summaryrefslogtreecommitdiff
path: root/.config/eww/scripts
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-23 06:47:03 +0300
committerThomas Voss <mail@thomasvoss.com> 2023-08-23 06:47:03 +0300
commit7ff798534a6fb9c99611d18ee22757346798ef61 (patch)
tree1f6603ff9f3eede365e6963b3ac66b5edbd232fb /.config/eww/scripts
parent8f7cbf4ad87d63fe82173645ecb590ebb0f12354 (diff)
eww: Add an eww configuration
Diffstat (limited to '.config/eww/scripts')
-rwxr-xr-x.config/eww/scripts/active-workspace-listener15
-rwxr-xr-x.config/eww/scripts/backlight-listener7
-rwxr-xr-x.config/eww/scripts/battery37
-rwxr-xr-x.config/eww/scripts/datetime-listener7
-rwxr-xr-x.config/eww/scripts/keymap-listener16
-rwxr-xr-x.config/eww/scripts/toggle17
-rwxr-xr-x.config/eww/scripts/volume-listener34
-rwxr-xr-x.config/eww/scripts/wireless3
-rwxr-xr-x.config/eww/scripts/workspace-list-listener28
9 files changed, 164 insertions, 0 deletions
diff --git a/.config/eww/scripts/active-workspace-listener b/.config/eww/scripts/active-workspace-listener
new file mode 100755
index 0000000..09a8298
--- /dev/null
+++ b/.config/eww/scripts/active-workspace-listener
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+readonly IPC=/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock
+
+hyprctl -j activeworkspace | jq -r '.name'
+socat -u UNIX-CONNECT:"$IPC" - \
+ | stdbuf -oL grep '^workspace>>' \
+ | while IFS= read -r line
+ do
+ IFS='>>'
+ set -- $line
+ echo $3
+ done
diff --git a/.config/eww/scripts/backlight-listener b/.config/eww/scripts/backlight-listener
new file mode 100755
index 0000000..82b5a55
--- /dev/null
+++ b/.config/eww/scripts/backlight-listener
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+while :
+do
+ lux | xargs printf '%g%%\n'
+ inotifywait -qqe modify /sys/class/backlight/*/brightness
+done
diff --git a/.config/eww/scripts/battery b/.config/eww/scripts/battery
new file mode 100755
index 0000000..0db4adb
--- /dev/null
+++ b/.config/eww/scripts/battery
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+set -e
+
+acpi | awk '
+ {
+ sub(/Battery [0-9]+: /, "")
+ FS = "[, ]+"
+ n = NF
+ sub(/%$/, "", $n)
+ printf "percentage=%d%%\n", $n
+ printf "icon="
+ $n = int($n)
+ if ($1 == "Charging")
+ print "󰂄"
+ else if ($n >= 90)
+ print "󰁹"
+ else if ($n >= 80)
+ print "󰂂"
+ else if ($n >= 70)
+ print "󰂁"
+ else if ($n >= 60)
+ print "󰁿"
+ else if ($n >= 50)
+ print "󰁾"
+ else if ($n >= 40)
+ print "󰁽"
+ else if ($n >= 30)
+ print "󰁼"
+ else if ($n >= 20)
+ print "󰁻"
+ else if ($n >= 10)
+ print "󰁺"
+ else
+ print "󰂎"
+ }' \
+ | jo
diff --git a/.config/eww/scripts/datetime-listener b/.config/eww/scripts/datetime-listener
new file mode 100755
index 0000000..c21dd02
--- /dev/null
+++ b/.config/eww/scripts/datetime-listener
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+while :
+do
+ date +'pretty=%d %B %Y (%A) — %T %Z%nmonth=%m' | jo
+ date +%s.%N | dc -e "? d 1 + 1 / r - p" | xargs sleep
+done
diff --git a/.config/eww/scripts/keymap-listener b/.config/eww/scripts/keymap-listener
new file mode 100755
index 0000000..a9666aa
--- /dev/null
+++ b/.config/eww/scripts/keymap-listener
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+readonly IPC=/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock
+
+hyprctl devices | sed -En '/Keyboard at/ {
+ :loop
+ n
+ /active keymap:/! b loop
+ s/.*active keymap: //p
+ q
+}
+'
+
+socat -u UNIX-CONNECT:"$IPC" - | sed -En 's/^activelayout>>[^,]+,//p'
diff --git a/.config/eww/scripts/toggle b/.config/eww/scripts/toggle
new file mode 100755
index 0000000..8ce7bcc
--- /dev/null
+++ b/.config/eww/scripts/toggle
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+# Open a file descriptor for writing to create the lock if it doesn’t exist. We
+# need a lock because of race-conditions that could occur if you spam a toggle
+# over and over.
+exec 3>"${XDG_RUNTIME_DIR:-/run/user/`id -u`}/eww-toggle.lock"
+flock 3
+
+for arg in "$@"; do
+ {
+ eww windows | grep -q "^\\*$arg$" && f=close || f=open
+ eww $f "$arg"
+ } &
+done
+wait
diff --git a/.config/eww/scripts/volume-listener b/.config/eww/scripts/volume-listener
new file mode 100755
index 0000000..9c0368c
--- /dev/null
+++ b/.config/eww/scripts/volume-listener
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+stdbuf -oL amixer events \
+ | stdbuf -oL sed 's/event value: //' \
+ | while IFS= read -r line
+ do
+ IFS='=,'
+ set -- $line
+ x=${6#\'}
+ x=${x%\'}
+ case "$x" in
+ 'Master Playback'*)
+ wpctl get-volume @DEFAULT_AUDIO_SINK@ \
+ | awk '
+ /MUTED/ {
+ print "icon="
+ print "percentage=Muted"
+ exit
+ }
+ {
+ printf "icon="
+ if ($2 < 0.33)
+ print ""
+ else if ($2 <= 0.66)
+ print ""
+ else
+ print ""
+ printf "percentage=%s%d%%\n", pad, $2 * 100
+ }
+ ' \
+ | jo
+ ;;
+ esac
+ done
diff --git a/.config/eww/scripts/wireless b/.config/eww/scripts/wireless
new file mode 100755
index 0000000..4221fe5
--- /dev/null
+++ b/.config/eww/scripts/wireless
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sudo wpa_cli status | sed -n 's/^ssid=//p'
diff --git a/.config/eww/scripts/workspace-list-listener b/.config/eww/scripts/workspace-list-listener
new file mode 100755
index 0000000..2024509
--- /dev/null
+++ b/.config/eww/scripts/workspace-list-listener
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set -e
+
+readonly IPC=/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock
+
+spaces="`hyprctl -j workspaces | jq -r 'sort_by(.id) | .[] | .name'`"
+jo -a $spaces
+
+socat -u UNIX-CONNECT:"$IPC" - \
+ | stdbuf -oL grep -E '^(create|destroy)workspace>>' \
+ | while IFS= read -r line
+ do
+ oifs="$IFS"
+ IFS='>>'
+ set -- $line
+ IFS="$oifs"
+
+ case "$1" in
+ c*)
+ spaces="`printf '%s\n%s\n' "$spaces" $3 | sort -V`"
+ ;;
+ d*)
+ spaces="`echo "$spaces" | grep -v "^$3$"`"
+ ;;
+ esac
+ jo -a $spaces
+ done