treewide: spawn wlogout on power button short press

This commit is contained in:
Anthony Rodriguez 2024-11-18 14:28:46 +01:00
parent 881ffab221
commit bc2ebd6c82
Signed by: nezia
GPG key ID: EE3BE97C040A86CE
4 changed files with 78 additions and 8 deletions

View file

@ -8,14 +8,19 @@
terminal = "foot"; terminal = "foot";
browser = "firefox"; browser = "firefox";
prefix = "Alt"; prefix = "Alt";
guiFileManager = "nautilus";
cliFileManager = "${terminal} -e yazi";
in { in {
programs.niri.settings.binds = { programs.niri.settings.binds = {
"${prefix}+D".action.spawn = appLauncher; "${prefix}+D".action.spawn = appLauncher;
"${prefix}+Return".action.spawn = terminal; "${prefix}+Return".action.spawn = terminal;
"${prefix}+W".action.spawn = browser; "${prefix}+W".action.spawn = browser;
"${prefix}+Shift+E".action.quit.skip-confirmation = true; "${prefix}+E".action.spawn = guiFileManager;
"${prefix}+Shift+E".action.spawn = cliFileManager;
"${prefix}+Shift+Slash".action = config.lib.niri.actions.show-hotkey-overlay; "${prefix}+Shift+Slash".action = config.lib.niri.actions.show-hotkey-overlay;
"${prefix}+Q".action = config.lib.niri.actions.close-window; "${prefix}+Q".action = config.lib.niri.actions.close-window;
"${prefix}+Shift+Q".action.quit.skip-confirmation = true;
"${prefix}+F".action = config.lib.niri.actions.maximize-column; "${prefix}+F".action = config.lib.niri.actions.maximize-column;
"${prefix}+Shift+F".action = config.lib.niri.actions.fullscreen-window; "${prefix}+Shift+F".action = config.lib.niri.actions.fullscreen-window;
"${prefix}+C".action = config.lib.niri.actions.center-column; "${prefix}+C".action = config.lib.niri.actions.center-column;
@ -157,5 +162,7 @@ in {
"XF86AudioMedia" = { "XF86AudioMedia" = {
action.spawn = ["sh" "-c" "env XDG_CURRENT_DESKTOP=gnome gnome-control-center"]; action.spawn = ["sh" "-c" "env XDG_CURRENT_DESKTOP=gnome gnome-control-center"];
}; };
"XF86PowerOff".action.spawn = "wlogout";
}; };
} }

View file

@ -26,10 +26,13 @@ in {
programs.niri = { programs.niri = {
settings = { settings = {
input.keyboard.xkb = { input = {
power-key-handling.enable = false;
keyboard.xkb = {
layout = "us"; layout = "us";
options = "compose:ralt"; options = "compose:ralt";
}; };
};
prefer-no-csd = true; prefer-no-csd = true;
hotkey-overlay.skip-at-startup = true; hotkey-overlay.skip-at-startup = true;
@ -117,4 +120,64 @@ in {
Restart = "on-failure"; Restart = "on-failure";
}; };
}; };
programs.wlogout = {
enable = true;
layout = let
systemd = let
systemd = lib.getExe' pkgs.systemd;
in {
loginctl = systemd "loginctl";
systemctl = systemd "systemctl";
};
in [
{
action = "${systemd.loginctl} lock-session";
keybind = "l";
label = "lock";
text = "Lock";
}
{
action = "${systemd.systemctl} hibernate";
keybind = "h";
label = "hibernate";
text = "Hibernate";
}
{
action = "${
systemd.loginctl
} terminate-user ${
config.home.username
}";
keybind = "q";
label = "logout";
text = "Logout";
}
{
action = "${systemd.systemctl} poweroff";
keybind = "p";
label = "shutdown";
text = "Shutdown";
}
{
action = "${systemd.systemctl} suspend";
keybind = "s";
label = "suspend";
text = "Suspend";
}
{
action = "${systemd.systemctl} reboot";
keybind = "r";
label = "reboot";
text = "Reboot";
}
];
};
} }

View file

@ -1,5 +1,9 @@
{ {
services.logind = { services.logind = {
lidSwitch = "suspend"; lidSwitch = "suspend";
extraConfig = ''
HandlePowerKey=ignore
HandlePowerKeyLongPress=poweroff
'';
}; };
} }

View file

@ -1,9 +1,5 @@
{ {
services = { services = {
logind.extraConfig = ''
HandlePowerKey=suspend
'';
power-profiles-daemon.enable = true; power-profiles-daemon.enable = true;
# battery info # battery info