From 5306e9f1bd67412cab9e8b7e5ced33983d9d0688 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Wed, 23 Sep 2026 03:41:42 +0500 Subject: [PATCH] lock script and prayertimes managed by nix --- config/sway/config | 2 +- home/lock.nix | 20 ++++++++++++++++++++ home/packages.nix | 1 + home/prayertimes.nix | 5 ----- home/shihaam.nix | 1 + scripts/lock.sh | 12 ++++++++++++ 6 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 home/lock.nix create mode 100755 scripts/lock.sh diff --git a/config/sway/config b/config/sway/config index ade0963..31acc6d 100644 --- a/config/sway/config +++ b/config/sway/config @@ -155,7 +155,7 @@ exec hash dbus-update-activation-environment 2>/dev/null && \ dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK exec xfce4-power-manager #exec /usr/bin/uxplay -avdec -bindsym $mod+l exec /home/shihaam/scripts/lock.sh +bindsym $mod+l exec /home/shihaam/scripts/lock.sh # see home/lock.nix # Notification centre: $mod+n opens the panel (past notifications, mpris, # DND toggle), $mod+Shift+n flips do-not-disturb. -sw closes it again on the diff --git a/home/lock.nix b/home/lock.nix new file mode 100644 index 0000000..7bfe24a --- /dev/null +++ b/home/lock.nix @@ -0,0 +1,20 @@ +# The screen lock bound to $mod+l in config/sway/config. +# +# It blanks the laptop panel, the keyboard backlight and the external monitor +# (over DDC/CI) before swaylock, then restores whatever they were at. swaylock +# itself comes from the sway module's default extraPackages, ddcutil from the +# host's systemPackages, and brightnessctl from home/packages.nix. +# +# Linked as a plain executable rather than wrapped with writeShellApplication, +# so it stays a file that can be edited and run on its own -- same reasoning as +# home/prayertimes.nix. +# +# Iteration loop: edit scripts/lock.sh -> git add if new -> nixos-rebuild switch. +{ ... }: + +{ + home.file."scripts/lock.sh" = { + source = ../scripts/lock.sh; + executable = true; + }; +} diff --git a/home/packages.nix b/home/packages.nix index 326c1ee..6c23c39 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -6,6 +6,7 @@ ripdrag playerctl # waybar mediaplayer module + swaync's mpris widget libnotify # notify-send, used by config/waybar/scripts/monitor-brightness.sh + brightnessctl # waybar backlight scroll + scripts/lock.sh fastfetch p7zip unrar # unfree diff --git a/home/prayertimes.nix b/home/prayertimes.nix index 35e1fe5..7d1c417 100644 --- a/home/prayertimes.nix +++ b/home/prayertimes.nix @@ -3,11 +3,6 @@ # # Times come from github.com/WovenCoast/prayertimes-db and the lookup follows # git.shihaam.dev/flamexode/prayertimes-sh. Every island's table is vendored, so -# switching island is an edit to config/prayertimes/islands.conf and a rebuild. -# -# Only the one script is linked out of scripts/, not the directory: ~/scripts -# also holds unmanaged things, such as the lock.sh that config/sway/config binds -# to $mod+l. # # Iteration loop: edit scripts/prayertimes.sh or config/prayertimes/islands.conf # -> git add if new -> nixos-rebuild switch -> prayertimes.sh today, and diff --git a/home/shihaam.nix b/home/shihaam.nix index 042f7fb..11d6631 100644 --- a/home/shihaam.nix +++ b/home/shihaam.nix @@ -7,6 +7,7 @@ ./packages.nix ./fonts.nix ./kdeconnect.nix + ./lock.nix ./nano.nix ./obs.nix ./prayertimes.nix diff --git a/scripts/lock.sh b/scripts/lock.sh new file mode 100755 index 0000000..479ea42 --- /dev/null +++ b/scripts/lock.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +prev_laptop=$(brightnessctl get) +prev_monitor=$(ddcutil -d 1 getvcp 10 | awk '{print $9}' | tr -d ',') +prev_kbd=$(brightnessctl -d tpacpi::kbd_backlight get) + +ddcutil -d 1 setvcp 10 0 & +brightnessctl set 0 +brightnessctl -d tpacpi::kbd_backlight set 0 +swaylock -e -c 000000 +ddcutil -d 1 setvcp 10 "$prev_monitor" +brightnessctl set "$prev_laptop" +brightnessctl -d tpacpi::kbd_backlight set "$prev_kbd"