refactor(home:binds): make mkBind function to simplify expression
This commit is contained in:
		
							parent
							
								
									09504dbc89
								
							
						
					
					
						commit
						5f03166886
					
				
					 3 changed files with 43 additions and 71 deletions
				
			
		|  | @ -3,6 +3,7 @@ | |||
|     ./kdeconnect.nix | ||||
|     ./ookvolume.nix | ||||
|     ./ookbrightness.nix | ||||
|     ./ookpower.nix | ||||
|     ./zellijMenu.nix | ||||
|   ]; | ||||
| } | ||||
|  |  | |||
|  | @ -1,39 +1,27 @@ | |||
| { lib, config, pkgs, ... }:  | ||||
| { lib, config, ... }:  | ||||
| 
 | ||||
| let | ||||
|   inherit (lib) mkIf; | ||||
|   wayland = config.ooknet.wayland; | ||||
|   binds = config.ooknet.binds; | ||||
| in | ||||
| 
 | ||||
| { | ||||
|   config = mkIf (wayland.compositor == "hyprland") { | ||||
|     wayland.windowManager.hyprland.settings = { | ||||
|       bind = let | ||||
|         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 [ | ||||
| 
 | ||||
|       bind = [ | ||||
|         # Program Launch | ||||
|         "SUPER,          b,             exec,     ${browser}" | ||||
|         "SUPER,          return,        exec,     ${terminal}" | ||||
|         "SUPER,          e,             exec,     ${terminal} ${editor}" | ||||
|         "SUPERSHIFT,     P,             exec,     ${password}" | ||||
|         "SUPER,          d,             exec,     ${discord}" | ||||
|         "SUPERSHIFT,     e,             exec,     ${explorer}" | ||||
|         "SUPERSHIFT,     S,             exec,     steam" | ||||
|         "SUPER,          escape,        exec,     ${terminal} --title=BTOP btop" | ||||
|         "SUPER CTRL,     return,        exec,     zellijmenu -n" | ||||
|         "SUPER,          b,             exec,     ${binds.browser}" | ||||
|         "SUPER,          return,        exec,     ${binds.terminal}" | ||||
|         "SUPER,          e,             exec,     ${binds.terminalLaunch} $EDITOR" | ||||
|         "SUPERSHIFT,     P,             exec,     ${binds.password}" | ||||
|         "SUPER,          d,             exec,     ${binds.discord}" | ||||
|         "SUPERSHIFT,     e,             exec,     ${binds.fileManager}" | ||||
|         "SUPERSHIFT,     S,             exec,     ${binds.steam}" | ||||
|         "SUPER,          escape,        exec,     ${binds.terminalLaunch} --title=BTOP btop" | ||||
|         "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" | ||||
| 
 | ||||
|         # Lock Screen | ||||
|         "SUPER,          Backspace,     exec,     ${locker}" | ||||
|         "SUPER,          Backspace,     exec,     ${binds.lock}" | ||||
|       ]; | ||||
|         # Mouse | ||||
|       bindm = [ | ||||
|  |  | |||
|  | @ -1,56 +1,39 @@ | |||
| { lib, ... }: | ||||
| { lib, pkgs, ... }: | ||||
| 
 | ||||
| let | ||||
|   inherit (lib) mkOption types; | ||||
|   inherit (types) str; | ||||
|   mkWarn = message: "notify-send --urgency=normal 'warning' '${message}'"; | ||||
|   mkBind = message: lib.mkOption { | ||||
|     type = lib.types.str; | ||||
|     default = "${pkgs.libnotify}/bin/notify-send --urgency=normal 'Warning' '${message}'"; | ||||
|   }; | ||||
| in | ||||
| 
 | ||||
| { | ||||
|   options.ooknet.binds = { | ||||
|     browser = mkOption { | ||||
|       type = str; | ||||
|       default = mkWarn "No browser is enabled"; | ||||
|     browser = mkBind "No browser is enabled"; | ||||
|     terminal = mkBind "No terminal 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..."; | ||||
|     }; | ||||
| 
 | ||||
|     terminal = mkOption { | ||||
|       type = str; | ||||
|       default = mkWarn "No terminal is enabled"; | ||||
|     brightness = { | ||||
|       up = mkBind "Brightness binding not found..."; | ||||
|       down = mkBind "Brightness binding not found..."; | ||||
|     }; | ||||
| 
 | ||||
|     terminalLaunch = mkOption { | ||||
|       type = str; | ||||
|       default = mkWarn "Failed to launch tui"; | ||||
|     }; | ||||
| 
 | ||||
|     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"; | ||||
|     spotify = { | ||||
|       launch = mkBind "Spotify is not enabled"; | ||||
|       next = mkBind "Spotify is not enabled"; | ||||
|       previous = mkBind "Spotify is not enabled"; | ||||
|       play = mkBind "Spotify is not enabled"; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue