From a0dd094e7dc356d34b0d97d180f088fcdaef57d7 Mon Sep 17 00:00:00 2001 From: Kajus Naujokaitis Date: Mon, 21 Oct 2024 16:04:59 +0300 Subject: [PATCH] Improved autolock functionality, relocated styles - Adjusted autolock behavior for a smoother transition to the lock screen - Relocated lock screen, login screen, and launcher styles to the styles directory - Updated default lock behavior to use loginctl Signed-off-by: Kajus Naujokaitis --- modules/desktop/graphics/ewwbar.nix | 3 +- modules/desktop/graphics/ghaf-launcher.nix | 46 +---------------- modules/desktop/graphics/labwc.config.nix | 13 +++-- modules/desktop/graphics/login-manager.nix | 23 +-------- .../graphics/styles/launcher-style.nix | 51 +++++++++++++++++++ .../styles/{gtk-lock.nix => lock-style.nix} | 4 +- .../desktop/graphics/styles/login-style.nix | 29 +++++++++++ 7 files changed, 98 insertions(+), 71 deletions(-) create mode 100644 modules/desktop/graphics/styles/launcher-style.nix rename modules/desktop/graphics/styles/{gtk-lock.nix => lock-style.nix} (89%) create mode 100644 modules/desktop/graphics/styles/login-style.nix diff --git a/modules/desktop/graphics/ewwbar.nix b/modules/desktop/graphics/ewwbar.nix index 0ef5af2b6..8c98bcefa 100644 --- a/modules/desktop/graphics/ewwbar.nix +++ b/modules/desktop/graphics/ewwbar.nix @@ -12,7 +12,6 @@ let cfg = config.ghaf.graphics.labwc; audio-ctrl = pkgs.callPackage ../../../packages/audio-ctrl { }; - gtklockStyle = pkgs.callPackage ./styles/gtk-lock.nix { }; launcher-icon = "${pkgs.ghaf-artwork}/icons/launcher.svg"; @@ -593,7 +592,7 @@ in :class "power-menu-button" :icon "${lock-icon}" :title "Lock" - :onclick "${eww-popup}/bin/eww-popup power-menu & ${pkgs.gtklock}/bin/gtklock -s ${gtklockStyle} &"))) + :onclick "${eww-popup}/bin/eww-popup power-menu & loginctl lock-session &"))) ;; Quick Settings Buttons ;; (defwidget settings_buttons [] diff --git a/modules/desktop/graphics/ghaf-launcher.nix b/modules/desktop/graphics/ghaf-launcher.nix index ffcd28ee6..5dabb1c40 100644 --- a/modules/desktop/graphics/ghaf-launcher.nix +++ b/modules/desktop/graphics/ghaf-launcher.nix @@ -2,49 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 { pkgs, ... }: let - drawerCSS = pkgs.writeTextDir "nwg-drawer/drawer.css" '' - /* Example configuration from: https://github.com/nwg-piotr/nwg-drawer/blob/main/drawer.css */ - window { - background-color: #121212; - color: #fff; - } - - /* search entry */ - entry { - background-color: rgba (43, 43, 43, 1); - border: 1px solid rgba(46, 46, 46, 1); - } - entry:focus { - box-shadow: none; - border: 1px solid rgba(223, 92, 55, 1); - } - - button, image { - background: none; - border: none; - box-shadow: none; - } - - button:hover { - background-color: rgba (255, 255, 255, 0.06); - } - - /* in case you wanted to give category buttons a different look */ - #category-button { - margin: 0 10px 0 10px; - } - - #pinned-box { - padding-bottom: 5px; - border-bottom: 1px dotted gray; - } - - #files-box { - padding: 5px; - border: 1px dotted gray; - border-radius: 15px; - } - ''; + drawerCSS = pkgs.callPackage ./styles/launcher-style.nix { }; in pkgs.writeShellApplication { name = "ghaf-launcher"; @@ -63,6 +21,6 @@ pkgs.writeShellApplication { rm -rf "$HOME/.config/nwg-drawer" #ln -s "${drawerCSS}/nwg-drawer" "$HOME/.config/" - nwg-drawer -r -nofs -nocats -s ${drawerCSS}/nwg-drawer/drawer.css + nwg-drawer -r -nofs -nocats -s ${drawerCSS} ''; } diff --git a/modules/desktop/graphics/labwc.config.nix b/modules/desktop/graphics/labwc.config.nix index 44e708909..9886a45ef 100644 --- a/modules/desktop/graphics/labwc.config.nix +++ b/modules/desktop/graphics/labwc.config.nix @@ -11,7 +11,7 @@ let audio-ctrl = pkgs.callPackage ../../../packages/audio-ctrl { }; ghaf-screenshot = pkgs.callPackage ../../../packages/ghaf-screenshot { }; - gtklockStyle = pkgs.callPackage ./styles/gtk-lock.nix { }; + gtklockStyle = pkgs.callPackage ./styles/lock-style.nix { }; lockCmd = "${pkgs.gtklock}/bin/gtklock -s ${gtklockStyle}"; ghaf-launcher = pkgs.callPackage ./ghaf-launcher.nix { inherit config pkgs; }; autostart = pkgs.writeShellApplication { @@ -68,7 +68,7 @@ let - + ${lib.optionalString config.ghaf.profiles.debug.enable '' @@ -265,7 +265,14 @@ in Type = "simple"; ExecStart = '' ${pkgs.swayidle}/bin/swayidle -w timeout ${builtins.toString cfg.autolock.duration} \ - '${pkgs.chayang}/bin/chayang && ${lockCmd}' + # Start dimming for 3.5 seconds in the background + '${pkgs.chayang}/bin/chayang -d 3.5 & CHAYANG_PID=$!; \ + sleep 3; \ + # If chayang is still running (i.e., user hasn't interrupted), + # proceed with locking + if kill -0 $CHAYANG_PID 2>/dev/null; then \ + loginctl lock-session; \ + fi' ''; }; partOf = [ "ghaf-session.target" ]; diff --git a/modules/desktop/graphics/login-manager.nix b/modules/desktop/graphics/login-manager.nix index d58bc6596..a866a2e63 100644 --- a/modules/desktop/graphics/login-manager.nix +++ b/modules/desktop/graphics/login-manager.nix @@ -8,27 +8,8 @@ }: let cfg = config.ghaf.graphics.login-manager; - gtkgreetStyle = pkgs.writeText "gtkgreet.css" '' - window { - background: rgba(18, 18, 18, 1); - color: #fff; - } - button { - box-shadow: none; - border-radius: 5px; - border: 1px solid rgba(255, 255, 255, 0.09); - background: rgba(255, 255, 255, 0.06); - } - entry { - background-color: rgba (43, 43, 43, 1); - border: 1px solid rgba(46, 46, 46, 1); - color: #eee; - } - entry:focus { - box-shadow: none; - border: 1px solid rgba(223, 92, 55, 1); - } - ''; + + gtkgreetStyle = pkgs.callPackage ./styles/login-style.nix { }; in { options.ghaf.graphics.login-manager = { diff --git a/modules/desktop/graphics/styles/launcher-style.nix b/modules/desktop/graphics/styles/launcher-style.nix new file mode 100644 index 000000000..a5d19e744 --- /dev/null +++ b/modules/desktop/graphics/styles/launcher-style.nix @@ -0,0 +1,51 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 + +# Ghaf app launcher style +{ + pkgs, + ... +}: +pkgs.writeText "ghaf-launcher.css" '' + /* Example configuration from: https://github.com/nwg-piotr/nwg-drawer/blob/main/drawer.css */ + window { + background-color: #121212; + color: #fff; + } + + /* search entry */ + entry { + background-color: rgba (43, 43, 43, 1); + border: 1px solid rgba(46, 46, 46, 1); + } + entry:focus { + box-shadow: none; + border: 1px solid rgba(223, 92, 55, 1); + } + + button, image { + background: none; + border: none; + box-shadow: none; + } + + button:hover { + background-color: rgba (255, 255, 255, 0.06); + } + + /* in case you wanted to give category buttons a different look */ + #category-button { + margin: 0 10px 0 10px; + } + + #pinned-box { + padding-bottom: 5px; + border-bottom: 1px dotted gray; + } + + #files-box { + padding: 5px; + border: 1px dotted gray; + border-radius: 15px; + } +'' diff --git a/modules/desktop/graphics/styles/gtk-lock.nix b/modules/desktop/graphics/styles/lock-style.nix similarity index 89% rename from modules/desktop/graphics/styles/gtk-lock.nix rename to modules/desktop/graphics/styles/lock-style.nix index df08e92ce..cf791f2bc 100644 --- a/modules/desktop/graphics/styles/gtk-lock.nix +++ b/modules/desktop/graphics/styles/lock-style.nix @@ -1,10 +1,12 @@ # Copyright 2022-2024 TII (SSRC) and the Ghaf contributors # SPDX-License-Identifier: Apache-2.0 + +# Ghaf lock screen style { pkgs, ... }: -pkgs.writeText "gtklock.css" '' +pkgs.writeText "ghaf-lock.css" '' window { background: rgba(18, 18, 18, 1); color: #fff; diff --git a/modules/desktop/graphics/styles/login-style.nix b/modules/desktop/graphics/styles/login-style.nix new file mode 100644 index 000000000..7ae6a1c12 --- /dev/null +++ b/modules/desktop/graphics/styles/login-style.nix @@ -0,0 +1,29 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 + +# Ghaf login screen style +{ + pkgs, + ... +}: +pkgs.writeText "ghaf-login.css" '' + window { + background: rgba(18, 18, 18, 1); + color: #fff; + } + button { + box-shadow: none; + border-radius: 5px; + border: 1px solid rgba(255, 255, 255, 0.09); + background: rgba(255, 255, 255, 0.06); + } + entry { + background-color: rgba (43, 43, 43, 1); + border: 1px solid rgba(46, 46, 46, 1); + color: #eee; + } + entry:focus { + box-shadow: none; + border: 1px solid rgba(223, 92, 55, 1); + } +''