feat(hypr): add some event notifications

This commit is contained in:
Price Hiller 2022-10-07 18:05:45 -05:00
parent 6f9c089268
commit 68c7c3d761
2 changed files with 36 additions and 0 deletions

View File

@ -5,3 +5,5 @@ source=~/.config/hypr/wm/monitors.conf
exec=~/.config/hypr/scripts/launch-waybar.bash
exec-once=sudo modprobe uinput && sudo kbct remap --config ~/.config/kbct/config.yml
exec=mako
exec-once=~/.config/hypr/scripts/events-monitor.bash
exec-once=udiskie

View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
monitor-dir() {
local event="${1}"
local directory="${2}"
local message_title="${3}"
inotifywait -m -e "${event}" --format '%w%f' "${directory}" | while read -r NEWFILE; do
notify-send "${message_title}" "${NEWFILE}" -a "Device Monitor"
done
}
monitor-ssid() {
local notify_title="Wifi State Changed"
local notify_app="Wifi State"
local previous_ssid=""
local ssid
while :; do
ssid="$(iwctl station wlan0 show | grep 'Connected network' | awk '{$1=$2=""; print $0}')"
ssid="$(printf "%s" "${ssid}" | xargs)"
if [[ "${ssid}" != "${previous_ssid}" ]]; then
if [[ -z "${ssid// /}" ]]; then
notify-send "${notify_title}" "Wifi Disconnected" -a "${notify_app}"
else
notify-send "${notify_title}" "Wifi Connected to ${ssid}" -a "${notify_app}"
fi
previous_ssid="${ssid}"
fi
sleep 1
done
}
monitor-ssid &
wait