diff options
Diffstat (limited to '.config/i3blocks/scripts')
| -rwxr-xr-x | .config/i3blocks/scripts/arch-update.py | 5 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/calendar | 38 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/disk-io | 25 | ||||
| -rw-r--r-- | .config/i3blocks/scripts/mediaplayer | 154 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/myCalendar | 2 | ||||
| -rwxr-xr-x | .config/i3blocks/scripts/rofi-calendar | 28 |
6 files changed, 236 insertions, 16 deletions
diff --git a/.config/i3blocks/scripts/arch-update.py b/.config/i3blocks/scripts/arch-update.py index 7dc5d62..7a7be68 100755 --- a/.config/i3blocks/scripts/arch-update.py +++ b/.config/i3blocks/scripts/arch-update.py @@ -8,6 +8,7 @@ import subprocess from subprocess import check_output import argparse import re +import os def create_argparse(): @@ -103,7 +104,6 @@ if update_count > 0: info += ' [{0}]'.format(', '.join(matches)) print(message.format(args.updates_available_color, info)) - import os if 'BLOCK_BUTTON' in os.environ: button = os.environ['BLOCK_BUTTON'] if button is not '': @@ -112,5 +112,6 @@ if update_count > 0: subprocess.call("termite -e 'sudo pacman -Syu' --hold", shell=True) + elif not args.quiet: - print(message.format(args.base_color, '-Syu ')) + print(message.format(args.base_color, '-Syu ')) diff --git a/.config/i3blocks/scripts/calendar b/.config/i3blocks/scripts/calendar new file mode 100755 index 0000000..fe09fcc --- /dev/null +++ b/.config/i3blocks/scripts/calendar @@ -0,0 +1,38 @@ +#! /bin/sh + +width=200 +height=200 +datefmt="+%a %Y-%m-%d" + +OPTIND=1 +while getopts ":f:W:H:" opt; do + case $opt in + f) datefmt="$OPTARG" ;; + W) width="$OPTARG" ;; + H) height="$OPTARG" ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +case "$BLOCK_BUTTON" in + 1|2|3) + + # the position of the upper left corner of the popup + posX=$(($BLOCK_X - $width)) + posY=$(($BLOCK_Y)) #+ $height)) + + i3-msg -q "exec yad --calendar \ + --width=$width --height=$height \ + --fixed \ + --close-on-unfocus --no-buttons \ + --posx=$posX --posy=$posY \ + > /dev/null" +esac +date "$datefmt" diff --git a/.config/i3blocks/scripts/disk-io b/.config/i3blocks/scripts/disk-io index 14ccc14..6e89bef 100755 --- a/.config/i3blocks/scripts/disk-io +++ b/.config/i3blocks/scripts/disk-io @@ -5,18 +5,19 @@ # # i3blocks blocklet script to monitor disk io -label="" -dt=5 -MB_only=0 -kB_only=0 -width=4 -MB_precision=1 -kB_precision=0 -regex="${BLOCK_INSTANCE:-/^(s|h)d[a-zA-Z]+/}" -threshold=0 -warn_color="#FF0000" -sep="/" -unit_suffix="B/s" +label="${PREFIX:-""}" +dt="${DT:-5}" +MB_only="${MB_ONLY:-0}" +kB_only="${KB_ONLY:-0}" +width="${WIDTH:-4}" +MB_precision="${MB_PRECISION:-1}" +kB_precision="${KB_PRECISION:-0}" +regex="${REGEX:-$BLOCK_INSTANCE}" +regex="${regex:-/^(s|h)d[a-zA-Z]+/}" +threshold="${THRESHOLD:-0}" +warn_color="${WARN_COLOR:-#FF0000}" +sep="${SEPARATOR:-/}" +unit_suffix="${SUFFIX:-B/s}" function list_devices { echo "Devices iostat reports that match our regex:" diff --git a/.config/i3blocks/scripts/mediaplayer b/.config/i3blocks/scripts/mediaplayer new file mode 100644 index 0000000..718e335 --- /dev/null +++ b/.config/i3blocks/scripts/mediaplayer @@ -0,0 +1,154 @@ +#!/usr/bin/env perl +# Copyright (C) 2014 Tony Crisci <tony@dubstepdish.com> +# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Requires playerctl binary to be in your path (except cmus) +# See: https://github.com/acrisci/playerctl + +# Set instance=NAME in the i3blocks configuration to specify a music player +# (playerctl will attempt to connect to org.mpris.MediaPlayer2.[NAME] on your +# DBus session). + +use Time::HiRes qw(usleep); +use Env qw(BLOCK_INSTANCE); + +use constant DELAY => 50; # Delay in ms to let network-based players (spotify) reflect new data. +use constant SPOTIFY_STR => 'spotify'; + +my @metadata = (); +my $player_arg = ""; + +if ($BLOCK_INSTANCE) { + $player_arg = "--player='$BLOCK_INSTANCE'"; +} + +sub buttons { + my $method = shift; + + if($method eq 'mpd') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("mpc prev"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("mpc toggle"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("mpc next"); + } elsif ($ENV{'BLOCK_BUTTON'} == 4) { + system("mpc volume +10"); + } elsif ($ENV{'BLOCK_BUTTON'} == 5) { + system("mpc volume -10"); + } + } elsif ($method eq 'cmus') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("cmus-remote --prev"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("cmus-remote --pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("cmus-remote --next"); + } + } elsif ($method eq 'playerctl') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("playerctl $player_arg previous"); + usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("playerctl $player_arg play-pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("playerctl $player_arg next"); + usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; + } elsif ($ENV{'BLOCK_BUTTON'} == 4) { + system("playerctl $player_arg volume 0.01+"); + } elsif ($ENV{'BLOCK_BUTTON'} == 5) { + system("playerctl $player_arg volume 0.01-"); + } + } elsif ($method eq 'rhythmbox') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("rhythmbox-client --previous"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("rhythmbox-client --play-pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("rhythmbox-client --next"); + } + } +} + +sub cmus { + my @cmus = split /^/, qx(cmus-remote -Q); + if ($? == 0) { + foreach my $line (@cmus) { + my @data = split /\s/, $line; + if (shift @data eq 'tag') { + my $key = shift @data; + my $value = join ' ', @data; + + @metadata[0] = $value if $key eq 'artist'; + @metadata[1] = $value if $key eq 'title'; + } + } + + if (@metadata) { + buttons('cmus'); + + # metadata found so we are done + print(join ' - ', @metadata); + exit 0; + } + } +} + +sub mpd { + my $data = qx(mpc current); + if (not $data eq '') { + buttons("mpd"); + print($data); + exit 0; + } +} + +sub playerctl { + buttons('playerctl'); + + my $artist = qx(playerctl $player_arg metadata artist); + # exit status will be nonzero when playerctl cannot find your player + exit(0) if $? || $artist eq '(null)'; + + push(@metadata, $artist) if $artist; + + my $title = qx(playerctl $player_arg metadata title); + exit(0) if $? || $title eq '(null)'; + + push(@metadata, $title) if $title; + + print(join(" - ", @metadata)) if @metadata; +} + +sub rhythmbox { + buttons('rhythmbox'); + + my $data = qx(rhythmbox-client --print-playing --no-start); + print($data); +} + +if ($player_arg eq '' or $player_arg =~ /mpd/) { + mpd; +} +elsif ($player_arg =~ /cmus/) { + cmus; +} +elsif ($player_arg =~ /rhythmbox/) { + rhythmbox; +} +else { + playerctl; +} diff --git a/.config/i3blocks/scripts/myCalendar b/.config/i3blocks/scripts/myCalendar index d1557ba..686fd00 100755 --- a/.config/i3blocks/scripts/myCalendar +++ b/.config/i3blocks/scripts/myCalendar @@ -1,6 +1,4 @@ #!/bin/bash -# this is a simple bash script / blocklet for i3blocks -# that will open a new termite instance with 'cal' when clicked datefmt='+%a %Y-%m-%d %H:%M:%S' diff --git a/.config/i3blocks/scripts/rofi-calendar b/.config/i3blocks/scripts/rofi-calendar new file mode 100755 index 0000000..e1f12d0 --- /dev/null +++ b/.config/i3blocks/scripts/rofi-calendar @@ -0,0 +1,28 @@ +#! /bin/sh + +blockdate=$(date '+%a. %d. %b. %Y') + +case "$BLOCK_BUTTON" in + 1|2|3) date=$(date '+%A, %d. %B') +export TERM=xterm +cal --color=always \ + | sed 's/\x1b\[[7;]*m/\<b\>\<u\>/g' \ + | sed 's/\x1b\[[27;]*m/\<\/u\>\<\/b\>/g' \ + | tail -n +2 \ + | rofi \ + -dmenu \ + -markup-rows \ + -no-fullscreen \ + -font "Monospace 6" \ + -hide-scrollbar \ + -bw 2 \ + -m -3 \ + -theme-str '#window {anchor:northeast; location: southeast;}' \ + -eh 1 \ + -width -22 \ + -no-custom \ + -no-config \ + -p "$date" > /dev/null + esac +echo $blockdate +date '+%d.%m.%Y' |
