aboutsummaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2026-08-15 09:35:09 +0100
committerJustine Smithies <justine@smithies.me.uk>2026-08-15 09:35:09 +0100
commita61da6f76813790bfaa2a995d9285d616b0b0a86 (patch)
tree2bccdb95cf4c8bd1a67478626e4fbd660209044f /.config
parente14e6e48a276264397d1cc6feedeab9260e5930a (diff)
Initial commit of very WIP cow scripts
Diffstat (limited to '.config')
-rwxr-xr-x.config/cow/scripts/battery.sh51
-rwxr-xr-x.config/cow/scripts/brightnesscontrol.sh39
-rwxr-xr-x.config/cow/scripts/calendar.sh26
-rwxr-xr-x.config/cow/scripts/date-time.sh10
-rwxr-xr-x.config/cow/scripts/idleinhibit.sh28
-rwxr-xr-x.config/cow/scripts/keyboard-layout.sh6
-rwxr-xr-x.config/cow/scripts/swayidle-update.sh7
-rwxr-xr-x.config/cow/scripts/volumecontrol.sh129
8 files changed, 296 insertions, 0 deletions
diff --git a/.config/cow/scripts/battery.sh b/.config/cow/scripts/battery.sh
new file mode 100755
index 0000000..2996547
--- /dev/null
+++ b/.config/cow/scripts/battery.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# Send a notification if battery is low, change status in info file accordingly
+notify_low () {
+
+ # Battery isn't much but is charging (don't notify)
+ [ "$status" = "on-line" ] && return
+
+ # Battery critically low
+ if [ "$capacity" -le 10 ] && ! grep -q critically-low "$lowinfo"; then
+ notify-send -i "$HOME/.config/icons/critical-battery.png" -u critical "Battery critically low!"
+ echo critically-low >"$lowinfo"
+
+ # Battery is low
+ elif [ "$capacity" -le 20 ] && ! grep -q low "$lowinfo"; then
+ notify-send -i "$HOME/.config/icons/low-battery.png" -t 5500 "Battery low!"
+ echo low >"$lowinfo"
+ fi
+}
+
+status="$(apm | grep -E "AC Line status:" | sed -n -e 's/^.*AC Line status: //p')"
+capacity="$(apm | grep -E "Remaining battery life:" | head -1 | sed -n -e 's/^.*Remaining battery life: //p' | sed 's/.$//')"
+
+# Get the low battery status from file ~/.cache/battery-low-status
+lowinfo="$HOME/.cache/battery-low-status"
+[ ! -e "$lowinfo" ] && touch "$lowinfo"
+
+
+case $1 in
+ left-click)
+ ;;
+ *)
+ # Set charging icon and capacity icon
+ [ "$status" = "on-line" ] && charging_icon="" || charging_icon=""
+ [ "$capacity" -gt 100 ] && capacity=100
+ if [ "$capacity" -lt 15 ]; then capacity_icon=' '
+ elif [ "$capacity" -lt 40 ]; then capacity_icon=' '
+ elif [ "$capacity" -lt 60 ]; then capacity_icon=' '
+ elif [ "$capacity" -lt 90 ]; then capacity_icon=' '
+ else capacity_icon=' '
+ fi
+
+ # Report low battery
+ [ "$capacity" -le 20 ] && notify_low
+
+ # Reset low battery information in these cases
+ { [ "$capacity" -gt 20 ] || [ "$status" = "Charging" ]; } && [ -n "$(cat "$lowinfo")" ] && echo "" >"$lowinfo"
+
+ echo "$capacity_icon$charging_icon $capacity"
+ ;;
+esac
diff --git a/.config/cow/scripts/brightnesscontrol.sh b/.config/cow/scripts/brightnesscontrol.sh
new file mode 100755
index 0000000..aed1bda
--- /dev/null
+++ b/.config/cow/scripts/brightnesscontrol.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# You can call this script like this:
+# brightnessControl up
+# brightnessControl down
+
+# Script inspired by these wonderful people:
+# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
+# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
+
+send_notification() {
+ icon="/usr/share/icons/Adwaita/symbolic/status/daytime-sunrise-symbolic.svg"
+ brightness=$(backlight -q)
+ # Make the bar with the special character ─ (it's not dash -)
+ # https://en.wikipedia.org/wiki/Box-drawing_character
+ bar=$(seq -s "─" 0 $((brightness / 10 )) | sed 's/[0-9]//g')
+ # Send the notification
+ fyi -i "$icon" --hint=string:x-canonical-private-synchronous:brightness -u normal "$bar $brightness"
+}
+
+case $1 in
+ up)
+ backlight + 4
+ backlight > ~/.cache/brightness
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ down)
+ backlight - 4
+ backlight > ~/.cache/brightness
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ *)
+ text=$(backlight -q)
+ icon=""
+ echo "$icon $text"
+ ;;
+esac
diff --git a/.config/cow/scripts/calendar.sh b/.config/cow/scripts/calendar.sh
new file mode 100755
index 0000000..82ddd92
--- /dev/null
+++ b/.config/cow/scripts/calendar.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Calendar script
+
+ShowCalendar() {
+ fyi -a "Calendar" --hint string:x-canonical-private-synchronous:calendar " 📅 Calendar" "$(cal | sed "s/\<$(date +%-d)\>/<span color='#fabd2f'><b>$(date +%-d)<\/b><\/span>/")"
+}
+
+EditCalendar() {
+ echo
+}
+
+case "$1" in
+ show)
+ ShowCalendar
+ ;;
+
+ edit)
+ EditCalendar
+ ;;
+
+ *)
+ echo $"Usage: ${0##*/} {show|edit}"
+ exit 1
+
+esac
diff --git a/.config/cow/scripts/date-time.sh b/.config/cow/scripts/date-time.sh
new file mode 100755
index 0000000..4ff00d4
--- /dev/null
+++ b/.config/cow/scripts/date-time.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+DaySuffix() {
+ case `date +%-d` in
+ 1|21|31) echo "st";;
+ 2|22) echo "nd";;
+ 3|23) echo "rd";;
+ *) echo "th";;
+ esac
+}
+echo $(date "+%A %-d`DaySuffix` %B %Y - %H:%M ")
diff --git a/.config/cow/scripts/idleinhibit.sh b/.config/cow/scripts/idleinhibit.sh
new file mode 100755
index 0000000..1196cbe
--- /dev/null
+++ b/.config/cow/scripts/idleinhibit.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Swayidle toggle
+toggle() {
+ if pgrep "swayidle" > /dev/null
+ then
+ pkill swayidle
+ notify-send --hint=string:x-canonical-private-synchronous:idleinhibit -u normal " Swayidle Inactive"
+ else
+ sh "$HOME/.config/cow/scripts/swayidle-update.sh"
+ notify-send --hint=string:x-canonical-private-synchronous:idleinhibit -u normal " Swayidle Active"
+ fi
+}
+
+case $1 in
+ toggle)
+ toggle
+ ;;
+ *)
+ if pgrep "swayidle" > /dev/null
+ then
+ icon=""
+ else
+ icon=""
+ fi
+ echo "$icon"
+ ;;
+esac
diff --git a/.config/cow/scripts/keyboard-layout.sh b/.config/cow/scripts/keyboard-layout.sh
new file mode 100755
index 0000000..2d9ee13
--- /dev/null
+++ b/.config/cow/scripts/keyboard-layout.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Get keyboard layout name
+echo "$(moocow show keyboard-layout | jq -r .data | awk -F '[()]' '{print $2}')"
+
+
diff --git a/.config/cow/scripts/swayidle-update.sh b/.config/cow/scripts/swayidle-update.sh
new file mode 100755
index 0000000..1f905a9
--- /dev/null
+++ b/.config/cow/scripts/swayidle-update.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+pkill -f swayidle
+read -r wallpaper<"$HOME/.cache/wallpaper"
+swayidle -w \
+ timeout 300 "swaylock -f -i $wallpaper --effect-blur 10x5 --clock --datestr '%a %d %b %Y' --indicator" \
+ timeout 600 "wlopm --off \*;swaylock -F -i $wallpaper --effect-blur 10x5 --clock --datestr '%a %d %b %Y' --indicator" resume "wlopm --on \*" &
+# before-sleep "swaylock -f -i $wallpaper --effect-blur 10x5 --clock --datestr '%a %d %b %Y' --indicator" &
diff --git a/.config/cow/scripts/volumecontrol.sh b/.config/cow/scripts/volumecontrol.sh
new file mode 100755
index 0000000..558d3e4
--- /dev/null
+++ b/.config/cow/scripts/volumecontrol.sh
@@ -0,0 +1,129 @@
+#!/bin/sh
+
+# You can call this script like this:
+# volumecontrol up
+# volumecontrol down
+# volumecontrol mute
+
+get_volume() {
+ # pactl get-sink-volume @DEFAULT_SINK@ | grep '%' | cut -d '%' -f 1 | cut -d ' ' -f 6
+ echo "scale=1; $(mixer vol | grep 'vol.volume=' | cut -d '=' -f 2 | cut -d ':' -f 1)*100" | bc | cut -d '.' -f 1
+}
+
+is_mute() {
+ # pactl get-sink-mute @DEFAULT_SINK@ | grep 'Mute: yes' >> /dev/null
+ mixer vol | grep 'vol.mute=on' >> /dev/null
+}
+
+send_notification() {
+ volume=$(get_volume)
+ # Make the bar with the special character ─ (it's not dash -)
+ # https://en.wikipedia.org/wiki/Box-drawing_character
+ if [ "$volume" = "100" ]; then
+ icon=""
+ elif [ "$volume" -ge "89" ] && [ "$volume" -le "100" ]; then
+ icon=""
+ elif [ "$volume" -ge "79" ] && [ "$volume" -le "90" ]; then
+ icon=""
+ elif [ "$volume" -ge "69" ] && [ "$volume" -le "80" ]; then
+ icon=""
+ elif [ "$volume" -ge "59" ] && [ "$volume" -le "70" ]; then
+ icon=""
+ elif [ "$volume" -ge "49" ] && [ "$volume" -le "60" ]; then
+ icon=""
+ elif [ "$volume" -ge "39" ] && [ "$volume" -le "50" ]; then
+ icon=""
+ elif [ "$volume" -ge "29" ] && [ "$volume" -le "40" ]; then
+ icon=""
+ elif [ "$volume" -ge "19" ] && [ "$volume" -le "30" ]; then
+ icon=""
+ elif [ "$volume" -ge "9" ] && [ "$volume" -le "20" ]; then
+ icon=""
+ elif [ "$volume" -gt "0" ] && [ "$volume" -le "10" ]; then
+ icon=""
+ elif [ "$volume" -eq "0" ]; then
+ icon=""
+ class="muted"
+ fi
+bar=$(seq -s "─" $(($volume/5)) | sed 's/[0-9]//g')
+# Send the notification
+fyi --hint=string:x-canonical-private-synchronous:volumecontrol -u normal "$icon $bar $volume"
+}
+
+case $1 in
+ up)
+ # pactl set-sink-mute @DEFAULT_SINK@ 0
+ mixer vol.mute=off
+ # Up the volume (+ 2%)
+ # pactl set-sink-volume @DEFAULT_SINK@ +2%
+ mixer vol.volume=+2%
+ mixer vol > ~/.cache/audio-volume
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ down)
+ # pactl set-sink-mute @DEFAULT_SINK@ 0
+ mixer vol.mute=off
+ # pactl set-sink-volume @DEFAULT_SINK@ -2%
+ mixer vol.volume=-2%
+ mixer vol > ~/.cache/audio-volume
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ mute)
+ # Toggle mute
+ # pactl set-sink-mute @DEFAULT_SINK@ toggle
+ mixer vol.mute=toggle
+ mixer vol > ~/.cache/audio-volume
+ if is_mute ; then
+ icon="󰝟"
+ class="muted"
+ text="<span color='#202020' bgcolor='#ff00aa' > $icon </span> $volume"
+ fyi --hint=string:x-canonical-private-synchronous:volumecontrol -u normal "$icon Audio Muted"
+ else
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ fi
+ ;;
+ *)
+ volume="$(get_volume)"
+
+ if [ "$volume" = "100" ]; then
+ icon=""
+ elif [ "$volume" -ge "89" ] && [ "$volume" -le "100" ]; then
+ icon=""
+ elif [ "$volume" -ge "79" ] && [ "$volume" -le "90" ]; then
+ icon=""
+ elif [ "$volume" -ge "69" ] && [ "$volume" -le "80" ]; then
+ icon=""
+ elif [ "$volume" -ge "59" ] && [ "$volume" -le "70" ]; then
+ icon=""
+ elif [ "$volume" -ge "49" ] && [ "$volume" -le "60" ]; then
+ icon=""
+ elif [ "$volume" -ge "39" ] && [ "$volume" -le "50" ]; then
+ icon=""
+ elif [ "$volume" -ge "29" ] && [ "$volume" -le "40" ]; then
+ icon=""
+ elif [ "$volume" -ge "19" ] && [ "$volume" -le "30" ]; then
+ icon=""
+ elif [ "$volume" -ge "9" ] && [ "$volume" -le "20" ]; then
+ icon=""
+ elif [ "$volume" -gt "0" ] && [ "$volume" -le "10" ]; then
+ icon=""
+ elif [ "$volume" -eq "0" ]; then
+ icon="󰝟"
+ class="muted"
+ fi
+
+
+if is_mute || [ "$class" = 'muted' ]; then
+ icon="󰝟"
+ class="muted"
+ text="<span color='#202020' bgcolor='#cc241d' > $icon </span> $volume"
+ else
+ text="<span color='#202020' bgcolor='#d65d0e' > $icon </span> $volume"
+fi
+
+echo "$icon $volume"
+ ;;
+esac