From 68c7c3d76153a88b4b05c9f2bbaf6c5cf7b040ee Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Fri, 7 Oct 2022 18:05:45 -0500 Subject: [PATCH] feat(hypr): add some event notifications --- dots/.config/hypr/hyprland.conf | 2 ++ dots/.config/hypr/scripts/events-monitor.bash | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 dots/.config/hypr/scripts/events-monitor.bash diff --git a/dots/.config/hypr/hyprland.conf b/dots/.config/hypr/hyprland.conf index 06f7902a..73b6c624 100644 --- a/dots/.config/hypr/hyprland.conf +++ b/dots/.config/hypr/hyprland.conf @@ -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 diff --git a/dots/.config/hypr/scripts/events-monitor.bash b/dots/.config/hypr/scripts/events-monitor.bash new file mode 100755 index 00000000..664bf05c --- /dev/null +++ b/dots/.config/hypr/scripts/events-monitor.bash @@ -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