refactor(home:binds): make mkBind function to simplify expression

This commit is contained in:
ooks-io 2024-06-09 17:14:01 +12:00
parent 09504dbc89
commit 5f03166886
3 changed files with 43 additions and 71 deletions

View file

@ -3,6 +3,7 @@
./kdeconnect.nix ./kdeconnect.nix
./ookvolume.nix ./ookvolume.nix
./ookbrightness.nix ./ookbrightness.nix
./ookpower.nix
./zellijMenu.nix ./zellijMenu.nix
]; ];
} }

View file

@ -1,39 +1,27 @@
{ lib, config, pkgs, ... }: { lib, config, ... }:
let let
inherit (lib) mkIf; inherit (lib) mkIf;
wayland = config.ooknet.wayland; wayland = config.ooknet.wayland;
binds = config.ooknet.binds;
in in
{ {
config = mkIf (wayland.compositor == "hyprland") { config = mkIf (wayland.compositor == "hyprland") {
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
bind = let bind = [
terminal = config.home.sessionVariables.TERMINAL;
browser = config.home.sessionVariables.BROWSER;
editor = config.home.sessionVariables.EDITOR;
locker = config.home.sessionVariables.LOCKER;
spotifyctl = "${pkgs.spotify-player}/bin/spotify_player";
discord = "${pkgs.vesktop}/bin/vesktop";
explorer = "${pkgs.cinnamon.nemo-with-extensions}/bin/nemo";
password = "${pkgs._1password-gui}/bin/1password";
in [
# Program Launch # Program Launch
"SUPER, b, exec, ${browser}" "SUPER, b, exec, ${binds.browser}"
"SUPER, return, exec, ${terminal}" "SUPER, return, exec, ${binds.terminal}"
"SUPER, e, exec, ${terminal} ${editor}" "SUPER, e, exec, ${binds.terminalLaunch} $EDITOR"
"SUPERSHIFT, P, exec, ${password}" "SUPERSHIFT, P, exec, ${binds.password}"
"SUPER, d, exec, ${discord}" "SUPER, d, exec, ${binds.discord}"
"SUPERSHIFT, e, exec, ${explorer}" "SUPERSHIFT, e, exec, ${binds.fileManager}"
"SUPERSHIFT, S, exec, steam" "SUPERSHIFT, S, exec, ${binds.steam}"
"SUPER, escape, exec, ${terminal} --title=BTOP btop" "SUPER, escape, exec, ${binds.terminalLaunch} --title=BTOP btop"
"SUPER CTRL, return, exec, zellijmenu -n" "SUPER CTRL, return, exec, ${binds.zellijMenu}"
"SUPER, delete, exec, powermenu -c dmenu" "SUPER, delete, exec, ${binds.powermenu} -c dmenu"
@ -116,7 +104,7 @@ in
"SUPERSHIFT, 0, movetoworkspace,10" "SUPERSHIFT, 0, movetoworkspace,10"
# Lock Screen # Lock Screen
"SUPER, Backspace, exec, ${locker}" "SUPER, Backspace, exec, ${binds.lock}"
]; ];
# Mouse # Mouse
bindm = [ bindm = [

View file

@ -1,56 +1,39 @@
{ lib, ... }: { lib, pkgs, ... }:
let let
inherit (lib) mkOption types; mkBind = message: lib.mkOption {
inherit (types) str; type = lib.types.str;
mkWarn = message: "notify-send --urgency=normal 'warning' '${message}'"; default = "${pkgs.libnotify}/bin/notify-send --urgency=normal 'Warning' '${message}'";
};
in in
{ {
options.ooknet.binds = { options.ooknet.binds = {
browser = mkOption { browser = mkBind "No browser is enabled";
type = str; terminal = mkBind "No terminal is enabled";
default = mkWarn "No browser is enabled"; terminalLaunch = mkBind "Failed to launch tui";
fileManager = mkBind "No file manager is enabled.";
notes = mkBind "No Notes app is enabled";
discord = mkBind "No Discord app is enabled";
steam = mkBind "Steam is not enabled";
powerMenu = mkBind "No power menu is enabled";
lock = mkBind "No screen locker enabled";
password = mkBind "No password manager enabled";
zellijMenu = mkBind "Zellij Menu is not enabled";
volume = {
up = mkBind "Volume binding not found...";
down = mkBind "Volume binding not found...";
mute = mkBind "Volume binding not found...";
}; };
brightness = {
terminal = mkOption { up = mkBind "Brightness binding not found...";
type = str; down = mkBind "Brightness binding not found...";
default = mkWarn "No terminal is enabled";
}; };
spotify = {
terminalLaunch = mkOption { launch = mkBind "Spotify is not enabled";
type = str; next = mkBind "Spotify is not enabled";
default = mkWarn "Failed to launch tui"; previous = mkBind "Spotify is not enabled";
}; play = mkBind "Spotify is not enabled";
fileManager = mkOption {
type = str;
default = mkWarn "No file manager is enabled.";
};
notes = mkOption {
type = str;
default = mkWarn "No notes app is enabled";
};
discord = mkOption {
type = str;
default = mkWarn "No discord app is enabled";
};
steam = mkOption {
type = str;
default = mkWarn "Steam is not enabled";
};
powerMenu = mkOption {
type = str;
default = mkWarn "No power menu is enabled";
};
locker = mkOption {
type = str;
default = mkWarn "No screen locker enabled";
}; };
}; };
} }