aboutsummaryrefslogtreecommitdiff
path: root/.config/eww/scripts
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2024-11-08 20:48:58 +0000
committerJustine Smithies <justine@smithies.me.uk>2024-11-08 20:48:58 +0000
commitc2fbc4d1717864a0055592e0b73d71c010e8686c (patch)
tree76e5bf50cc0f9c1b83f474740a8015d7f4e0ef26 /.config/eww/scripts
parentb9d24b3b6bdaed04fab07d9150c51d4f0f7a5c7d (diff)
Initial commit
Diffstat (limited to '.config/eww/scripts')
-rwxr-xr-x.config/eww/scripts/arch-updates.sh39
-rwxr-xr-x.config/eww/scripts/bar-toggle.sh18
-rwxr-xr-x.config/eww/scripts/battery.sh53
-rwxr-xr-x.config/eww/scripts/brightnesscontrol39
-rwxr-xr-x.config/eww/scripts/calendar.sh26
-rwxr-xr-x.config/eww/scripts/date-time.sh12
-rwxr-xr-x.config/eww/scripts/idleinhibit.sh33
-rwxr-xr-x.config/eww/scripts/keyboardlayout.sh8
-rwxr-xr-x.config/eww/scripts/monitor.sh11
-rwxr-xr-x.config/eww/scripts/network.sh43
-rwxr-xr-x.config/eww/scripts/scratchpad-indicator.sh35
-rwxr-xr-x.config/eww/scripts/start.sh41
-rwxr-xr-x.config/eww/scripts/void-updates.sh39
-rwxr-xr-x.config/eww/scripts/volumecontrol123
-rwxr-xr-x.config/eww/scripts/workspace.sh64
15 files changed, 584 insertions, 0 deletions
diff --git a/.config/eww/scripts/arch-updates.sh b/.config/eww/scripts/arch-updates.sh
new file mode 100755
index 0000000..e3da71f
--- /dev/null
+++ b/.config/eww/scripts/arch-updates.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+function CheckUpdates() {
+xbps-install -Mun 1> /tmp/void-updates
+updates="$(cat /tmp/void-updates | awk '{ print $1 }')"
+number=$(cat /tmp/void-updates | wc -l)
+
+if [ "$number" -gt 0 ]; then
+ text=" $number"
+else
+ text=""
+fi
+
+echo "$text"
+}
+
+function RefreshUpdates() {
+ value="$(CheckUpdates)"
+ eww update arch-updates="$value"
+}
+
+function Update() {
+ foot bash -c 'sudo xbps-install -Suv'
+ RefreshUpdates
+}
+
+case "$1" in
+ Refresh)
+ RefreshUpdates
+ exit 0
+ ;;
+ Update)
+ Update
+ exit 0
+ ;;
+ *)
+ CheckUpdates
+ exit 0
+esac
diff --git a/.config/eww/scripts/bar-toggle.sh b/.config/eww/scripts/bar-toggle.sh
new file mode 100755
index 0000000..78d0050
--- /dev/null
+++ b/.config/eww/scripts/bar-toggle.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+monitors=$(river-bedload -print outputs | jq -r -c '.[] | .name' | wc -l | xargs)
+
+for ((i = 0 ; i < $monitors ; i++)); do
+ echo $i
+ active_monitor=$(river-bedload -print outputs | jq 'map(.focused)|to_entries|.[]|select(.value)|.key')
+ # Flip value e.g 0 to 1
+ if [ "$monitors" != "1" ]; then
+ ((active_monitor ^= 1))
+ fi
+ bar=$(eww active-windows | grep "bar$i")
+ if [ "$active_monitor" == "$i" ] && [ "$bar" == "bar$i: bar$i" ]; then
+ eww close bar$i
+ elif [ "$active_monitor" == "$i" ]; then
+ eww open bar$i
+ fi
+done
+
diff --git a/.config/eww/scripts/battery.sh b/.config/eww/scripts/battery.sh
new file mode 100755
index 0000000..a984346
--- /dev/null
+++ b/.config/eww/scripts/battery.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+
+# 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"
+
+ printf "%s%s%d%%\n" "$charging_icon" "$capacity_icon" "$capacity"
+ ;;
+esac
+
+
diff --git a/.config/eww/scripts/brightnesscontrol b/.config/eww/scripts/brightnesscontrol
new file mode 100755
index 0000000..1e8ea9f
--- /dev/null
+++ b/.config/eww/scripts/brightnesscontrol
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+# 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
+
+function 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
+ ;;
+ *)
+ brightness=$(backlight -q)
+ icon=""
+ printf "%s" "$icon $brightness" "%"
+ ;;
+esac
diff --git a/.config/eww/scripts/calendar.sh b/.config/eww/scripts/calendar.sh
new file mode 100755
index 0000000..a9e3502
--- /dev/null
+++ b/.config/eww/scripts/calendar.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+# Calendar script
+
+function 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>/")"
+}
+
+function EditCalendar() {
+ echo
+}
+
+case "$1" in
+ show)
+ ShowCalendar
+ ;;
+
+ edit)
+ EditCalendar
+ ;;
+
+ *)
+ echo $"Usage: ${0##*/} {show|edit}"
+ exit 1
+
+esac
diff --git a/.config/eww/scripts/date-time.sh b/.config/eww/scripts/date-time.sh
new file mode 100755
index 0000000..9835842
--- /dev/null
+++ b/.config/eww/scripts/date-time.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+DaySuffix() {
+ case `date +%-d` in
+ 1|21|31) echo "st";;
+ 2|22) echo "nd";;
+ 3|23) echo "rd";;
+ *) echo "th";;
+ esac
+}
+date=$(date "+%A %-d`DaySuffix` %B %Y")
+icon=""
+printf "%s" "$date "
diff --git a/.config/eww/scripts/idleinhibit.sh b/.config/eww/scripts/idleinhibit.sh
new file mode 100755
index 0000000..f606ad5
--- /dev/null
+++ b/.config/eww/scripts/idleinhibit.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# Swayidle toggle
+function toggle {
+ if pgrep "swayidle" > /dev/null
+ then
+ pkill swayidle
+ notify-send --hint=string:x-canonical-private-synchronous:idleinhibit -u normal " Swayidle Inactive"
+else
+ read -r wallpaper<~/.cache/wallpaper
+ export wallpaper=$( echo $wallpaper)
+ swayidle -w \
+ timeout 300 'swaylock -f -i $wallpaper' \
+ timeout 600 'wlopm --off \*;swaylock -F -i $wallpaper' resume 'wlopm --on \*' \
+ before-sleep 'swaylock -f -i $wallpaper' &
+ 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
+ printf "%s" "$icon "
+ ;;
+esac
diff --git a/.config/eww/scripts/keyboardlayout.sh b/.config/eww/scripts/keyboardlayout.sh
new file mode 100755
index 0000000..aa98833
--- /dev/null
+++ b/.config/eww/scripts/keyboardlayout.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Get long name
+# echo "$(hyprctl devices | grep -A 2 "at-translated-set-2-keyboard" | awk 'NR==3 {print $3" "$4}')"
+
+# Get short name
+echo "$(hyprctl devices | grep -A 2 "at-translated-set-2-keyboard" | awk 'NR==3 {print $4}'| grep -Po '(?<=\().*(?=\))' )"
+
diff --git a/.config/eww/scripts/monitor.sh b/.config/eww/scripts/monitor.sh
new file mode 100755
index 0000000..a211054
--- /dev/null
+++ b/.config/eww/scripts/monitor.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+function handle {
+ if [[ ${1:0:12} == "monitoradded" ]]; then
+ ~/.config/eww/scripts/start.sh
+ elif [[ ${1:0:14} == "monitorremoved" ]]; then
+ ~/.config/eww/scripts/start.sh
+ fi
+}
+
+socat - UNIX-CONNECT:/tmp/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done
diff --git a/.config/eww/scripts/network.sh b/.config/eww/scripts/network.sh
new file mode 100755
index 0000000..29396aa
--- /dev/null
+++ b/.config/eww/scripts/network.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# This script requires dnsutils aka bind to fetch the WAN IP address
+
+# Shows the connections names
+# nmcli connection show --active | grep 'ethernet' | awk '{ print $1 }' FS=' '
+# nmcli connection show --active | grep 'wifi' | awk '{ print $1 }' FS=' '
+
+# Show ethernet interface name
+# nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' '
+
+# Show wifi interface name
+# nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' '
+
+function ShowInfo {
+ if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then
+ wan="$(dig @resolver4.opendns.com myip.opendns.com +short)"
+ connection="$(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' '): $(nmcli connection show --active | grep 'ethernet' | awk '{ printf "%s\nLAN IP:",$1 }' FS=' ') $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' ') | awk '{printf "%s\nWAN IP: '$wan'", $2}' FS='[:/]')"
+ elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then
+ wan="$(dig @resolver4.opendns.com myip.opendns.com +short)"
+ connection="$(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' '): $(nmcli connection show --active | grep 'wifi' | awk '{ printf "%s\nLAN IP:",$1 }' FS=' ') $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' ') | awk '{printf "%s/nWAN IP: '$wan'", $2}' FS='[:/]')"
+ else
+ connection="No active connection."
+ fi
+ fyi -i "network-idle" --hint string:x-canonical-private-synchronous:network-status "$connection"
+}
+
+function IconUpdate() {
+ if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then
+ icon="󰈀"
+ elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then
+ icon=""
+ else
+ icon="󰲜"
+ fi
+ printf "%s" "$icon"
+}
+
+if [ "$1" = "ShowInfo" ]; then
+ ShowInfo
+else
+ IconUpdate
+fi
diff --git a/.config/eww/scripts/scratchpad-indicator.sh b/.config/eww/scripts/scratchpad-indicator.sh
new file mode 100755
index 0000000..8fd06f4
--- /dev/null
+++ b/.config/eww/scripts/scratchpad-indicator.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Scratchpad indicator for Sway
+
+output="$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.name == "__i3_scratch").floating_nodes[]|"`<b>"+.name+"`</b> - "+.app_id+" "+(.id|tostring)')"
+number="$(swaymsg -r -t get_tree | jq -r 'recurse(.nodes[]) | first(select(.name=="__i3_scratch")) | .floating_nodes | length')"
+
+if [ "$number" -gt 0 ]; then
+ text=" $number"
+else
+ text=""
+fi
+
+output="$(echo "$output" | sed -r 's/[&]+/and/g')" # Replace unprintable & character with the word 'and'
+tooltip="\n"
+tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')"
+tooltip=${tooltip::-2}
+
+function ShowInfo() {
+ if [ "$number" -eq 0 ]; then
+ exit
+ else
+ tooltip="$(echo -e $tooltip)"
+ notify-send --hint=string:x-canonical-private-synchronous:scratchpad -u normal " Scratchpad" "$tooltip"
+ fi
+}
+
+function Update() {
+ printf "%s" "$text"
+}
+
+if [ "$1" = "ShowInfo" ]; then
+ ShowInfo
+else
+ Update
+fi
diff --git a/.config/eww/scripts/start.sh b/.config/eww/scripts/start.sh
new file mode 100755
index 0000000..ec305b9
--- /dev/null
+++ b/.config/eww/scripts/start.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+focusactivetag() {
+ export arg="$1"
+ # Focus the lowest active tag
+ num=$(river-bedload -print outputs | jq -r '.['$arg'] | select(.).focused_tags')
+ b=0
+ while [[ $num -gt 0 ]]
+ do
+ let temp=$num%2
+ if [[ $temp -eq 1 ]]
+ then
+ let count=$count+1
+ fi
+ let num=$num/2
+ let b=b+1
+ if [[ $temp -eq 1 ]]
+ then
+ riverctl set-focused-tags $((1 << ($b - 1)))
+ return
+ fi
+done
+return
+}
+
+# kill any running instances if they exist
+eww kill
+
+# Start Eww daemon
+# eww daemon
+
+# start a bar for each monitor
+monitors=$(wlr-randr | grep "^[^ ]" | awk '{ print$1 }' | wc -l | xargs)
+total=$(wlr-randr | grep "^[^ ]" | awk '{ print$1 }' | wc -l | xargs)
+monitors=$(($monitors-1))
+# for ((i = 0 ; i < $monitors ; i++)); do
+for ((i = $monitors ; i >= 0 ; i-=1)); do
+ eww open bar${i}
+ riverctl focus-output $(wlr-randr | grep "^[^ ]" | awk '{ print$1 }' | awk 'FNR == '$i+1' {print}')
+ focusactivetag $i
+done
diff --git a/.config/eww/scripts/void-updates.sh b/.config/eww/scripts/void-updates.sh
new file mode 100755
index 0000000..b004735
--- /dev/null
+++ b/.config/eww/scripts/void-updates.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+function CheckUpdates() {
+xbps-install -Mun 1> /tmp/void-updates
+updates="$(cat /tmp/void-updates | awk '{ print $1 }')"
+number=$(cat /tmp/void-updates | wc -l)
+
+if [ "$number" -gt 0 ]; then
+ text=" $number"
+else
+ text=""
+fi
+
+echo "$text"
+}
+
+function RefreshUpdates() {
+ value="$(CheckUpdates)"
+ eww update void-updates="$value"
+}
+
+function Update() {
+ foot bash -c 'sudo xbps-install -Suv'
+ RefreshUpdates
+}
+
+case "$1" in
+ Refresh)
+ RefreshUpdates
+ exit 0
+ ;;
+ Update)
+ Update
+ exit 0
+ ;;
+ *)
+ CheckUpdates
+ exit 0
+esac
diff --git a/.config/eww/scripts/volumecontrol b/.config/eww/scripts/volumecontrol
new file mode 100755
index 0000000..7f058c9
--- /dev/null
+++ b/.config/eww/scripts/volumecontrol
@@ -0,0 +1,123 @@
+#!/usr/bin/env bash
+
+# You can call this script like this:
+# volumecontrol up
+# volumecontrol down
+# volumecontrol mute
+
+function get_volume {
+ # amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
+ # pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '\d+(?=%)' | head -n 1
+ pactl get-sink-volume @DEFAULT_SINK@ | grep '%' | cut -d '%' -f 1 | cut -d ' ' -f 6
+}
+
+function is_mute {
+ # amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
+ pactl get-sink-mute @DEFAULT_SINK@ | grep 'Mute: yes' >> /dev/null
+}
+
+function 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=""
+ # volume="M "
+ 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)
+ # Set the volume on (if it was muted)
+ # amixer set Master on > /dev/null
+ pactl set-sink-mute @DEFAULT_SINK@ 0
+ # Up the volume (+ 2%)
+ # amixer sset Master 2%+ > /dev/null
+ pactl set-sink-volume @DEFAULT_SINK@ +2%
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ down)
+ # amixer set Master on > /dev/null
+ pactl set-sink-mute @DEFAULT_SINK@ 0
+ # amixer sset Master 2%- > /dev/null
+ pactl set-sink-volume @DEFAULT_SINK@ -2%
+ send_notification
+ # canberra-gtk-play -i audio-volume-change
+ ;;
+ mute)
+ # Toggle mute
+ # amixer set Master 1+ toggle > /dev/null
+ pactl set-sink-mute @DEFAULT_SINK@ toggle
+ if is_mute ; then
+ icon="󰝟"
+ 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="󰝟"
+ volume="M "
+ fi
+
+
+if is_mute; then
+ icon="󰝟"
+ volume="M "
+fi
+
+printf "%s" "$icon $volume%"
+ ;;
+esac
diff --git a/.config/eww/scripts/workspace.sh b/.config/eww/scripts/workspace.sh
new file mode 100755
index 0000000..7e48bfa
--- /dev/null
+++ b/.config/eww/scripts/workspace.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+
+active() {
+num=$(river-bedload -print outputs | jq -r '.['$arg'] | select(.).view_tags')
+b=0
+while [[ $num -gt 0 ]]
+do
+ let temp=$num%2
+ if [[ $temp -eq 1 ]]
+ then
+ let count=$count+1
+ fi
+ let num=$num/2
+ let b=b+1
+ if [[ $temp -eq 1 ]]
+ then
+ echo $b
+ fi
+done
+return
+}
+
+#define icons for workspaces 1-9
+ic=(0 1 2 3 4 5 6 7 8 9)
+
+workspaces() {
+export arg="$1"
+ unset -v \
+ o1 o2 o3 o4 o5 o6 o7 o8 o9 \
+ f1 f2 f3 f4 f5 f6 f7 f8 f9
+
+if [[ $arg = 0 && $(river-bedload -print outputs | jq -r '.[''] | select(.).name' | wc -l | xargs) -gt 1 ]]
+then
+ arg=1
+else
+ arg=0
+fi
+
+ows="$(active)"
+for num in $ows; do
+ export o"$num"="$num"
+done
+
+# Get Focused workspace for current monitor ID
+num=$(river-bedload -print focused | jq -r '.['$arg'] | select(.).focused_id')
+export f"$num"="$num"
+
+echo "(box :class \"workspace\" :orientation \"h\" :space-evenly \"false\" \
+ (button :onclick \"riverctl set-focused-tags $((1 << (1 - 1)))\" :class \"w0$o1$f1\" \"${ic[1]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (2 - 1)))\" :class \"w0$o2$f2\" \"${ic[2]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (3 - 1)))\" :class \"w0$o3$f3\" \"${ic[3]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (4 - 1)))\" :class \"w0$o4$f4\" \"${ic[4]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (5 - 1)))\" :class \"w0$o5$f5\" \"${ic[5]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (6 - 1)))\" :class \"w0$o6$f6\" \"${ic[6]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (7 - 1)))\" :class \"w0$o7$f7\" \"${ic[7]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (8 - 1)))\" :class \"w0$o8$f8\" \"${ic[8]}\") \
+ (button :onclick \"riverctl set-focused-tags $((1 << (9 - 1)))\" :class \"w0$o9$f9\" \"${ic[9]}\") \
+ )"
+}
+
+workspaces $1
+river-bedload -watch active | while read -r; do
+workspaces $1
+done