1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-05 02:39:45 +01:00
home-manager/modules/services/xcape.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

84 lines
2.4 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.xcape;
in {
meta.maintainers = [ maintainers.nickhu ];
options = {
services.xcape = {
enable = mkEnableOption (lib.mdDoc "xcape");
timeout = mkOption {
type = types.nullOr types.int;
default = null;
example = 500;
description = lib.mdDoc ''
If you hold a key longer than this timeout, xcape will not
generate a key event. Default is 500 ms.
'';
};
mapExpression = mkOption {
type = types.attrsOf types.str;
default = { };
example = {
Shift_L = "Escape";
Control_L = "Control_L|O";
};
description = lib.mdDoc ''
The value has the grammar `Key[|OtherKey]`.
The list of key names is found in the header file
{file}`X11/keysymdef.h` (remove the
`XK_` prefix). Note that due to limitations
of X11 shifted keys must be specified as a shift key
followed by the key to be pressed rather than the actual
name of the character. For example to generate "{" the
expression `Shift_L|bracketleft` could be
used (assuming that you have a key with "{" above "[").
You can also specify keys in decimal (prefix #), octal (#0),
or hexadecimal (#0x). They will be interpreted as keycodes
unless no corresponding key name is found.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xcape" pkgs
lib.platforms.linux)
];
systemd.user.services.xcape = {
Unit = mkMerge [
{
Description = "xcape";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
}
(mkIf (config.home.keyboard != null && config.home.keyboard != { }) {
After = [ "graphical-session-pre.target" "setxkbmap.service" ];
})
];
Service = {
Type = "forking";
ExecStart = "${pkgs.xcape}/bin/xcape"
+ optionalString (cfg.timeout != null) " -t ${toString cfg.timeout}"
+ optionalString (cfg.mapExpression != { }) " -e '${
builtins.concatStringsSep ";"
(attrsets.mapAttrsToList (n: v: "${n}=${v}") cfg.mapExpression)
}'";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
}