Add a sleep script and bind the power button to it

This commit is contained in:
Bad 2022-02-22 01:03:10 +01:00
parent 440976059a
commit 052bc57f6b
6 changed files with 56 additions and 29 deletions

View file

@ -87,11 +87,11 @@
]
},
"locked": {
"lastModified": 1645007752,
"narHash": "sha256-FQZMiVP/1vgR7x+TWonMf0NZczrZ4ZjhSTj3rM+kglY=",
"lastModified": 1645293039,
"narHash": "sha256-PwdDu+SkX8dreeuJ/4av1sEluNZdrpdXv8JsRKKg1Yc=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "c944b5ee82a829ddf7fa6bd9300bc2fe3d005fa1",
"rev": "1df878b6f8351795a3bebfbe4fd2d02e1e8b29d6",
"type": "github"
},
"original": {
@ -197,11 +197,11 @@
"rust-analyzer-src": "rust-analyzer-src_2"
},
"locked": {
"lastModified": 1645165506,
"narHash": "sha256-PClhTeC1EhkHUQQmP9XyiR7y1d6hlEc7QY8nN1GuAzQ=",
"lastModified": 1645338193,
"narHash": "sha256-BTajZF5xFmO3+MZE29C6JRLSM6PXdoFrpTlaMZr0Ljc=",
"owner": "nix-community",
"repo": "fenix",
"rev": "380b82e3d3381b32f11dfe024cb7d135e36d0168",
"rev": "f15f0f9fedd87e265e49585463df72c1257f1ae8",
"type": "github"
},
"original": {
@ -327,16 +327,16 @@
]
},
"locked": {
"lastModified": 1643933536,
"narHash": "sha256-yRmsWAG4DnLxLIUtlaZsl0kH7rN5xSoyNRlf0YZrcH4=",
"lastModified": 1645244400,
"narHash": "sha256-o7KCd6ySFZ9/LbS62aTeuFmBWtP7Tt3Q3RcNjYgTgZU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2860d7e3bb350f18f7477858f3513f9798896831",
"rev": "0232fe1b75e6d7864fd82b5c72f6646f87838fc3",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-21.11",
"ref": "master",
"repo": "home-manager",
"type": "github"
}
@ -359,11 +359,11 @@
},
"latest_2": {
"locked": {
"lastModified": 1644525281,
"narHash": "sha256-D3VuWLdnLmAXIkooWAtbTGSQI9Fc1lkvAr94wTxhnTU=",
"lastModified": 1644613700,
"narHash": "sha256-wLRPJclMH8vsHuFtyI78aF09lw5mbi3lMB6uiK5S2wE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "48d63e924a2666baf37f4f14a18f19347fbd54a2",
"rev": "23d785aa6f853e6cf3430119811c334025bbef55",
"type": "github"
},
"original": {
@ -445,11 +445,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1644870092,
"narHash": "sha256-RLPD92lqXW98LDIbbwYqwAbt3R4iD1V1PiylfgBq5cU=",
"lastModified": 1645346782,
"narHash": "sha256-3qd0cu+2kapIP7cdHW9n8zh1wCvRGg83K7/cCj5Xv+A=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "10eab1c4cd8e715c0b41d32c28af2b89fc67bed0",
"rev": "1ccfe243aa6e94bf80f2a66f6be41d086d37fc87",
"type": "github"
},
"original": {
@ -476,11 +476,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1645225515,
"narHash": "sha256-fByCY0yhLr1u/hNFtyIttkGND4QugrLUx3KVbpEXqbg=",
"lastModified": 1645378280,
"narHash": "sha256-09OH6OcQunHGp6UP4VRfLwFg4UkfnBWZuqkhij2ZhNQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c927a5e42993b3f8b3f2df4f20dd4679f53b9a8c",
"rev": "16845d1fcc9e7628d7fe156c36ae27add7e1b4cc",
"type": "github"
},
"original": {
@ -507,11 +507,11 @@
},
"nixpkgs_4": {
"locked": {
"lastModified": 1644972330,
"narHash": "sha256-6V2JFpTUzB9G+KcqtUR1yl7f6rd9495YrFECslEmbGw=",
"lastModified": 1645013224,
"narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "19574af0af3ffaf7c9e359744ed32556f34536bd",
"rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970",
"type": "github"
},
"original": {
@ -523,11 +523,11 @@
},
"nixpkgs_5": {
"locked": {
"lastModified": 1644525281,
"narHash": "sha256-D3VuWLdnLmAXIkooWAtbTGSQI9Fc1lkvAr94wTxhnTU=",
"lastModified": 1644613700,
"narHash": "sha256-wLRPJclMH8vsHuFtyI78aF09lw5mbi3lMB6uiK5S2wE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "48d63e924a2666baf37f4f14a18f19347fbd54a2",
"rev": "23d785aa6f853e6cf3430119811c334025bbef55",
"type": "github"
},
"original": {
@ -614,11 +614,11 @@
"rust-analyzer-src_2": {
"flake": false,
"locked": {
"lastModified": 1645024434,
"narHash": "sha256-ZYwqOkx9MYKmbuqkLJdRhIn7IghMRclbUzxJgR7OOhA=",
"lastModified": 1645265362,
"narHash": "sha256-6z88g8cyw6Ae9SxgGUmT+jMuMadrJ4IgVV+UHdK4ook=",
"owner": "rust-analyzer",
"repo": "rust-analyzer",
"rev": "89faff7477e904f6820990f130a3aed72c1d7e6b",
"rev": "1d53f695f0408f47c5cce5cefa471eb0e86b0db7",
"type": "github"
},
"original": {

View file

@ -17,7 +17,7 @@
bud.inputs.nixpkgs.follows = "nixos";
bud.inputs.devshell.follows = "digga/devshell";
home.url = "github:nix-community/home-manager/release-21.11";
home.url = "github:nix-community/home-manager/master";
# home.url = "path:/home/mae/home-manager";
home.inputs.nixpkgs.follows = "nixos";

View file

@ -17,6 +17,10 @@ in
environment.pathsToLink = [ "/share/zsh" ];
services.logind.lidSwitch = "ignore";
services.logind.extraConfig = ''
# dont shutdown when power button is short-pressed
HandlePowerKey=ignore
'';
environment = {
systemPackages = with pkgs; [

View file

@ -1,8 +1,10 @@
{ pkgs, lib, ... }:
let
rofi = pkgs.rofi.override { plugins = [ pkgs.rofi-emoji ]; };
in
{
imports = [ ./swayidle.nix ];
wayland.windowManager.sway = rec {
enable = true;
config = {
@ -32,6 +34,9 @@ in
# and: https://github.com/NixOS/nixpkgs/issues/57602#issuecomment-820512097
{ command = "dbus-update-activation-environment WAYLAND_DISPLAY"; }
];
keybindings = lib.mkOptionDefault {
"XF86PowerOff" = "exec systemctl suspend";
};
};
wrapperFeatures.gtk = true;
systemdIntegration = true;

View file

@ -0,0 +1,5 @@
{ pkgs, ...}: {
lockscreen = pkgs.writeShellScriptBin "lockscreen" ''
${pkgs.swaylock-effects}/bin/swaylock --screenshot --clock --effect-blur 10x10
'';
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }@inputs:
let scripts = ((import ./scripts.nix) inputs); in
{
services.swayidle = {
enable = true;
events = [
{ event = "before-sleep"; command = "${scripts.lockscreen}/bin/lockscreen"; }
];
timeouts = [
# { timeout = 60; command = ; }
];
};
}