2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.xserver.imwheel;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.xserver.imwheel = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "IMWheel service");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "--buttons=45" ];
|
|
|
|
example = [ "--debug" ];
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Additional command-line arguments to pass to
|
2022-08-12 12:06:08 +00:00
|
|
|
{command}`imwheel`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
rules = mkOption {
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
default = {};
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
".*" = '''
|
|
|
|
None, Up, Button4, 8
|
|
|
|
None, Down, Button5, 8
|
|
|
|
Shift_L, Up, Shift_L|Button4, 4
|
|
|
|
Shift_L, Down, Shift_L|Button5, 4
|
|
|
|
Control_L, Up, Control_L|Button4
|
|
|
|
Control_L, Down, Control_L|Button5
|
|
|
|
''';
|
|
|
|
}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Window class translation rules.
|
|
|
|
/etc/X11/imwheelrc is generated based on this config
|
|
|
|
which means this config is global for all users.
|
2023-11-16 04:20:00 +00:00
|
|
|
See [official man pages](https://imwheel.sourceforge.net/imwheel.1.html)
|
2022-12-28 21:21:41 +00:00
|
|
|
for more information.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.imwheel ];
|
|
|
|
|
|
|
|
environment.etc."X11/imwheel/imwheelrc".source =
|
|
|
|
pkgs.writeText "imwheelrc" (concatStringsSep "\n\n"
|
|
|
|
(mapAttrsToList
|
|
|
|
(rule: conf: "\"${rule}\"\n${conf}") cfg.rules
|
|
|
|
));
|
|
|
|
|
|
|
|
systemd.user.services.imwheel = {
|
|
|
|
description = "imwheel service";
|
|
|
|
wantedBy = [ "graphical-session.target" ];
|
|
|
|
partOf = [ "graphical-session.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.imwheel}/bin/imwheel " + escapeShellArgs ([
|
|
|
|
"--detach"
|
|
|
|
"--kill"
|
|
|
|
] ++ cfg.extraOptions);
|
|
|
|
ExecStop = "${pkgs.procps}/bin/pkill imwheel";
|
2020-09-25 04:45:31 +00:00
|
|
|
RestartSec = 3;
|
|
|
|
Restart = "always";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|