From d15fe0104cb7edd384bdd78bcc5155654f2400b9 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 21 May 2025 15:32:27 +0200 Subject: [PATCH] chore: update configs --- .config/sway/config | 2 +- ...en-recorder.sh => open-screen-recorder.sh} | 5 ++- .config/waybar/config.jsonc | 9 ++-- .config/waybar/scripts/check-battery.sh | 22 ++++++++++ .../{check_updates.sh => check-updates.sh} | 2 +- .config/waybar/scripts/check_battery.sh | 41 ------------------- .../waybar/scripts/close-screen-recorder.sh | 12 ++++++ 7 files changed, 44 insertions(+), 49 deletions(-) rename .config/sway/scripts/{toggle-screen-recorder.sh => open-screen-recorder.sh} (67%) mode change 100644 => 100755 create mode 100755 .config/waybar/scripts/check-battery.sh rename .config/waybar/scripts/{check_updates.sh => check-updates.sh} (87%) delete mode 100755 .config/waybar/scripts/check_battery.sh create mode 100755 .config/waybar/scripts/close-screen-recorder.sh diff --git a/.config/sway/config b/.config/sway/config index 60b4d1d..20b3746 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -8,7 +8,7 @@ set $right l # wf-recorder -set $screenrecorder `bash $HOME/.config/sway/scripts/toggle-screen-recorder.sh` +set $screenrecorder `bash $HOME/.config/sway/scripts/open-screen-recorder.sh` bindsym --to-code $mod+Shift+R exec $screenrecorder # background diff --git a/.config/sway/scripts/toggle-screen-recorder.sh b/.config/sway/scripts/open-screen-recorder.sh old mode 100644 new mode 100755 similarity index 67% rename from .config/sway/scripts/toggle-screen-recorder.sh rename to .config/sway/scripts/open-screen-recorder.sh index cc624cc..6e37f7d --- a/.config/sway/scripts/toggle-screen-recorder.sh +++ b/.config/sway/scripts/open-screen-recorder.sh @@ -1,9 +1,10 @@ #!/bin/bash main() { - local pid="$(pgrep "wf-recorder" || pgrep "slurp")" + pid="$(pgrep "wf-recorder" || pgrep "slurp")" + status=$? - if [[ $? != 0 ]]; then + if [[ $status != 0 ]]; then GEO="$(slurp)" && wf-recorder -g "$GEO" -f "$HOME/Pictures/$(date +'recording_%Y-%m-%d-%H%M%S.mp4')" else pkill --signal SIGINT wf-recorder diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc index 98f33c2..d07e4e3 100644 --- a/.config/waybar/config.jsonc +++ b/.config/waybar/config.jsonc @@ -102,8 +102,8 @@ "tooltip": true, "format": "{} ", "interval": 60, - "exec": "$HOME/.config/waybar/scripts/check_updates.sh", - "exec-if": "[[ `$HOME/.config/waybar/scripts/check_updates.sh` != 0 ]]", + "exec": "$HOME/.config/waybar/scripts/check-updates.sh", + "exec-if": "[[ `$HOME/.config/waybar/scripts/check-updates.sh` != 0 ]]", "signal": 1 }, @@ -113,7 +113,8 @@ "return-type": "json", "interval": 1, "exec": "echo '{\"class\": \"recording\"}'", - "exec-if": "pgrep wf-recorder" + "exec-if": "pgrep wf-recorder", + "on-click": "$HOME/.config/waybar/scripts/close-screen-recorder.sh" }, "custom/power": { @@ -188,7 +189,7 @@ "format-plugged": "{capacity}% ", "format-icons": ["󰁻", "󰁼", "󰁾", "󰂀", "󰂂", "󰁹"], "tooltip-format": "{timeTo}\nCapacity: {capacity}%\nPower: {power:0.2f}w\nCycles: {cycles}\nHealth: {health}%", - "on-update": "$HOME/.config/waybar/scripts/check_battery.sh" + "on-update": "$HOME/.config/waybar/scripts/check-battery.sh" }, "disk": { diff --git a/.config/waybar/scripts/check-battery.sh b/.config/waybar/scripts/check-battery.sh new file mode 100755 index 0000000..59fca42 --- /dev/null +++ b/.config/waybar/scripts/check-battery.sh @@ -0,0 +1,22 @@ +#! /usr/bin/env bash + +bat="/sys/class/power_supply/BAT1" +crit="${1:-15}" +stat="$(cat $bat/status)" +perc="$(cat $bat/capacity)" + +notifysend() { + local pid + local title="Low Battery" + local body="Current charge: $perc%" + + notify-send --print-id --urgency=critical --icon=dialog-warning "$title" "$body" +} + +main() { + if [[ "$stat" == "Discharging" ]] && [[ "$perc" -le "$crit" ]] && [[ ! -f "$file" ]]; then + notifysend + fi +} + +main $@ \ No newline at end of file diff --git a/.config/waybar/scripts/check_updates.sh b/.config/waybar/scripts/check-updates.sh similarity index 87% rename from .config/waybar/scripts/check_updates.sh rename to .config/waybar/scripts/check-updates.sh index 912df7a..c514bef 100755 --- a/.config/waybar/scripts/check_updates.sh +++ b/.config/waybar/scripts/check-updates.sh @@ -4,4 +4,4 @@ main() { checkupdates | wc -l } -main $@ +main $@ \ No newline at end of file diff --git a/.config/waybar/scripts/check_battery.sh b/.config/waybar/scripts/check_battery.sh deleted file mode 100755 index f3bb343..0000000 --- a/.config/waybar/scripts/check_battery.sh +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env bash - -file=~/.config/waybar/scripts/lowbat -bat="/sys/class/power_supply/BAT1" -crit="${1:-15}" -stat="$(cat $bat/status)" -perc="$(cat $bat/capacity)" - -notifysend() { - local pid - local title="Low Battery" - local body="Current charge: $perc%" - if [[ ! -f "$file" ]]; then - pid="$(notify-send --print-id --urgency=critical --icon=dialog-warning "$title" "$body")" - else - pid="$(notify-send --print-id --replace-id="$(cat $file)" --urgency=critical --icon=dialog-warning "$title" "$body")" - fi - - echo $pid > $file -} - -main() { - if [[ "$stat" == "Discharging" ]] && [[ "$perc" -le "$crit" ]] && [[ ! -f "$file" ]]; then - notifysend - fi - - if [[ -f "$file" ]]; then - case "$stat" in - "Charging" ) - rm $file - ;; - "Discharging" ) - notifysend - ;; - * );; - esac - - fi -} - -main $@ \ No newline at end of file diff --git a/.config/waybar/scripts/close-screen-recorder.sh b/.config/waybar/scripts/close-screen-recorder.sh new file mode 100755 index 0000000..1bb613c --- /dev/null +++ b/.config/waybar/scripts/close-screen-recorder.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +main() { + pid="$(pgrep "wf-recorder" || pgrep "slurp")" + status=$? + + if [[ $status == 0 ]]; then + pkill --signal SIGINT wf-recorder + fi +} + +main $@ \ No newline at end of file