summaryrefslogtreecommitdiff
path: root/.config/eww/scripts
diff options
context:
space:
mode:
Diffstat (limited to '.config/eww/scripts')
-rwxr-xr-x.config/eww/scripts/getvol9
-rwxr-xr-x.config/eww/scripts/update_workspaces34
-rwxr-xr-x.config/eww/scripts/update_x_names33
3 files changed, 76 insertions, 0 deletions
diff --git a/.config/eww/scripts/getvol b/.config/eww/scripts/getvol
new file mode 100755
index 0000000..9fbe60f
--- /dev/null
+++ b/.config/eww/scripts/getvol
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+RUNNING_SINK=$(pactl list sinks | awk '
+ /^Sink #/ {sink=$2}
+ /State: RUNNING/ {print sink}
+' | head -n1)
+
+pactl list sinks | grep -A 20 "^Sink $RUNNING_SINK" | grep '^[[:space:]]Volume:' | \
+ head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
diff --git a/.config/eww/scripts/update_workspaces b/.config/eww/scripts/update_workspaces
new file mode 100755
index 0000000..4fb1b1c
--- /dev/null
+++ b/.config/eww/scripts/update_workspaces
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+gib_workspace_names() {
+ wmctrl -d \
+ | awk '{ print $1 " " $2 " " $9 }' \
+ | grep -v NSP
+}
+
+gib_workspace_yuck() {
+ buffered=""
+ gib_workspace_names | while read -r id active name; do
+ name="${name#*_}"
+ if [ "$active" == '*' ]; then
+ active_class="active"
+ else
+ active_class="inactive"
+ fi
+
+ if wmctrl -l | grep --regexp '.*\s\+'"$id"'\s\+.*' >/dev/null; then
+ button_class="occupied"
+ button_name="●"
+ else
+ button_class="empty"
+ button_name="○"
+ fi
+ buffered+="(button :class \"$button_class $active_class\" :onclick \"wmctrl -s $id\" \"$button_name\")"
+ echo -n "$buffered"
+ buffered=""
+ done
+}
+
+box_attrs=':orientation "h" :class "workspaces" :space-evenly false :halign "center" :valign "center" :vexpand false :spacing 8 '
+
+echo "(box $box_attrs $(gib_workspace_yuck))"
diff --git a/.config/eww/scripts/update_x_names b/.config/eww/scripts/update_x_names
new file mode 100755
index 0000000..63117ef
--- /dev/null
+++ b/.config/eww/scripts/update_x_names
@@ -0,0 +1,33 @@
+#!/run/current-system/profile/bin/guile \
+-s
+!#
+
+(use-modules (ice-9 popen)
+ (ice-9 textual-ports)
+ (ice-9 rdelim))
+
+(define cmd "wmctrl -l | awk -v ws=\"$(wmctrl -d | awk '$2 == \"*\" {print $1}')\" '$2 == ws {print}' | cut -d ' ' -f 5-")
+
+(define box-attrs '(:class "classes"
+ :orientation "h"
+ :valign "center"
+ :halign "start"
+ :space-evenly "false"))
+
+(define titles
+ (let* ((process (open-pipe* OPEN_READ "sh" "-c" cmd))
+ (output (get-string-all process)))
+ (close-pipe process)
+ output))
+
+(define labels
+ (map (lambda (t) `(eventbox
+ :onclick ,(string-concatenate `("wmctrl -a \"" ,t "\""))
+ (label :class "class"
+ :text ,t
+ :truncate true
+ :valign "center")))
+ (filter (lambda (s) (not (string=? s "")))
+ (string-split titles #\newline))))
+
+(write `(box ,@box-attrs ,@labels))