diff --git a/hosts/laptop/default.nix b/hosts/laptop/default.nix index a45cdb5..c683832 100644 --- a/hosts/laptop/default.nix +++ b/hosts/laptop/default.nix @@ -74,6 +74,15 @@ i3 = { enable = true; battery = true; + mediaKeys = { + musicMenu = "F5"; + musicPlay = "F10"; + musicPrev = "F9"; + musicNext = "F11"; + audioMute = "F6"; + audioDown = "F7"; + audioUp = "F8"; + }; }; gaming = { diff --git a/modules/stuff/i3.nix b/modules/stuff/i3.nix index 683d009..0d6b46a 100644 --- a/modules/stuff/i3.nix +++ b/modules/stuff/i3.nix @@ -25,6 +25,22 @@ in { default = {}; }; battery = mkEnableOption "battery"; + mediaKeys = mkOption { + type = types.submodule { + options = let + mkKeyOpt = default: mkOption { inherit default; type = types.str; }; + in { + musicMenu = mkKeyOpt "F5"; + musicPlay = mkKeyOpt "F7"; + musicPrev = mkKeyOpt "F6"; + musicNext = mkKeyOpt "F8"; + audioMute = mkKeyOpt "F9"; + audioDown = mkKeyOpt "F10"; + audioUp = mkKeyOpt "F11"; + }; + }; + default = {}; + }; }; config = let @@ -122,7 +138,7 @@ in { modifier = "Mod4"; floating.modifier = "Mod4"; - keybindings = let + keybindings = with config.chuj.stuff.i3.mediaKeys; let mod = modifier; execns = "exec --no-startup-id"; cmd_and_center = cmd: "${execns} i3-msg '${cmd}' && i3custom-center-mouse-on-focus"; @@ -138,9 +154,9 @@ in { "--release ${mod}+k" = "${execns} xkill"; # Volume control - "Ctrl+F9" = "${execns} pamixer --toggle-mute && ${update_i3status}"; - "Ctrl+F10" = "${execns} pamixer --decrease 5 && ${update_i3status}"; - "Ctrl+F11" = "${execns} pamixer --increase 5 && ${update_i3status}"; + "Ctrl+${audioMute}" = "${execns} pamixer --toggle-mute && ${update_i3status}"; + "Ctrl+${audioDown}" = "${execns} pamixer --decrease 5 && ${update_i3status}"; + "Ctrl+${audioUp}" = "${execns} pamixer --increase 5 && ${update_i3status}"; # General i3 keybindings "${mod}+f" = cmd_and_center "fullscreen toggle"; @@ -190,15 +206,15 @@ in { "${mod}+Shift+0" = cmd_and_center "move container to workspace number 10"; } (optionalAttrs config.chuj.stuff.mpd.enable { # MPD controls - "Ctrl+F5" = "exec mpdfdial.sh && ${update_mpdstatus} && ${update_i3status}"; - "Ctrl+F6" = "exec mpc prev && ${update_mpdstatus} && ${update_i3status}"; - "Ctrl+F7" = "exec mpc toggle && ${update_mpdstatus} && ${update_i3status}"; - "Ctrl+F8" = "exec mpc next && ${update_mpdstatus} && ${update_i3status}"; - "Ctrl+Shift+F6" = "exec mpc seek -3"; - "Ctrl+Shift+F7" = "exec mpc clear && ${update_mpdstatus} && ${update_i3status}"; - "Ctrl+Shift+F8" = "exec mpc seek +3"; - "Ctrl+Shift+F10" = ''exec mpc volume -5 && dunstify "mpc $(mpc volume)" -r 420''; - "Ctrl+Shift+F11" = ''exec mpc volume +5 && dunstify "mpc $(mpc volume)" -r 420''; + "Ctrl+${musicMenu}" = "exec mpdfdial.sh && ${update_mpdstatus} && ${update_i3status}"; + "Ctrl+${musicPrev}" = "exec mpc prev && ${update_mpdstatus} && ${update_i3status}"; + "Ctrl+${musicPlay}" = "exec mpc toggle && ${update_mpdstatus} && ${update_i3status}"; + "Ctrl+${musicNext}" = "exec mpc next && ${update_mpdstatus} && ${update_i3status}"; + "Ctrl+Shift+${musicPrev}" = "exec mpc seek -3"; + "Ctrl+Shift+${musicPlay}" = "exec mpc clear && ${update_mpdstatus} && ${update_i3status}"; + "Ctrl+Shift+${musicNext}" = "exec mpc seek +3"; + "Ctrl+Shift+${audioDown}" = ''exec mpc volume -5 && dunstify "mpc $(mpc volume)" -r 420''; + "Ctrl+Shift+${audioUp}" = ''exec mpc volume +5 && dunstify "mpc $(mpc volume)" -r 420''; }); bars = [