aboutsummaryrefslogtreecommitdiff
path: root/i3blocks
diff options
context:
space:
mode:
Diffstat (limited to 'i3blocks')
-rwxr-xr-xi3blocks/i3battery.sh37
-rwxr-xr-xi3blocks/i3brightness.sh5
-rwxr-xr-xi3blocks/i3date.sh4
-rwxr-xr-xi3blocks/i3internet.sh26
-rwxr-xr-xi3blocks/i3music.sh12
-rwxr-xr-xi3blocks/i3vol.sh8
6 files changed, 92 insertions, 0 deletions
diff --git a/i3blocks/i3battery.sh b/i3blocks/i3battery.sh
new file mode 100755
index 0000000..34c461a
--- /dev/null
+++ b/i3blocks/i3battery.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Give a battery name (e.g. BAT1) as an argument.
+
+case $BLOCK_BUTTON in
+ 3) pgrep -x dunst >/dev/null && notify-send "<b>🔋 Battery module:</b>
+🔋: discharging
+♻: stagnant charge
+🔌: charging
+⚡: charged
+❗: battery very low!
+- Text color reflects charge left" ;;
+esac
+
+capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
+status=$(cat /sys/class/power_supply/"$1"/status)
+
+#if [ "$capacity" -ge 80 ]; then
+# color="#b8bb26"
+#elif [ "$capacity" -ge 60 ]; then
+# color="#ebdbb2"
+#elif [ "$capacity" -ge 40 ]; then
+# color="#fabd2f"
+#elif [ "$capacity" -ge 20 ]; then
+# color="#fe8019"
+#else
+# color="#fb4934"
+# warn="❗"
+#fi
+
+[ ! "$capacity" -gt 15 ] && warn="❗"
+[ -z $warn ] && warn=""
+
+#[ "$status" = "Charging" ] && color="#FFF"
+
+printf "%s%s%s%s" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')" "$warn"
+
+echo ""
diff --git a/i3blocks/i3brightness.sh b/i3blocks/i3brightness.sh
new file mode 100755
index 0000000..0347ae6
--- /dev/null
+++ b/i3blocks/i3brightness.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+value=$(cat /sys/class/backlight/intel_backlight/brightness)
+max=$(cat /sys/class/backlight/intel_backlight/max_brightness)
+echo "☀️$(($(($value*100))/$max))%"
diff --git a/i3blocks/i3date.sh b/i3blocks/i3date.sh
new file mode 100755
index 0000000..c393327
--- /dev/null
+++ b/i3blocks/i3date.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+dayofyear=$(date +%j)
+perc=$(echo "scale=1; ($dayofyear*100)/365" | bc)
+echo $(date +"%A, %y/%m/%d ($perc%) - %T")
diff --git a/i3blocks/i3internet.sh b/i3blocks/i3internet.sh
new file mode 100755
index 0000000..536b242
--- /dev/null
+++ b/i3blocks/i3internet.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#case $BLOCK_BUTTON in
+# 1) $TERMINAL -e nmtui ;;
+# 3) pgrep -x dunst >/dev/null && notify-send "<b>🌐 Internet module:</b>
+#- Click for \`nmtui\` for wifi access
+#📡: no wifi connection
+#📶: wifi connection with quality
+#❎: no ethernet
+#🌐: ethernet working
+#" ;;
+#esac
+#
+#[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="📡"
+#
+#[ ! -n "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }')
+#
+#printf "%s %s" "$wifiicon" "$(cat /sys/class/net/e*/operstate | sed "s/down/❎/;s/up/🌐/")"
+
+wstatus=$(cat /sys/class/net/wlp2s0/operstate)
+estatus=$(cat /sys/class/net/enp3s0/operstate)
+wifi="$(nmcli | grep "wlp2s0: conectado to " | cut -d' ' -f4-) ($(ip addr show wlp2s0 | grep "inet " | cut -d' ' -f6))"
+en=$(ip addr show enp3s0 | grep "inet " | cut -d' ' -f6)
+[ $wstatus = "down" ] && wifi="down"
+[ $estatus = "down" ] && en="down"
+echo "W: 📶 $wifi - E: 🌐 $en"
diff --git a/i3blocks/i3music.sh b/i3blocks/i3music.sh
new file mode 100755
index 0000000..6cb9f10
--- /dev/null
+++ b/i3blocks/i3music.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+status=$(cmus-remote -Q | grep status | awk '{print $2}')
+if [ $status = "playing" ]; then
+ artist=$(cmus-remote -Q | grep "tag artist " | cut -d' ' -f3-)
+ title=$(cmus-remote -Q | grep "tag title " | cut -d' ' -f3-)
+ [ -z $artist ] && artist="(unknown)"
+ [ -z $title ] && title=$(cmus-remote -Q | grep "file " | cut -d'/' -f5-)
+ echo "$artist ─ $title"
+else
+ echo "$status"
+fi
diff --git a/i3blocks/i3vol.sh b/i3blocks/i3vol.sh
new file mode 100755
index 0000000..5f91bde
--- /dev/null
+++ b/i3blocks/i3vol.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+vol=$(pactl list sinks | grep Volumen: | awk '{print $5}')
+mute=$(pactl list sinks | grep Silencio: | cut -d' ' -f2)
+if [ $mute = "no" ]; then
+ echo "🔊 $vol"
+else
+ echo "🔇($vol)"
+fi