aboutsummaryrefslogtreecommitdiff
path: root/.config/i3blocks
diff options
context:
space:
mode:
Diffstat (limited to '.config/i3blocks')
-rw-r--r--.config/i3blocks/brightness.py17
-rw-r--r--.config/i3blocks/config98
-rwxr-xr-x.config/i3blocks/scripts/arch-update.py5
-rwxr-xr-x.config/i3blocks/scripts/calendar38
-rwxr-xr-x.config/i3blocks/scripts/disk-io25
-rw-r--r--.config/i3blocks/scripts/mediaplayer154
-rwxr-xr-x.config/i3blocks/scripts/myCalendar2
-rwxr-xr-x.config/i3blocks/scripts/rofi-calendar28
8 files changed, 304 insertions, 63 deletions
diff --git a/.config/i3blocks/brightness.py b/.config/i3blocks/brightness.py
new file mode 100644
index 0000000..993856e
--- /dev/null
+++ b/.config/i3blocks/brightness.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python3
+
+backlight_dir = '/sys/class/backlight/intel_backlight/'
+
+brightness_file = 'brightness'
+max_brightness_file = 'max_brightness'
+
+brightness = int(open(backlight_dir + brightness_file).read())
+max_brightness = int(open(backlight_dir + max_brightness_file).read())
+
+ratio = (brightness / max_brightness)
+percent = ratio * 100
+
+round_percent = percent + 2.5
+round_percent = round_percent - round_percent%5
+
+print("{}%".format(round(round_percent)))
diff --git a/.config/i3blocks/config b/.config/i3blocks/config
index ac3ddbb..a8001dd 100644
--- a/.config/i3blocks/config
+++ b/.config/i3blocks/config
@@ -30,10 +30,16 @@ markup=none
[arch-update]
-command=~/.config/i3blocks/scripts/arch-update.py #run arch-update.py -h for options
+command=python ~/.config/i3blocks/scripts/arch-update.py #run arch-update.py -h for options
interval=3600
markup=pango
-color=#006DA3
+
+[mediaplayer]
+command=perl ~/.config/i3blocks/scripts/mediaplayer
+instance=cmus
+interval=5
+signal=10
+label=♪
# Memory usage
#
@@ -61,19 +67,18 @@ interval=30
separator=false
[disk-io]
-label=
-command=~/.config/i3blocks/scripts/disk-io -w 2
-#command=$SCRIPT_DIR/disk-io -w 3 -M -P 0
+label=
+command=~/.config/i3blocks/scripts/disk-io
interval=persist
-markup=pango
-instance=/mmcblk0/
+#markup=pango
+
# Network interface monitoring
#
# If the instance is not specified, use the interface used for default route.
# The address can be forced to IPv4 or IPv6 with -4 or -6 switches.
[iface]
#instance=wlan0
-color=#00ffff
+color=#00FF00
interval=10
separator=false
@@ -96,12 +101,6 @@ interval=10
#min_width=CPU: 100.00%
separator=false
-[load_average]
-interval=10
-separator=false
-label=AVG
-
-#
# Temperature
#
# Support multiple chips, though lm-sensors.
@@ -110,10 +109,29 @@ label=AVG
[temperature]
label=TEMP
interval=10
-command=/usr/lib/i3blocks/temperature --chip coretemp-isa-0000
+separator=false
-# Key indicators
+[load_average]
+interval=10
+
+# Battery indicator
#
+# The battery instance defaults to 0.
+#[battery]
+#label=BAT
+#label=⚡
+#instance=1
+#interval=30
+#separator=false
+
+#[brightness]
+#command=~/.config/i3blocks/brightness.py
+#label=☀
+#interval=once
+#signal=12
+
+# Key indicators
+#🎧
# Add the following bindings to i3 config file:
#
# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks
@@ -122,32 +140,11 @@ command=/usr/lib/i3blocks/temperature --chip coretemp-isa-0000
instance=CAPS
interval=once
signal=11
-#
-#[keyindicator]
-#instance=NUM
-#interval=once
-#signal=11
-[brightness]
-command=~/.config/i3blocks/scripts/brightness.py
-label=
-#☀️
+[keyindicator]
+instance=NUM
interval=once
-signal=12
-
-# Battery indicator
-#
-# The battery instance defaults to 0.
-[battery]
-command=~/.config/i3blocks/scripts/batterybar
-#label=BAT
-markup=pango
-#label= BAT
-#🔋
-#⚡
-#instance=1
-interval=30
-#separator=false
+signal=11
# Volume indicator
#
@@ -155,20 +152,26 @@ interval=30
# The second parameter overrides the mixer selection
# See the script for details.
-#[volume]
-##label=VOL
-#label=♪
-#instance=Master
+[volume]
+#label=VOL
+label=VOL
+instance=Master
#instance=PCM
-#interval=once
-#signal=10
+interval=once
+signal=10
# Date Time
#
+#[calendar]
+#command=~/.config/i3blocks/scripts/calendar
+#label=
+#interval=3600
+
[time]
+command=~/.config/i3blocks/scripts/myCalendar -f '+%a %Y-%m-%d %H:%M:%S'
label=
-command=~/.config/i3blocks/scripts/myCalendar -f '+%a %Y-%m-%d %H:%M:%S'
+#command=date '+%a %Y-%m-%d %H:%M:%S'
interval=1
# Generic media player support
@@ -187,3 +190,4 @@ interval=1
#interval=20
+
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'