-
Notifications
You must be signed in to change notification settings - Fork 0
fix(noctalia): lock before lid suspend #1688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2360d61
0aa900f
3018c3d
5f3006a
e8b8164
e6592d3
aff6698
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,13 @@ | |
| pkgs, | ||
| ... | ||
| }: | ||
| let | ||
| noctaliaShell = inputs.noctalia-shell.packages.${pkgs.system}.default; | ||
| noctaliaLockBeforeSleep = pkgs.replaceVars ./lock-before-sleep.sh { | ||
| noctalia_shell = "${noctaliaShell}/bin/noctalia-shell"; | ||
| sleep = "${pkgs.coreutils}/bin/sleep"; | ||
| }; | ||
| in | ||
| { | ||
| xdg.configFile."noctalia/colorschemes/Dracula-Custom/Dracula-Custom.json" = { | ||
| source = ./Dracula-Custom.json; | ||
|
|
@@ -24,9 +31,21 @@ | |
| Install.WantedBy = [ "graphical-session.target" ]; | ||
| }; | ||
|
|
||
| systemd.user.services.noctalia-lock-before-sleep = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the overlap with |
||
| Unit = { | ||
| Description = "Lock Noctalia before system sleep"; | ||
| Before = [ "sleep.target" ]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
cubic-dev-ai[bot] marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing graphical-session ordering: the sibling |
||
| }; | ||
| Service = { | ||
| Type = "oneshot"; | ||
| ExecStart = "${pkgs.bash}/bin/bash ${noctaliaLockBeforeSleep}"; | ||
| }; | ||
| Install.WantedBy = [ "sleep.target" ]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This unit will likely never run on system suspend. systemd's user-instance
Please verify with (Apologies for missing this in my initial review — I assumed modern systemd propagates user |
||
| }; | ||
|
|
||
| programs.noctalia-shell = { | ||
| enable = true; | ||
| package = inputs.noctalia-shell.packages.${pkgs.system}.default; | ||
| package = noctaliaShell; | ||
|
|
||
| settings = { | ||
| bar = { | ||
|
|
@@ -60,6 +79,7 @@ | |
| { id = "PowerProfile"; } | ||
| { id = "Volume"; } | ||
| { id = "Brightness"; } | ||
| { id = "DarkMode"; } | ||
| { id = "ControlCenter"; } | ||
| ]; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
| # Lock through Noctalia before systemd lets suspend continue. | ||
| set -euo pipefail | ||
|
|
||
| NOCTALIA_SHELL="@noctalia_shell@" | ||
| SLEEP="@sleep@" | ||
|
|
||
| if ! "$NOCTALIA_SHELL" ipc call lockScreen lock; then | ||
| exit 0 | ||
| fi | ||
|
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silent lock failure allows suspend with no log; add a When The dual Hyprland At minimum, journal the failure so it's auditable: 🛡️ Proposed fix: log the failed lock before gracefully exiting+LOGGER="@logger@"
+
if ! "$NOCTALIA_SHELL" ipc call lockScreen lock; then
+ "$LOGGER" -t noctalia-lock-before-sleep \
+ "WARNING: lockScreen IPC call failed; suspending without a lock screen"
exit 0
fiWire +logger = "${pkgs.util-linux}/bin/logger";
noctalia_shell = ...;
sleep = ...;🤖 Prompt for AI Agents |
||
|
|
||
| "$SLEEP" 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,6 +210,10 @@ import ../../hosts/nixos { | |
| }; | ||
| security.pam.services.noctalia-shell = { | ||
| fprintAuth = true; | ||
| rules.auth.fprintd.settings = { | ||
| max-tries = -1; | ||
| timeout = -1; | ||
| }; | ||
| }; | ||
| security.pam.services.sudo = { | ||
| fprintAuth = true; | ||
|
|
@@ -246,9 +250,9 @@ import ../../hosts/nixos { | |
|
|
||
| # Power button behavior - lock screen instead of shutdown | ||
| services.logind.settings.Login.HandlePowerKey = "lock"; | ||
| # Suspend on lid close | ||
| # Suspend on battery lid close; on AC, Hyprland locks on the lid switch event. | ||
| services.logind.settings.Login.HandleLidSwitch = "suspend"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Battery lid-close still has a lock-vs-suspend race. With The AC path you just added (
|
||
| services.logind.settings.Login.HandleLidSwitchExternalPower = "suspend"; | ||
| services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore"; | ||
|
|
||
| # Auto timezone (via geolocation) | ||
| services.geoclue2.enable = true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2329 | ||
|
|
||
| Describe 'config/hyprland/hyprland.conf lid lock binding' | ||
| CONFIG="$PWD/config/hyprland/hyprland.conf" | ||
|
|
||
| It 'locks Noctalia when Hyprland reports the lid switch closing' | ||
| When run bash -c "grep -F 'bindl = , switch:on:Lid Switch, exec, noctalia-shell ipc call lockScreen lock' '$CONFIG'" | ||
| The output should include 'switch:on:Lid Switch' | ||
| The output should include 'lockScreen lock' | ||
| End | ||
|
|
||
| End |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2329 | ||
|
|
||
| Describe 'named-hosts/matic/default.nix lid policy' | ||
| CONFIG="$PWD/named-hosts/matic/default.nix" | ||
|
|
||
| It 'keeps battery lid close as suspend' | ||
| When run bash -c "grep -F 'services.logind.settings.Login.HandleLidSwitch = \"suspend\";' '$CONFIG'" | ||
| The output should include 'HandleLidSwitch = "suspend"' | ||
| End | ||
|
|
||
| It 'lets Hyprland handle lid close while on AC power' | ||
| When run bash -c "grep -F 'services.logind.settings.Login.HandleLidSwitchExternalPower = \"ignore\";' '$CONFIG'" | ||
| The output should include 'HandleLidSwitchExternalPower = "ignore"' | ||
| End | ||
|
|
||
| End |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2329 | ||
|
|
||
| Describe 'named-hosts/matic/default.nix Noctalia fingerprint PAM' | ||
| CONFIG="$PWD/named-hosts/matic/default.nix" | ||
|
|
||
| It 'keeps lock-screen fingerprint auth from timing out' | ||
| When run bash -c "awk '/security.pam.services.noctalia-shell = \\{/{in_service=1} in_service{print} in_service && /^ \\};/{exit}' '$CONFIG'" | ||
| The output should include 'fprintAuth = true;' | ||
| The output should include 'max-tries = -1;' | ||
| The output should include 'timeout = -1;' | ||
| End | ||
|
|
||
| End |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2329 | ||
|
|
||
| Describe 'config/noctalia/default.nix bar widgets' | ||
| CONFIG="$PWD/config/noctalia/default.nix" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider using ShellSpec's 🛡️ Proposed guard+ CONFIG="$PWD/config/noctalia/default.nix"
It 'places DarkMode immediately after Brightness on the right bar'
+ Skip if "config file not found" [ ! -f "$CONFIG" ]
When run bash -c "awk ..."🤖 Prompt for AI Agents |
||
|
|
||
| It 'places DarkMode immediately after Brightness on the right bar' | ||
| When run bash -c "awk '/widgets.right = \\[/{in_right=1} in_right && /id =/ { gsub(/.*id = \"|\";.*/, \"\"); print } in_right && /\\];/{exit}' '$CONFIG' | paste -sd ' ' -" | ||
| The output should include 'Brightness DarkMode ControlCenter' | ||
| End | ||
|
|
||
| End | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2016,SC2329 | ||
|
|
||
| Describe 'config/noctalia/lock-before-sleep.sh' | ||
| SCRIPT="$PWD/config/noctalia/lock-before-sleep.sh" | ||
|
|
||
| It 'uses bash strict mode' | ||
| When run bash -c "head -5 '$SCRIPT'" | ||
| The output should include 'set -euo pipefail' | ||
| End | ||
|
|
||
| It 'uses injected command paths' | ||
| When run bash -c "cat '$SCRIPT'" | ||
| The output should include '@noctalia_shell@' | ||
| The output should include '@sleep@' | ||
| End | ||
|
|
||
| It 'calls Noctalia lock IPC before sleeping' | ||
| When run bash -c "cat '$SCRIPT'" | ||
| The output should include 'ipc call lockScreen lock' | ||
| The output should include '"$SLEEP" 1' | ||
| End | ||
|
|
||
| End |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For GitHub Actions pull_request events, what does github.sha point to (head SHA vs merge SHA), and which refs are guaranteed to exist for raw.githubusercontent.com downloads?💡 Result:
For GitHub Actions workflows triggered by pull_request events (excluding pull_request_target), github.sha points to the SHA of the merge commit (a temporary test merge of the PR head into the base branch). This is the last merge commit on the GITHUB_REF branch, which is refs/pull/<PR number>/merge [1][2][3]. The head SHA is available via github.event.pull_request.head.sha, and base SHA via github.event.pull_request.base.sha [4][5]. actions/checkout by default checks out this merge commit [6]. For raw.githubusercontent.com downloads, the following refs are guaranteed to exist for any repository (public or private, as long as the file/blob is accessible via the token/permissions): - refs/heads/<branch> for any branch (e.g., https://raw.githubusercontent.com/user/repo/refs/heads/main/file.txt) - refs/tags/<tag> for any tag - <commit-sha> directly (e.g., https://raw.githubusercontent.com/user/repo/abc123/file.txt) - refs/pull/<PR number>/head pointing to the head commit of the PR (even for fork PRs) [7][8][9] - refs/pull/<PR number>/merge pointing to the test merge commit (only if the PR is mergeable) [4][1][10] These refs allow serving raw files from branches, tags, commits, and PRs via raw.githubusercontent.com [11].
Citations:
gh pr checkoutwithgit fetch refs/pullto avoid GH_HOST issues github/gh-aw#26136🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 1071
🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 123
🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 542
This step waits for the wrong ref—ensure the guarded SHA is actually available.
Line 70 checks for
refs/pull/<num>/head, but line 82 downloads using${{ github.sha }}, which onpull_requestevents points to the merge commit (refs/pull/<num>/merge). These are different refs. The merge ref exists only if the PR is mergeable, so the guard can pass while the SHA used byraw.githubusercontent.comis still unavailable.Either wait for
${{ github.sha }}availability directly, or fetch using${{ github.event.pull_request.head.sha }}consistently.🤖 Prompt for AI Agents