Merge pull request #5 from gytic/hotkeys
Add declarative keyboard settings
This commit is contained in:
commit
8644a50587
5 changed files with 116 additions and 207 deletions
|
|
@ -65,6 +65,12 @@ in {
|
|||
}
|
||||
];
|
||||
};
|
||||
|
||||
keybinds = {
|
||||
commands = [
|
||||
{ key="<Super>l"; exe="xflock4"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
################################################################
|
||||
|
|
|
|||
|
|
@ -1,197 +0,0 @@
|
|||
<?xml version="1.1" encoding="UTF-8"?>
|
||||
|
||||
<channel name="xfce4-keyboard-shortcuts" version="1.0">
|
||||
<property name="commands" type="empty">
|
||||
<property name="default" type="empty">
|
||||
<property name="<Alt>F1" type="empty"/>
|
||||
<property name="<Alt>F2" type="empty">
|
||||
<property name="startup-notify" type="empty"/>
|
||||
</property>
|
||||
<property name="<Alt>F3" type="empty">
|
||||
<property name="startup-notify" type="empty"/>
|
||||
</property>
|
||||
<property name="<Primary><Alt>Delete" type="empty"/>
|
||||
<property name="<Primary><Alt>l" type="empty"/>
|
||||
<property name="<Primary><Alt>t" type="empty"/>
|
||||
<property name="XF86Display" type="empty"/>
|
||||
<property name="<Super>p" type="empty"/>
|
||||
<property name="<Primary>Escape" type="empty"/>
|
||||
<property name="XF86WWW" type="empty"/>
|
||||
<property name="HomePage" type="empty"/>
|
||||
<property name="XF86Mail" type="empty"/>
|
||||
<property name="Print" type="empty"/>
|
||||
<property name="<Alt>Print" type="empty"/>
|
||||
<property name="<Shift>Print" type="empty"/>
|
||||
<property name="<Super>e" type="empty"/>
|
||||
<property name="<Primary><Alt>f" type="empty"/>
|
||||
<property name="<Primary><Alt>Escape" type="empty"/>
|
||||
<property name="<Primary><Shift>Escape" type="empty"/>
|
||||
<property name="<Super>r" type="empty">
|
||||
<property name="startup-notify" type="empty"/>
|
||||
</property>
|
||||
<property name="<Alt><Super>s" type="empty"/>
|
||||
</property>
|
||||
<property name="custom" type="empty">
|
||||
<property name="<Alt>F2" type="string" value="xfce4-appfinder --collapsed">
|
||||
<property name="startup-notify" type="bool" value="true"/>
|
||||
</property>
|
||||
<property name="<Alt>Print" type="string" value="xfce4-screenshooter -w"/>
|
||||
<property name="<Super>r" type="string" value="xfce4-appfinder -c">
|
||||
<property name="startup-notify" type="bool" value="true"/>
|
||||
</property>
|
||||
<property name="XF86WWW" type="string" value="exo-open --launch WebBrowser"/>
|
||||
<property name="XF86Mail" type="string" value="exo-open --launch MailReader"/>
|
||||
<property name="<Alt>F3" type="string" value="xfce4-appfinder">
|
||||
<property name="startup-notify" type="bool" value="true"/>
|
||||
</property>
|
||||
<property name="Print" type="string" value="xfce4-screenshooter"/>
|
||||
<property name="<Primary>Escape" type="string" value="xfdesktop --menu"/>
|
||||
<property name="<Shift>Print" type="string" value="xfce4-screenshooter -r"/>
|
||||
<property name="<Primary><Alt>Delete" type="string" value="xfce4-session-logout"/>
|
||||
<property name="<Alt><Super>s" type="string" value="orca"/>
|
||||
<property name="<Primary><Alt>t" type="string" value="exo-open --launch TerminalEmulator"/>
|
||||
<property name="<Primary><Alt>f" type="string" value="thunar"/>
|
||||
<property name="<Primary><Alt>l" type="string" value="xflock4"/>
|
||||
<property name="<Super>l" type="string" value="xflock4"/>
|
||||
<property name="<Alt>F1" type="string" value="xfce4-popup-applicationsmenu"/>
|
||||
<property name="<Super>p" type="string" value="xfce4-display-settings --minimal"/>
|
||||
<property name="<Primary><Shift>Escape" type="string" value="xfce4-taskmanager"/>
|
||||
<property name="<Super>e" type="string" value="thunar"/>
|
||||
<property name="<Primary><Alt>Escape" type="string" value="xkill"/>
|
||||
<property name="HomePage" type="string" value="exo-open --launch WebBrowser"/>
|
||||
<property name="XF86Display" type="string" value="xfce4-display-settings --minimal"/>
|
||||
<property name="override" type="bool" value="true"/>
|
||||
</property>
|
||||
</property>
|
||||
<property name="xfwm4" type="empty">
|
||||
<property name="default" type="empty">
|
||||
<property name="<Alt>Insert" type="empty"/>
|
||||
<property name="Escape" type="empty"/>
|
||||
<property name="Left" type="empty"/>
|
||||
<property name="Right" type="empty"/>
|
||||
<property name="Up" type="empty"/>
|
||||
<property name="Down" type="empty"/>
|
||||
<property name="<Alt>Tab" type="empty"/>
|
||||
<property name="<Alt><Shift>Tab" type="empty"/>
|
||||
<property name="<Alt>Delete" type="empty"/>
|
||||
<property name="<Primary><Alt>Down" type="empty"/>
|
||||
<property name="<Primary><Alt>Left" type="empty"/>
|
||||
<property name="<Shift><Alt>Page_Down" type="empty"/>
|
||||
<property name="<Alt>F4" type="empty"/>
|
||||
<property name="<Alt>F6" type="empty"/>
|
||||
<property name="<Alt>F7" type="empty"/>
|
||||
<property name="<Alt>F8" type="empty"/>
|
||||
<property name="<Alt>F9" type="empty"/>
|
||||
<property name="<Alt>F10" type="empty"/>
|
||||
<property name="<Alt>F11" type="empty"/>
|
||||
<property name="<Alt>F12" type="empty"/>
|
||||
<property name="<Primary><Shift><Alt>Left" type="empty"/>
|
||||
<property name="<Primary><Alt>End" type="empty"/>
|
||||
<property name="<Primary><Alt>Home" type="empty"/>
|
||||
<property name="<Primary><Shift><Alt>Right" type="empty"/>
|
||||
<property name="<Primary><Shift><Alt>Up" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_1" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_2" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_3" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_4" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_5" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_6" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_7" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_8" type="empty"/>
|
||||
<property name="<Primary><Alt>KP_9" type="empty"/>
|
||||
<property name="<Alt>space" type="empty"/>
|
||||
<property name="<Shift><Alt>Page_Up" type="empty"/>
|
||||
<property name="<Primary><Alt>Right" type="empty"/>
|
||||
<property name="<Primary><Alt>d" type="empty"/>
|
||||
<property name="<Primary><Alt>Up" type="empty"/>
|
||||
<property name="<Super>Tab" type="xfce4-popup-applicationsmenu"/>
|
||||
<property name="<Primary>F1" type="empty"/>
|
||||
<property name="<Primary>F2" type="empty"/>
|
||||
<property name="<Primary>F3" type="empty"/>
|
||||
<property name="<Primary>F4" type="empty"/>
|
||||
<property name="<Primary>F5" type="empty"/>
|
||||
<property name="<Primary>F6" type="empty"/>
|
||||
<property name="<Primary>F7" type="empty"/>
|
||||
<property name="<Primary>F8" type="empty"/>
|
||||
<property name="<Primary>F9" type="empty"/>
|
||||
<property name="<Primary>F10" type="empty"/>
|
||||
<property name="<Primary>F11" type="empty"/>
|
||||
<property name="<Primary>F12" type="empty"/>
|
||||
<property name="<Super>KP_Left" type="empty"/>
|
||||
<property name="<Super>KP_Right" type="empty"/>
|
||||
<property name="<Super>KP_Down" type="empty"/>
|
||||
<property name="<Super>KP_Up" type="empty"/>
|
||||
<property name="<Super>KP_Page_Up" type="empty"/>
|
||||
<property name="<Super>KP_Home" type="empty"/>
|
||||
<property name="<Super>KP_End" type="empty"/>
|
||||
<property name="<Super>KP_Next" type="empty"/>
|
||||
</property>
|
||||
<property name="custom" type="empty">
|
||||
<property name="<Primary>F12" type="string" value="workspace_12_key"/>
|
||||
<property name="<Super>KP_Down" type="string" value="tile_down_key"/>
|
||||
<property name="<Alt>F4" type="string" value="close_window_key"/>
|
||||
<property name="<Primary><Alt>KP_3" type="string" value="move_window_workspace_3_key"/>
|
||||
<property name="<Primary>F2" type="string" value="workspace_2_key"/>
|
||||
<property name="<Primary>F6" type="string" value="workspace_6_key"/>
|
||||
<property name="<Primary><Alt>Down" type="string" value="down_workspace_key"/>
|
||||
<property name="<Primary><Alt>KP_9" type="string" value="move_window_workspace_9_key"/>
|
||||
<property name="<Super>KP_Up" type="string" value="tile_up_key"/>
|
||||
<property name="<Primary><Alt>End" type="string" value="move_window_next_workspace_key"/>
|
||||
<property name="<Primary>F8" type="string" value="workspace_8_key"/>
|
||||
<property name="<Primary><Shift><Alt>Left" type="string" value="move_window_left_key"/>
|
||||
<property name="<Super>KP_Right" type="string" value="tile_right_key"/>
|
||||
<property name="<Primary><Alt>KP_4" type="string" value="move_window_workspace_4_key"/>
|
||||
<property name="Right" type="string" value="right_key"/>
|
||||
<property name="Down" type="string" value="down_key"/>
|
||||
<property name="<Primary>F3" type="string" value="workspace_3_key"/>
|
||||
<property name="<Shift><Alt>Page_Down" type="string" value="lower_window_key"/>
|
||||
<property name="<Primary>F9" type="string" value="workspace_9_key"/>
|
||||
<property name="<Alt>Tab" type="string" value="cycle_windows_key"/>
|
||||
<property name="<Primary><Shift><Alt>Right" type="string" value="move_window_right_key"/>
|
||||
<property name="<Primary><Alt>Right" type="string" value="right_workspace_key"/>
|
||||
<property name="<Alt>F6" type="string" value="stick_window_key"/>
|
||||
<property name="<Primary><Alt>KP_5" type="string" value="move_window_workspace_5_key"/>
|
||||
<property name="<Primary>F11" type="string" value="workspace_11_key"/>
|
||||
<property name="<Alt>F10" type="string" value="maximize_window_key"/>
|
||||
<property name="<Alt>Delete" type="string" value="del_workspace_key"/>
|
||||
<property name="<Super>Tab" type="string" value="switch_window_key"/>
|
||||
<property name="<Primary><Alt>d" type="string" value="show_desktop_key"/>
|
||||
<property name="<Primary>F4" type="string" value="workspace_4_key"/>
|
||||
<property name="<Super>KP_Page_Up" type="string" value="tile_up_right_key"/>
|
||||
<property name="<Alt>F7" type="string" value="move_window_key"/>
|
||||
<property name="Up" type="string" value="up_key"/>
|
||||
<property name="<Primary><Alt>KP_6" type="string" value="move_window_workspace_6_key"/>
|
||||
<property name="<Alt>F11" type="string" value="fullscreen_key"/>
|
||||
<property name="<Alt>space" type="string" value="popup_menu_key"/>
|
||||
<property name="<Super>KP_Home" type="string" value="tile_up_left_key"/>
|
||||
<property name="Escape" type="string" value="cancel_key"/>
|
||||
<property name="<Primary><Alt>KP_1" type="string" value="move_window_workspace_1_key"/>
|
||||
<property name="<Super>KP_Next" type="string" value="tile_down_right_key"/>
|
||||
<property name="<Super>KP_Left" type="string" value="tile_left_key"/>
|
||||
<property name="<Shift><Alt>Page_Up" type="string" value="raise_window_key"/>
|
||||
<property name="<Primary><Alt>Home" type="string" value="move_window_prev_workspace_key"/>
|
||||
<property name="<Alt><Shift>Tab" type="string" value="cycle_reverse_windows_key"/>
|
||||
<property name="<Primary><Alt>Left" type="string" value="left_workspace_key"/>
|
||||
<property name="<Alt>F12" type="string" value="above_key"/>
|
||||
<property name="<Primary><Shift><Alt>Up" type="string" value="move_window_up_key"/>
|
||||
<property name="<Primary>F5" type="string" value="workspace_5_key"/>
|
||||
<property name="<Alt>F8" type="string" value="resize_window_key"/>
|
||||
<property name="<Primary><Alt>KP_7" type="string" value="move_window_workspace_7_key"/>
|
||||
<property name="<Primary><Alt>KP_2" type="string" value="move_window_workspace_2_key"/>
|
||||
<property name="<Super>KP_End" type="string" value="tile_down_left_key"/>
|
||||
<property name="<Primary><Alt>Up" type="string" value="up_workspace_key"/>
|
||||
<property name="<Alt>F9" type="string" value="hide_window_key"/>
|
||||
<property name="<Primary>F7" type="string" value="workspace_7_key"/>
|
||||
<property name="<Primary>F10" type="string" value="workspace_10_key"/>
|
||||
<property name="Left" type="string" value="left_key"/>
|
||||
<property name="<Primary><Alt>KP_8" type="string" value="move_window_workspace_8_key"/>
|
||||
<property name="<Alt>Insert" type="string" value="add_workspace_key"/>
|
||||
<property name="<Primary>F1" type="string" value="workspace_1_key"/>
|
||||
<property name="override" type="bool" value="true"/>
|
||||
</property>
|
||||
</property>
|
||||
<property name="providers" type="array">
|
||||
<value type="string" value="xfwm4"/>
|
||||
<value type="string" value="commands"/>
|
||||
</property>
|
||||
</channel>
|
||||
|
|
@ -2,17 +2,110 @@
|
|||
* For now this just hard copies the config file.
|
||||
* This can be improved by allowing users to define there own keybinds
|
||||
*/
|
||||
{ config, lib, ... }: let
|
||||
cfg = config.nixos95;
|
||||
in lib.mkIf cfg.enable {
|
||||
{ config, lib, pkgs, ... }: let
|
||||
cfg = config.nixos95.keybinds;
|
||||
t = lib.types;
|
||||
slib = pkgs.callPackage ./util/lib.nix { };
|
||||
in {
|
||||
|
||||
home-manager.users.${cfg.user} = {
|
||||
options.nixos95.keybinds = {
|
||||
commands = lib.mkOption {
|
||||
description = ''
|
||||
Keyboard shortcuts that should be made available.
|
||||
|
||||
xdg.configFile = {
|
||||
"xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml" = {
|
||||
force = true;
|
||||
source = ./dotfiles/xfce4-keyboard-shortcuts.xml;
|
||||
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 = "<Super>r";
|
||||
exe = "xfce4-appfinder --collapsed";
|
||||
}
|
||||
{
|
||||
key = "XF86WWW";
|
||||
exe = "exo-open --launch WebBrowser";
|
||||
}
|
||||
{
|
||||
key = "XF86Mail";
|
||||
exe = "exo-open --launch MailReder";
|
||||
}
|
||||
{
|
||||
key = "Print";
|
||||
exe = "xfce4-screenshooter";
|
||||
}
|
||||
];
|
||||
};
|
||||
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 '' <property name="${key}" type="string" value="${exe}"/> '')
|
||||
|> lib.concatStringsSep "\n";
|
||||
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 = ''
|
||||
<?xml version="1.1" encoding="UTF-8"?>
|
||||
|
||||
<channel name="xfce4-keyboard-shortcuts" version="1.0">
|
||||
<property name="commands" type="empty">
|
||||
<property name="custom" type="empty">
|
||||
<property name="override" type="bool" value="true" />
|
||||
${commands_xml}
|
||||
</property>
|
||||
</property>
|
||||
<property name="xfwm4" type="empty">
|
||||
<property name="custom" type="empty">
|
||||
<property name="override" type="bool" value="true" />
|
||||
${xfwm4_xml}
|
||||
</property>
|
||||
</property>
|
||||
<property name="providers" type="array">
|
||||
<value type="string" value="commands" />
|
||||
<value type="string" value="xfwm4" />
|
||||
</property>
|
||||
</channel>
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
cfg = config.nixos95.taskbar;
|
||||
user = config.nixos95.user;
|
||||
t = lib.types;
|
||||
slib = pkgs.callPackage ./util/lib.nix { };
|
||||
in {
|
||||
|
||||
options.nixos95.taskbar = {
|
||||
|
|
@ -108,14 +109,14 @@ in {
|
|||
battery_xml = ifBattery '' <property name="plugin-7" type="string" value="battery" /> '';
|
||||
|
||||
applications_cfg = cfg.applications
|
||||
|> lib.filter ( elm : !( lib.hasAttr "enable" elm) || elm.enable )
|
||||
|> lib.filter slib.isEnable
|
||||
|> lib.imap0 ( ptr : elm : rec {
|
||||
# we start IDs in the 20 range to not get confilics with other plugins
|
||||
plugin_id = "2" + builtins.toString ptr;
|
||||
plugin_desktop = let
|
||||
desc = if elm ? description then elm.description else "";
|
||||
term = if elm ? term && elm.term then "true" else "false";
|
||||
exec = if elm ? pkg then lib.getExe elm.pkg else elm.exe;
|
||||
exec = slib.getExe elm;
|
||||
in pkgs.writeTextFile {
|
||||
name = "${elm.name}.desktop";
|
||||
text = ''
|
||||
|
|
|
|||
6
nixos95/util/lib.nix
Normal file
6
nixos95/util/lib.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{ lib, ... }: {
|
||||
# return true if elm.enable is not set or elm.enable is true
|
||||
isEnable = elm : !( lib.hasAttr "enable" elm ) || elm.enable;
|
||||
# return executable path from elm.pkg if defined or elm.exe
|
||||
getExe = elm : if elm ? pkg then lib.getExe elm.pkg else elm.exe;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue