From b2ef9326fd73e71bdd6aecf2952c195f79f0b415 Mon Sep 17 00:00:00 2001 From: Joshua Yuen Date: Sat, 12 Sep 2026 02:46:18 -0400 Subject: [PATCH] Add AGS power controls and locking --- modules/home/ags/app/style.scss | 24 ++++++++++- modules/home/ags/app/widget/Bar.tsx | 4 ++ modules/home/ags/app/widget/Power.tsx | 62 +++++++++++++++++++++++++++ modules/home/hyprland/default.nix | 1 + modules/home/hyprland/hyprlock.nix | 36 ++++++++++++++++ modules/nixos/hyprland.nix | 2 + 6 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 modules/home/ags/app/widget/Power.tsx create mode 100644 modules/home/hyprland/hyprlock.nix diff --git a/modules/home/ags/app/style.scss b/modules/home/ags/app/style.scss index 81d409e..cdee348 100644 --- a/modules/home/ags/app/style.scss +++ b/modules/home/ags/app/style.scss @@ -45,7 +45,8 @@ .ws:hover, .volume:hover, .wifi:hover, -.battery:hover { +.battery:hover, +.power:hover { background: transparentize($base05, 0.88); } @@ -53,7 +54,8 @@ .mute icon, .wifi icon, .wifi-header icon, -.battery icon { +.battery icon, +.power icon { font-size: 16px; } @@ -173,3 +175,21 @@ font-size: 0.85em; opacity: 0.7; } + +.power-row { + padding: 4px 6px; + border-radius: 6px; + margin: 1px 0; + + icon { + font-size: 16px; + } + + label { + margin: 0 6px; + } +} + +.power-row:hover { + background: transparentize($base05, 0.88); +} diff --git a/modules/home/ags/app/widget/Bar.tsx b/modules/home/ags/app/widget/Bar.tsx index 8e46760..0cb1396 100644 --- a/modules/home/ags/app/widget/Bar.tsx +++ b/modules/home/ags/app/widget/Bar.tsx @@ -4,22 +4,26 @@ import Clock from "./Clock" import { VolumeWidget } from "./Volume" import { WifiWidget } from "./Wifi" import { BatteryWidget } from "./Battery" +import { PowerWidget } from "./Power" export default function Bar(gdkmonitor: Gdk.Monitor) { const { TOP, LEFT, RIGHT } = Astal.WindowAnchor const volume = VolumeWidget(gdkmonitor) const wifi = WifiWidget(gdkmonitor) const battery = BatteryWidget(gdkmonitor) + const power = PowerWidget(gdkmonitor) const right: Array = [] if (wifi.button) right.push(wifi.button) right.push(volume.button) if (battery.button) right.push(battery.button) + right.push(power.button) const popups: Array = [] if (wifi.popup) popups.push(wifi.popup) popups.push(volume.popup) if (battery.popup) popups.push(battery.popup) + popups.push(power.popup) return [ ( diff --git a/modules/home/ags/app/widget/Power.tsx b/modules/home/ags/app/widget/Power.tsx new file mode 100644 index 0000000..6b1ba8e --- /dev/null +++ b/modules/home/ags/app/widget/Power.tsx @@ -0,0 +1,62 @@ +import Gtk from "gi://Gtk?version=3.0" +import { execAsync, Variable } from "astal" +import Dropdown from "./Dropdown" + +const actions = [ + { label: "lock", icon: "system-lock-screen-symbolic", cmd: ["hyprlock"] }, + { + label: "suspend", + icon: "weather-clear-night-symbolic", + cmd: ["systemctl", "suspend"], + }, + { + label: "log out", + icon: "system-log-out-symbolic", + cmd: ["hyprctl", "dispatch", "exit"], + }, + { + label: "reboot", + icon: "system-reboot-symbolic", + cmd: ["systemctl", "reboot"], + }, + { + label: "shut down", + icon: "system-shutdown-symbolic", + cmd: ["systemctl", "poweroff"], + }, +] + +function PowerRow(action: (typeof actions)[number]) { + return ( + + ) +} + +export function PowerWidget(gdkmonitor: Gdk.Monitor) { + const open = Variable(false) + + const button = ( + + ) + + const popup = ( + + {actions.map((action) => PowerRow(action))} + + ) + + return { button, popup } +} \ No newline at end of file diff --git a/modules/home/hyprland/default.nix b/modules/home/hyprland/default.nix index 7f3d0a1..b633bf0 100644 --- a/modules/home/hyprland/default.nix +++ b/modules/home/hyprland/default.nix @@ -5,5 +5,6 @@ imports = [ ./binds.nix ./hyprland.nix + ./hyprlock.nix ]; } diff --git a/modules/home/hyprland/hyprlock.nix b/modules/home/hyprland/hyprlock.nix new file mode 100644 index 0000000..26195c1 --- /dev/null +++ b/modules/home/hyprland/hyprlock.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + ... +}: +with lib; +let + cfg = config.modules.hyprland; + colors = config.lib.stylix.colors; +in +{ + config = mkIf cfg.enable { + programs.hyprlock = { + enable = true; + settings = { + general = { + hide_cursor = true; + ignore_empty_input = true; + }; + + label = [ + { + monitor = ""; + text = "$TIME12"; + position = "0, 100"; + halign = "center"; + valign = "center"; + font_size = 48; + font_family = "${config.stylix.fonts.sansSerif.name}"; + color = "rgb(${colors.base05})"; + } + ]; + }; + }; + }; +} \ No newline at end of file diff --git a/modules/nixos/hyprland.nix b/modules/nixos/hyprland.nix index d86f903..0bb3c8b 100644 --- a/modules/nixos/hyprland.nix +++ b/modules/nixos/hyprland.nix @@ -13,5 +13,7 @@ in enable = true; withUWSM = true; }; + + security.pam.services.hyprlock = { }; }; }