diff --git a/nixos/modules/services/hardware/pommed.nix b/nixos/modules/services/hardware/pommed.nix index 7be4dc1e84643..bf7d6a46a293d 100644 --- a/nixos/modules/services/hardware/pommed.nix +++ b/nixos/modules/services/hardware/pommed.nix @@ -2,7 +2,9 @@ with lib; -{ +let cfg = config.services.hardware.pommed; + defaultConf = "${pkgs.pommed_light}/etc/pommed.conf.mactel"; +in { options = { @@ -12,37 +14,37 @@ with lib; type = types.bool; default = false; description = '' - Whether to use the pommed tool to handle Apple laptop keyboard hotkeys. + Whether to use the pommed tool to handle Apple laptop + keyboard hotkeys. ''; }; configFile = mkOption { - type = types.path; + type = types.nullOr types.path; + default = null; description = '' - The path to the pommed.conf file. + The path to the pommed.conf file. Leave + to null to use the default config file + (/etc/pommed.conf.mactel). See the + files /etc/pommed.conf.mactel and + /etc/pommed.conf.pmac for examples to + build on. ''; }; }; }; - config = mkIf config.services.hardware.pommed.enable { - environment.systemPackages = [ pkgs.polkit ]; + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.polkit pkgs.pommed_light ]; - environment.etc."pommed.conf".source = config.services.hardware.pommed.configFile; - - services.hardware.pommed.configFile = "${pkgs.pommed}/etc/pommed.conf"; - - services.dbus.packages = [ pkgs.pommed ]; + environment.etc."pommed.conf".source = + if cfg.configFile == null then defaultConf else cfg.configFile; systemd.services.pommed = { - description = "Pommed hotkey management"; + description = "Pommed Apple Hotkeys Daemon"; wantedBy = [ "multi-user.target" ]; - after = [ "dbus.service" ]; - postStop = "rm -f /var/run/pommed.pid"; - script = "${pkgs.pommed}/bin/pommed"; - serviceConfig.Type = "forking"; - path = [ pkgs.eject ]; + script = "${pkgs.pommed_light}/bin/pommed -f"; }; }; } diff --git a/pkgs/os-specific/linux/pommed-light/default.nix b/pkgs/os-specific/linux/pommed-light/default.nix new file mode 100644 index 0000000000000..a039984ff3386 --- /dev/null +++ b/pkgs/os-specific/linux/pommed-light/default.nix @@ -0,0 +1,65 @@ +{ + stdenv +, fetchurl +, pciutils +, confuse +, alsaLib +, audiofile +, pkgconfig +, zlib +, eject +}: + +stdenv.mkDerivation rec { + pkgname = "pommed-light"; + version = "1.50lw"; + name = "${pkgname}-${version}"; + + src = fetchurl { + url = "https://github.com/bytbox/${pkgname}/archive/v${version}.tar.gz"; + + sha256 = "1r2f28zqmyvzgymd0ng53hscbrq8vcqhxdnkq5dppjf9yrzn018b"; + }; + + postPatch = '' + substituteInPlace pommed.conf.mactel --replace /usr $out + substituteInPlace pommed.conf.pmac --replace /usr $out + substituteInPlace pommed/beep.h --replace /usr $out + substituteInPlace pommed/cd_eject.c --replace /usr/bin/eject ${eject}/bin/eject + ''; + + buildInputs = [ + pciutils + confuse + alsaLib + audiofile + pkgconfig + zlib + eject + ]; + + installPhase = '' + install -Dm755 pommed/pommed $out/bin/pommed + install -Dm644 pommed.conf.mactel $out/etc/pommed.conf.mactel + install -Dm644 pommed.conf.pmac $out/etc/pommed.conf.pmac + + # Man page + install -Dm644 pommed.1 $out/share/man/man1/pommed.1 + + # Sounds + install -Dm644 pommed/data/goutte.wav $out/share/pommed/goutte.wav + install -Dm644 pommed/data/click.wav $out/share/pommed/click.wav + ''; + + meta = { + description = "A trimmed version of the pommed hotkey handler for MacBooks"; + longDescription = '' + This is a stripped-down version of pommed with client, dbus, and + ambient light sensor support removed, optimized for use with dwm + and the like. + ''; + homepage = https://github.com/bytbox/pommed-light; + platforms = stdenv.lib.platforms.linux; + license = stdenv.lib.licenses.gpl2; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 33711f519c7f3..37780d742ec67 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14347,6 +14347,8 @@ in pommed = callPackage ../os-specific/linux/pommed {}; + pommed_light = callPackage ../os-specific/linux/pommed-light {}; + pond = callPackage ../applications/networking/instant-messengers/pond { }; ponymix = callPackage ../applications/audio/ponymix { };