aboutsummaryrefslogtreecommitdiff
path: root/.config/yambar/scripts
diff options
context:
space:
mode:
Diffstat (limited to '.config/yambar/scripts')
-rwxr-xr-x.config/yambar/scripts/brightnesscontrol44
-rwxr-xr-x.config/yambar/scripts/calendar.sh26
-rwxr-xr-x.config/yambar/scripts/date-time.sh12
-rwxr-xr-x.config/yambar/scripts/dater.sh26
-rwxr-xr-x.config/yambar/scripts/idleinhibit.sh36
-rwxr-xr-x.config/yambar/scripts/network.sh48
-rwxr-xr-x.config/yambar/scripts/scratchpad-indicator.sh18
-rwxr-xr-x.config/yambar/scripts/void-updates.sh38
-rwxr-xr-x.config/yambar/scripts/volumecontrol107
-rwxr-xr-x.config/yambar/scripts/yambar-start.sh18
10 files changed, 373 insertions, 0 deletions
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