From 4068fdf409058190178985ac259ef6fdb1596e4c Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 17 May 2023 09:53:26 -0500 Subject: [PATCH] Cleanup good morning script --- common/bin/field | 1 - common/bin/good-morning | 21 +++++++++++++++++++++ common/bin/maybe-good-morning | 21 +++++++++++++++++++++ os/linux/hypr/hyprland.conf | 5 ++++- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 common/bin/good-morning create mode 100755 common/bin/maybe-good-morning diff --git a/common/bin/field b/common/bin/field index 45bbb7a..d2bf241 100755 --- a/common/bin/field +++ b/common/bin/field @@ -2,6 +2,5 @@ has_command gawk || { echo "No gawk." >&2 ; exit 1; } index="${1:-1}" -echo "$#" >&2 [ "$#" -lt 1 ] || shift gawk "$@" '{print $'"${index}"'}' diff --git a/common/bin/good-morning b/common/bin/good-morning new file mode 100755 index 0000000..f3b1704 --- /dev/null +++ b/common/bin/good-morning @@ -0,0 +1,21 @@ +#!/usr/bin/env fish + +# create a messages file for subscripts to write to or manipulate for ending +# output +set message_file (mktemp) + +for f in (fd good-morning.d.fish $HOME/.config/lytedev-env --max-depth 2) + # run scripts for any linked environments with a hooked script + source $f $message_file +end + + +# output the messages file's contents +echo +cat $message_file +echo + +# since this script almost always runs in its own window which dies after +# finishing, give the user a chance to read the output +echo "When you're ready, hit enter to finish!" +read diff --git a/common/bin/maybe-good-morning b/common/bin/maybe-good-morning new file mode 100755 index 0000000..6909def --- /dev/null +++ b/common/bin/maybe-good-morning @@ -0,0 +1,21 @@ +#!/usr/bin/env fish + +# TODO: some kind of better time-based or last-awakened heuristic to determine +# whether or not this shows + +set -l hours 08 09 10 +if ! contains (date +%H) $hours + echo "Not sending notification since it isn't the morning" >>&2 + exit 1 +end + +notify-send \ + --urgency critical \ + "Good morning!" \ + "Activate this notification (click it) to run the script. Dismiss (Super+Ctrl+Space) to ignore." \ + --action=default=Activate \ + | rg default + +if test $status -eq 0 + hyprctl dispatch exec [float] wezterm start good-morning +end diff --git a/os/linux/hypr/hyprland.conf b/os/linux/hypr/hyprland.conf index 6f3be3e..3c326f4 100644 --- a/os/linux/hypr/hyprland.conf +++ b/os/linux/hypr/hyprland.conf @@ -5,7 +5,7 @@ monitor=,preferred,auto,auto # Execute your favorite apps at launch exec-once = firefox & wezterm & hyprpaper & mako & /usr/lib/polkit-kde-authentication-agent-1 & eww daemon & eww open-many bar -exec-once = swayidle -w timeout 600 'notify-send "Locking in 30 seconds..."' timeout 630 'swaylock -f' timeout 660 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' before-sleep 'swaylock -f' +exec-once = swayidle -w timeout 600 'notify-send "Locking in 30 seconds..."' timeout 630 'swaylock -f' timeout 660 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' resume 'maybe-good-morning' before-sleep 'swaylock -f' exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP env = XCURSOR_SIZE,24 @@ -208,3 +208,6 @@ bind = CTRL SHIFT $mainMod, L, exec, swaylock bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow +bind = $mainMod CTRL, space, exec, makoctl dismiss +bind = $mainMod SHIFT CTRL, space, exec, makoctl restore +bind = $mainMod SHIFT, space, exec, makoctl invoke