-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
id3v1669
committed
Sep 18, 2024
1 parent
c5487c8
commit fe270db
Showing
3 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
self: | ||
{ config | ||
, lib | ||
, stdenv | ||
, ... | ||
}: | ||
let | ||
cfg = config.services.swhkd; | ||
inherit (stdenv.hostPlatform) system; | ||
|
||
inherit (lib) types; | ||
inherit (lib.modules) mkIf; | ||
inherit (lib.options) mkOption mkEnableOption; | ||
in | ||
{ | ||
options.services.swhkd = { | ||
enable = mkEnableOption "Simple Wayland HotKey Daemon"; | ||
|
||
package = mkOption { | ||
description = "The package to use for `swhkd`"; | ||
default = self.packages.${system}.default; | ||
type = types.package; | ||
}; | ||
|
||
cooldown = mkOption { | ||
description = "The cooldown to use for `swhkd`"; | ||
default = 250; | ||
type = types.int; | ||
}; | ||
|
||
settings = mkOption { | ||
description = "The config to use for `swhkd` syntax and samples could found in [repo](https://github.com/waycrate/swhkd)."; | ||
default = '' | ||
super + return | ||
alacritty | ||
''; | ||
type = types.lines; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment.systemPackages = [ cfg.package ]; | ||
environment.etc."swhkd/swhkdrc".text = cfg.settings; | ||
|
||
systemd.user.services.swhkd = { | ||
description = "Simple Wayland HotKey Daemon"; | ||
bindsTo = [ "default.target" ]; | ||
script = '' | ||
/run/wrappers/bin/pkexec ${cfg.package}/bin/swhkd \ | ||
--cooldown ${toString cfg.cooldown} | ||
''; | ||
serviceConfig.Restart = "always"; | ||
wantedBy = [ "default.target" ]; | ||
}; | ||
security.polkit = { | ||
enable = true; | ||
extraConfig = '' | ||
polkit.addRule(function(action, subject) { | ||
if (action.id == "com.github.swhkd.pkexec" && | ||
subject.local == true && | ||
subject.active == true &&) { | ||
return polkit.Result.YES; | ||
} | ||
}); | ||
''; | ||
}; | ||
}; | ||
} |