Cleanup stuff

This commit is contained in:
2023-11-14 20:54:20 -08:00
parent a502b72299
commit 5d80c98c1f
12 changed files with 24 additions and 10 deletions

42
old/x11/battery-notify.sh Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env zsh
local system_uname="$(uname)"
if [[ "${system_uname}" = 'Linux' ]]; then
let charge_full="$(cat '/sys/class/power_supply/BAT0/charge_full')."
function get_battery_percent {
let charge_now="$(cat '/sys/class/power_supply/BAT0/charge_now')."
printf '%.0f' "$((charge_now / charge_full * 100))"
}
function is_adapted_connected {
let connected="$(cat /sys/class/power_supply/ADP1/online)"
((${connected} == 1))
}
# Linux ends here
else
echo "${0}: error: unknown os: \"${system_uname}\"" >&2
exit 1
fi
function send_battery_warning {
dunstify -p -t 0 "Low Battery" "Battery is at ${1}%!"
}
local did_notify=false
let notify_id=-1
while true; do
let battery_percent="$(get_battery_percent)"
if ((${battery_percent} > 10)) || is_adapted_connected; then
did_notify=false
if ((${notify_id} > 0)); then
dunstify -C ${notify_id}
notify_id=-1
fi
elif ! ${did_notify}; then
did_notify=true
notify_id="$(send_battery_warning ${battery_percent})"
fi
sleep 10
done

8
old/x11/copy-screen-text.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env zsh
local text="$(maim -k -s -f png | tesseract stdin stdout -l eng 2>/dev/null)"
let char_count="$(printf '%s' "${text}" | wc -c)"
printf '%s' "${text}" | xclip -selection clipboard
notify-send -t 5000 "Coppied Text" "Coppied ${char_count} characters"

19
old/x11/lock-screen.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env zsh
local i3lock_args=()
let image_index=1
for arg; do
case "${arg}"; in
--no-empty-pass|-e)
i3lock_args+=(-e)
image_index+=1
;;
esac
done
dunstctl set-paused true
xset dpms 0 0 15
i3lock ${i3lock_args} -n -i "${@[${image_index}]}"
xset -dpms
dunstctl set-paused false

8
old/x11/reset-saver-daemon.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/zsh
while true; do
if pactl list sink-inputs | grep -i -B13 'firefox' | grep 'Corked: no' >/dev/null || pactl list sink-inputs | grep -i -B13 'chromium' | grep 'Corked: no' >/dev/null; then
echo reset
xset s reset
fi
sleep 1m
done

16
old/x11/screenshot.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env zsh
local maim_args=("-f" "png")
local outfile="screenshot--$(date +'%F_%k-%M-%S').png"
local outpath="${HOME}/downloads/${outfile}"
case "${1}" in;
'-root')
maim ${maim_args} "${outpath}" || exit
;;
'-select' | *)
maim ${maim_args} -s "${outpath}" || exit
;;
esac
notify-send -t 5000 "Screenshot Taken" "Screenshot saved to \"${outfile}\""

View File

@ -0,0 +1,5 @@
#!/usr/bin/env zsh
local color="$(xcolor)"
printf '%s' "${color}" | xclip -selection clipboard
notify-send -t 5000 "Color Coppied" "${color}"

5
old/x11/toggle-stalonetray.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env sh
pgrep stalonetray \
&& pkill stalonetray \
|| stalonetray -bg '#000000' -i 64 --geometry '7x1+3840-10' &