aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2018-12-12 14:45:10 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2018-12-12 14:45:10 +0100
commit98c5d04bb264cc903b935897b2188d8f2be4c7a1 (patch)
tree980f06ad65b322ae9073814470ebb69b2feca108
parentf28a3b624f84828a90524ccc7236678b4f4ddecc (diff)
downloadscripts-98c5d04bb264cc903b935897b2188d8f2be4c7a1.tar.gz
scripts-98c5d04bb264cc903b935897b2188d8f2be4c7a1.zip
i3blocks modules.
-rwxr-xr-xbrightness.sh13
-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
-rwxr-xr-xvol.sh9
8 files changed, 109 insertions, 5 deletions
diff --git a/brightness.sh b/brightness.sh
index b104d22..946453c 100755
--- a/brightness.sh
+++ b/brightness.sh
@@ -6,15 +6,18 @@ maxbrightness_file=/sys/class/backlight/intel_backlight/max_brightness
brightness=$(< $brightness_file)
maxbrightness=$(< $maxbrightness_file)
let target=$1+$brightness
-#for testing:
-#echo "Actual bright: $brightness; Max: $maxbrightness; Target: $target"
if [ $target -gt $maxbrightness ]
then
- echo "Value too big. Target: $target; max: $maxbrightness"
+ #echo "Value too big. Target: $target; max: $maxbrightness"
+ echo $maxbrightness | tee $brightness_file
elif [ 0 -gt $target ]
then
- echo "Value too low. Target: $target"
+ #echo "Value too low. Target: $target"
+ echo "0" | tee $brightness_file
else
echo $target | tee $brightness_file
- echo "New brightness: $target/$maxbrightness"
+ #echo "New brightness: $target/$maxbrightness"
fi
+
+notify-send -t 500 "$(~/scripts/i3blocks/i3brightness.sh)"
+pkill -SIGRTMIN+11 i3blocks
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
diff --git a/vol.sh b/vol.sh
new file mode 100755
index 0000000..827bf7b
--- /dev/null
+++ b/vol.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ $1 = "mute" ]; then
+ pactl set-sink-mute 0 toggle
+else
+ pactl set-sink-volume 0 $1%
+fi
+
+notify-send -t 500 "$(~/scripts/i3blocks/i3vol.sh)"
+pkill -SIGRTMIN+10 i3blocks