diff options
author | Justine Smithies <justine@smithies.me.uk> | 2023-10-11 18:21:52 +0100 |
---|---|---|
committer | Justine Smithies <justine@smithies.me.uk> | 2023-10-11 18:21:52 +0100 |
commit | 786f9c22fab19de866566de4c7933aef416a1462 (patch) | |
tree | 512c3563b43a511171979604d6a2a09a4b68c50a /.config/yambar | |
parent | ba6e0a870faa3306b1e15bd03460b2faa30ceb37 (diff) |
Switched to River
Diffstat (limited to '.config/yambar')
-rw-r--r-- | .config/yambar/config.yml | 271 | ||||
-rwxr-xr-x | .config/yambar/scripts/brightnesscontrol | 44 | ||||
-rwxr-xr-x | .config/yambar/scripts/calendar.sh | 26 | ||||
-rwxr-xr-x | .config/yambar/scripts/date-time.sh | 12 | ||||
-rwxr-xr-x | .config/yambar/scripts/dater.sh | 26 | ||||
-rwxr-xr-x | .config/yambar/scripts/idleinhibit.sh | 36 | ||||
-rwxr-xr-x | .config/yambar/scripts/network.sh | 48 | ||||
-rwxr-xr-x | .config/yambar/scripts/scratchpad-indicator.sh | 18 | ||||
-rwxr-xr-x | .config/yambar/scripts/void-updates.sh | 38 | ||||
-rwxr-xr-x | .config/yambar/scripts/volumecontrol | 107 | ||||
-rwxr-xr-x | .config/yambar/scripts/yambar-start.sh | 18 |
11 files changed, 644 insertions, 0 deletions
diff --git a/.config/yambar/config.yml b/.config/yambar/config.yml new file mode 100644 index 0000000..2c402fb --- /dev/null +++ b/.config/yambar/config.yml @@ -0,0 +1,271 @@ +nerdfont: &nerdfont Symbols Nerd Font Mono:pixelsize=12 +gomono: &gomono GoMono Nerd Font Mono:pixelsize=12 +bg_default: &bg_default {stack: [{background: {color: 00000000}}, {underline: {size: 3, color: 98971aff}}]} + +std_underline: &std_underline {underline: { size: 5, color: 98c379ff}} + +bar: + font: *gomono + height: 20 + location: top + right-spacing: 8 + right-margin: 10 + border: + top-margin: 5 + left-margin: 10 + right-margin: 10 + color: d8dee900 + background: 000000aa + foreground: ffffffff + + left: + # - i3: + # # persistent: [1, 2, 3, 4, 5, 6, 7, 8, 9] + # sort: ascending + # anchors: + # - string: &i3_common {margin: 5, on-click: "~/.config/waybar/scripts/dispatch.sh {name}"} + # - string: &default {<<: *i3_common, text: "{name}", margin: 10} + # - focused: &focused + # deco: {stack: [ *bg_default]} + # - invisible: &invisible {foreground: 888888ff} + # - urgent: &urgent + # deco: {stack: [background: {color: eb6e67ff}, <<: *std_underline]} + # - map: &i3_mode + # default: + # - string: + # margin: 5 + # text: "{mode}" + # deco: {background: {color: cc421dff}} + # - empty: {right-margin: 0} + # conditions: + # mode == default: {empty: {}} + # content: + # "": + # map: + # conditions: + # state == focused: {string: {<<: [*default, *focused]}} + # state == unfocused: {string: {<<: *default}} + # state == invisible: {string: {<<: [*default, *invisible]}} + # state == urgent: {string: {<<: [*default, *urgent]}} + # + # current: + # map: + # left-margin: 7 + # conditions: + # application == "": + # - map: {<<: *i3_mode} + # - string: {text: "{title}"} + # default: + # list: + # spacing: 0 + # items: + # - map: {<<: *i3_mode} + - river: + anchors: + - base: &river_base + left-margin: 10 + right-margin: 10 + default: {string: {text: , font: *gomono}} + conditions: + id == 1: {string: {text: 1, font: *gomono}} + id == 2: {string: {text: 2, font: *gomono}} + id == 3: {string: {text: 3, font: *gomono}} + id == 4: {string: {text: 4, font: *gomono}} + id == 5: {string: {text: 5, font: *gomono}} + id == 6: {string: {text: 6, font: *gomono}} + id == 7: {string: {text: 7, font: *gomono}} + id == 8: {string: {text: 8, font: *gomono}} + id == 9: {string: {text: 9, font: *gomono}} + # id == 21: {string: {text: "Scratchpad", font: *gomono}} + + content: + map: + on-click: + left: sh -c "riverctl set-focused-tags $((1 << ({id} - 1)))" + right: sh -c "riverctl toggle-focused-tags $((1 << ({id} -1)))" + middle: sh -c "riverctl toggle-view-tags $((1 << ({id} -1)))" + conditions: + state == urgent: + map: + <<: *river_base + deco: {background: {color: D08770ff}} + state == focused: + map: + <<: *river_base + deco: *bg_default + state == visible && ~occupied: + map: + <<: *river_base + state == visible && occupied: + map: + <<: *river_base + deco: *bg_default + state == unfocused: + map: + <<: *river_base + state == invisible && ~occupied: {empty: {}} + state == invisible && occupied: + map: + <<: *river_base + deco: {underline: {size: 3, color: 00000000}} + + center: + - script: + path: ~/.config/yambar/scripts/dater.sh + args: [] + content: + string: + margin: 0 + text: "{date}" + on-click: sh -c "~/.config/yambar/scripts/calendar.sh show" + - clock: + content: + - string: + margin: 0 + text: "{time}" + + right: + - script: + path: ~/.config/yambar/scripts/void-updates.sh + args: [] + content: + string: + margin: 0 + text: "{updates}" + font: *nerdfont + foreground: 98971aff + on-click: sh -c "~/.config/yambar/scripts/void-updates.sh update" + - script: + path: ~/.config/yambar/scripts/idleinhibit.sh + args: [] + content: + string: + margin: 0 + text: "{idleinhibit}" + font: *nerdfont + on-click: sh -c "~/.config/yambar/scripts/idleinhibit.sh toggle" + - sway-xkb: + identifiers: + - 1:1:AT_Translated_Set_2_keyboard + spacing: 5 + content: {string: {text: "{layout}"}} + - pipewire: + anchors: + volume: &volume + conditions: + muted: + string: + text: "0%" + on-click: + middle: sh -c "amixer set Master 1+ toggle" + ~muted: + string: + text: "{cubic_volume}%" + on-click: + left: sh -c "amixer sset Master 2%-" + middle: sh -c "amixer set Master 1+ toggle" + right: sh -c "amixer sset Master 2%+" + content: + list: + items: + - map: + conditions: + type == "sink": + map: + conditions: + icon == "audio-headset-bluetooth": + string: {text: "", font: *nerdfont} + muted: {string: {text: "", font: *nerdfont}} + default: + - ramp: + tag: cubic_volume + items: + - string: {text: "", font: *nerdfont} + - string: {text: "", font: *nerdfont} + - string: {text: "", font: *nerdfont} + type == "source": + - string: {text: "", font: *nerdfont, left-margin: 5} + - map: + <<: *volume + - backlight: + name: amdgpu_bl0 + content: [ string: {text: , font: *nerdfont}, string: {text: "{percent}%", on-click: { left: sh -c "light -U 5", right: sh -c "light -A 5"}}] + - network: + name: enp5s0 + content: + map: + conditions: + state == down: {string: {text: , font: *nerdfont, foreground: ffffffff}} + ~carrier: {empty: {}} + carrier: + map: + default: {string: {text: , font: *nerdfont, foreground: ffffffff}} + conditions: + state == up && ipv4 != "": {string: {text: , font: *nerdfont}} + - network: + name: wlp3s0 + poll-interval: 1000 + content: + map: + default: {string: {text: , font: *nerdfont, foreground: ffffff66}} + conditions: + state == down: {string: {text: , font: *nerdfont, foreground: ffffffff}} + state == up: + map: + default: + - string: {text: , font: *nerdfont} + - string: {text: "{ssid} {dl-speed:mb}/{ul-speed:mb} Mb/s"} + + conditions: + ipv4 == "": + - string: {text: , font: *nerdfont, foreground: ffffff66} + - string: {text: "{ssid} {dl-speed:mb}/{ul-speed:mb} Mb/s", foreground: ffffff66} + - battery: + name: BAT0 + poll-interval: 10000 + anchors: + discharging: &discharging + list: + items: + - ramp: + tag: capacity + items: + - string: {text: , foreground: ff0000ff, font: *nerdfont} + - string: {text: , foreground: ffa600ff, font: *nerdfont} + - string: {text: , font: *nerdfont} + - string: {text: , font: *nerdfont} + - string: {text: , font: *nerdfont} + - string: {text: , font: *nerdfont} + - string: {text: , font: *nerdfont} + - string: {text: , font: *nerdfont} + - string: {text: , font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: "{capacity}% {estimate}"} + content: + map: + conditions: + state == unknown: + <<: *discharging + state == discharging: + <<: *discharging + state == charging: + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: "{capacity}% {estimate}"} + state == full: + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: "{capacity}% full"} + state == "not charging": + - ramp: + tag: capacity + items: + - string: {text: , foreground: ff0000ff, font: *nerdfont} + - string: {text: , foreground: ffa600ff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: , foreground: ffffffff, font: *nerdfont} + - string: {text: "{capacity}%"} diff --git a/.config/yambar/scripts/brightnesscontrol b/.config/yambar/scripts/brightnesscontrol new file mode 100755 index 0000000..718cb05 --- /dev/null +++ b/.config/yambar/scripts/brightnesscontrol @@ -0,0 +1,44 @@ +#!/bin/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/Papirus-Dark/16x16/actions/brightnesssettings.svg + brightness=$(light -G) + brightness=$(echo "$brightness" | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}') + # 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') + #brightness=$((brightness *100 / 255 )) + #echo $bar + #echo $test + # Send the notification + notify-send -i "$icon" -r 5555 -u normal "$bar $brightness" +} + +case $1 in + up) + # increase the backlight by 5% + light -A 5 + send_notification + #canberra-gtk-play -i audio-volume-change + ;; + down) + # decrease the backlight by 5% + light -U 5 + send_notification + #canberra-gtk-play -i audio-volume-change + ;; + *) + brightness=$(light -G) + brightness=$(echo "$brightness" | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}') + icon="" + printf "%s" "$icon $brightness" "%" + ;; +esac diff --git a/.config/yambar/scripts/calendar.sh b/.config/yambar/scripts/calendar.sh new file mode 100755 index 0000000..d066cf8 --- /dev/null +++ b/.config/yambar/scripts/calendar.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Calendar script + +function ShowCalendar() { + dunstify -i "calendar" " Calendar" "$(cal --color=always | sed "s/..7m/<b><span color=\"#fabd2f\">/;s/..27m/<\/span><\/b>/")" -r 124 +} + +function EditCalendar() { + echo +} + +case "$1" in + show) + ShowCalendar + ;; + + edit) + EditCalendar + ;; + + *) + echo $"Usage: ${0##*/} {show|edit}" + exit 1 + +esac diff --git a/.config/yambar/scripts/date-time.sh b/.config/yambar/scripts/date-time.sh new file mode 100755 index 0000000..6968cec --- /dev/null +++ b/.config/yambar/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 - %H:%M") +icon="" +printf "%s" "$date" diff --git a/.config/yambar/scripts/dater.sh b/.config/yambar/scripts/dater.sh new file mode 100755 index 0000000..00d4b7e --- /dev/null +++ b/.config/yambar/scripts/dater.sh @@ -0,0 +1,26 @@ +#!/bin/sh + + +while true; do +number=$(date +'%d') + +case $number in + 1*)extension=th;; + *1)extension=st;; + *2)extension=nd;; + *3)extension=rd;; + *)extension=th;; +esac + +date=$(date +"%A $(printf ${number##0}$extension) %B %Y -") + +echo "date|string|$date" +echo "" + +hour=$(date +'%H') +minute=$(date +'%M') + +second=$(expr $hour \* 3600 + $minute \* 60) + +sleep "$second" +done diff --git a/.config/yambar/scripts/idleinhibit.sh b/.config/yambar/scripts/idleinhibit.sh new file mode 100755 index 0000000..90dfcb2 --- /dev/null +++ b/.config/yambar/scripts/idleinhibit.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# River swayidle toggle +function toggle { +if pgrep "swayidle" > /dev/null +then + pkill swayidle + notify-send -r 5556 -u normal " Swayidle Inactive" +else + swayidle -w \ + timeout 300 'swaylock -f -i ~/.cache/wallpaper' \ + timeout 600 'wlopm --off \*;swaylock -F -i ~/.cache/wallpaper' resume 'wlopm --on \*' \ + before-sleep 'swaylock -f -i $wallpaper' & + notify-send -r 5556 -u normal " Swayidle Active" +fi +} + +case $1 in + toggle) + toggle + ;; + *) + while true; do + if pgrep "swayidle" > /dev/null + then + icon="" + else + icon="" + fi + echo "idleinhibit|string|$icon" + echo "" + sleep 1 + done + ;; +esac +exit 0 diff --git a/.config/yambar/scripts/network.sh b/.config/yambar/scripts/network.sh new file mode 100755 index 0000000..73338f9 --- /dev/null +++ b/.config/yambar/scripts/network.sh @@ -0,0 +1,48 @@ +#!/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 +short myip.opendns.com @resolver1.opendns.com)" + connection="$(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' '): $(nmcli connection show --active | grep 'ethernet' | awk '{ print $1 }' FS=' ') - $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' ') | awk '{print $2}' FS='[:/]') +WAN IP: $wan" + elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then + wan="$(dig +short myip.opendns.com @resolver1.opendns.com)" + connection="$(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' '): $(nmcli connection show --active | grep 'wifi' | awk '{ print $1 }' FS=' ') - $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' ') | awk '{print $2}' FS='[:/]') +WAN IP: $wan" + else + connection="No active connection." + fi +} + +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 +} + +ShowInfo +IconUpdate + +text="$icon" + +tooltip="$(echo "$connection" | sed -z 's/\n/\\n/g')" +tooltip=${tooltip::-2} + +echo "{\"text\":\""$text"\", \"tooltip\":\""$tooltip"\"}" +exit 0 diff --git a/.config/yambar/scripts/scratchpad-indicator.sh b/.config/yambar/scripts/scratchpad-indicator.sh new file mode 100755 index 0000000..05ba3b1 --- /dev/null +++ b/.config/yambar/scripts/scratchpad-indicator.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +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=" Scratchpad\n\n" +tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')" +tooltip=${tooltip::-2} + +echo "{\"text\":\"$text\", \"tooltip\":\"$tooltip\"}" +exit 0 diff --git a/.config/yambar/scripts/void-updates.sh b/.config/yambar/scripts/void-updates.sh new file mode 100755 index 0000000..98b3e0b --- /dev/null +++ b/.config/yambar/scripts/void-updates.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +function update-yambar { +echo "updates|string|" +echo "" + +while true; do + +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 "updates|string|$text" +echo "" +sleep 30m + +done +} + +function update { + foot bash -c "sudo xbps-install -Suv"; sh -c "~/.config/yambar/scripts/yambar-start.sh" +} + +case $1 in + update) + update + ;; + *) + update-yambar + ;; +esac +exit 0 diff --git a/.config/yambar/scripts/volumecontrol b/.config/yambar/scripts/volumecontrol new file mode 100755 index 0000000..65b0082 --- /dev/null +++ b/.config/yambar/scripts/volumecontrol @@ -0,0 +1,107 @@ +#!/bin/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 +} + +function is_mute { + amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /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" = "0" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-muted.png" +notify-send -i "$icon_name" -r 5556 -u normal "$volume" + else + if [ "$volume" -lt "10" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-low.png" +notify-send -i "$icon_name" -r 5556 -u normal "$volume" + else + if [ "$volume" -lt "30" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-low.png" + else + if [ "$volume" -lt "70" ]; then + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-medium.png" + else + icon_name="/usr/share/icons/Adwaita/16x16/legacy/audio-volume-high.png" + fi + fi + fi +fi +bar=$(seq -s "─" $(($volume/5)) | sed 's/[0-9]//g') +# Send the notification +notify-send -i "$icon_name" -r 5556 -u normal "$bar $volume" +} + +case $1 in + up) + # Set the volume on (if it was muted) + amixer set Master on > /dev/null + # Up the volume (+ 2%) + amixer sset Master 2%+ > /dev/null + send_notification + canberra-gtk-play -i audio-volume-change + ;; + down) + amixer set Master on > /dev/null + amixer sset Master 2%- > /dev/null + send_notification + canberra-gtk-play -i audio-volume-change + ;; + mute) + # Toggle mute + amixer set Master 1+ toggle > /dev/null + if is_mute ; then + notify-send -i "/usr/share/icons/Adwaita/16x16/legacy/audio-volume-muted.png" -r 5556 -u normal "$bar 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/yambar/scripts/yambar-start.sh b/.config/yambar/scripts/yambar-start.sh new file mode 100755 index 0000000..064d984 --- /dev/null +++ b/.config/yambar/scripts/yambar-start.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +killall yambar + +monitors=$(wlr-randr | grep "^[^ ]" | awk '{ print$1 }') +total=$(wlr-randr | grep "^[^ ]" | awk '{ print$1 }' | wc -l) + +for monitor in ${monitors}; do + riverctl focus-output ${monitor} + # swaymsg focus output ${monitor} + yambar & + sleep 0.2 +done +if [ "$total" -gt "1" ]; then + riverctl focus-output HDMI-A-1 + # swaymsg focus output HDMI-A-1 +fi +exit 0 |