/** * For now this just hard copies the config file. * This can be improved by allowing users to define there own keybinds */ { config, lib, pkgs, ... }: let cfg = config.nixos95.keybinds; t = lib.types; slib = pkgs.callPackage ./util/lib.nix { }; in { options.nixos95.keybinds = { default_commands = lib.mkOption { internal = true; description = '' INTERNAL: additional default keyboard shortcuts to add ''; type = t.listOf t.attrs; default = [ { key = "XF86WWW"; exe = "exo-open --launch WebBrowser"; } { key = "XF86Mail"; exe = "exo-open --launch MailReder"; } { key = "Print"; exe = "xfce4-screenshooter"; } { key = "s"; exe = "xfce4-screenshooter --fullscreen"; } { key = "Super_L"; pkg = pkgs.xfce.xfce4-whiskermenu-plugin; # open whiskermenu with a press on SUPER like on windows } ]; }; commands = lib.mkOption { description = '' Keyboard shortcuts that should be made available. Each keyboard shortcut is defined as a set with the follwoing schema: { enable = bool; [optional; default = true] key = string; [key sequence to triggger the command] # to specify which command to execute use on of the following: pkg = package; [use mainProgramm of a nix package; e.g. pkgs.firefox] exe = string; [provide a program name directly; e.g. firefox] } > Modifier keys must be surrounded by angle brackets ''; type = t.listOf t.attrs; default = [ { key = "r"; exe = "xfce4-appfinder --collapsed"; } ]; }; xfwm4 = lib.mkOption { description = '' Keyboard shortcuts to control xfwm4 Each keyboard shortcut is defined as a set with the follwoing schema: { enable = bool; [optional; default = true] key = string; [key sequence to triggger the command] # to specify which command to execute use on of the following: pkg = package; [use mainProgramm of a nix package; e.g. pkgs.firefox] exe = string; [provide a program name directly; e.g. firefox] } > Modifier keys must be surrounded by angle brackets ''; type = t.listOf t.attrs; default = [ ]; }; }; config = lib.mkIf config.nixos95.enable { home-manager.users.${config.nixos95.user} = { xdg.configFile = let to_xml = list : list |> lib.filter slib.isEnable |> lib.map ( elm : let key = lib.escapeXML elm.key; exe = lib.escapeXML (slib.getExe elm); in '' '') |> lib.concatStringsSep "\n"; default_commands_xml = to_xml cfg.default_commands; commands_xml = to_xml cfg.commands; xfwm4_xml = to_xml cfg.xfwm4; in { "xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml" = { force = true; text = '' ${default_commands_xml} ${commands_xml} ${builtins.readFile ./dotfiles/xfwm4-keybinds.xml} ${xfwm4_xml} ''; }; }; }; }; }