refactor(home:hyprland): move volume, brightness, powermenu --> tools
This commit is contained in:
		
							parent
							
								
									a6d5e892a1
								
							
						
					
					
						commit
						09504dbc89
					
				
					 9 changed files with 124 additions and 57 deletions
				
			
		|  | @ -1,5 +1,8 @@ | |||
| { | ||||
|   imports = [ | ||||
|     ./kdeconnect.nix | ||||
|     ./ookvolume.nix | ||||
|     ./ookbrightness.nix | ||||
|     ./zellijMenu.nix | ||||
|   ]; | ||||
| } | ||||
|  |  | |||
							
								
								
									
										45
									
								
								home/modules/desktop/tools/ookbrightness.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								home/modules/desktop/tools/ookbrightness.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| { lib, osConfig, pkgs, ... }: | ||||
| 
 | ||||
| let | ||||
|   inherit (lib) mkIf; | ||||
|   inherit (builtins) elem; | ||||
|   features = osConfig.ooknet.host.hardware.features; | ||||
|   ookbrightness = pkgs.writeShellApplication { | ||||
|     name = "ookbrightness"; | ||||
|     runtimeInputs = with pkgs; [brillo libnotify]; | ||||
|     text = /* bash */ '' | ||||
|       BRIGHTNESS=$(brillo -G | awk -F'.' '{print$1}') | ||||
|       notify() { | ||||
|         notify-send --app-name="system-notify" -h string:x-canonical-private-synchronous:sys-notify "  $BRIGHTNESS%" | ||||
|       } | ||||
|       option() { | ||||
|         case "$1" in | ||||
|         up) | ||||
|           brillo -q -u 30000 -A 5 | ||||
|           ;; | ||||
|         down) | ||||
|           brillo -q -u 30000 -U 5 | ||||
|           ;; | ||||
|         *) | ||||
|           echo "Invalid argument" | ||||
|           ;; | ||||
|         esac | ||||
|       } | ||||
|       main() { | ||||
|         option "$@" | ||||
|         notify | ||||
|       } | ||||
|       main "$@" | ||||
|     ''; | ||||
|   }; | ||||
| in | ||||
| 
 | ||||
| { | ||||
|   config = mkIf (elem "backlight" features) { | ||||
|     home.packages = [ ookbrightness ]; | ||||
|     ooknet.binds.brightness = { | ||||
|       up = "ookbrightness up"; | ||||
|       down = "ookbrightness down"; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										14
									
								
								home/modules/desktop/tools/ookpower.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								home/modules/desktop/tools/ookpower.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| { lib, config, inputs, pkgs, ... }: | ||||
| 
 | ||||
| let | ||||
|   inherit (lib) mkIf; | ||||
|   launcher = config.ooknet.wayland.launcher; | ||||
| in | ||||
| 
 | ||||
| 
 | ||||
| { | ||||
|   config = mkIf (launcher == "rofi") { | ||||
|     home.packages = [ inputs.ooks-scripts.packages.${pkgs.system}.powermenu ]; | ||||
|     ooknet.binds.powermenu = "powermenu -c dmenu"; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										47
									
								
								home/modules/desktop/tools/ookvolume.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								home/modules/desktop/tools/ookvolume.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,47 @@ | |||
| { lib, pkgs, osConfig, ... }: | ||||
| 
 | ||||
| let | ||||
|   inherit (lib) mkIf; | ||||
|   inherit (builtins) elem; | ||||
|   features = osConfig.ooknet.host.hardware.features; | ||||
|   ookvolume = pkgs.writeShellApplication { | ||||
|     name = "ookvolume"; | ||||
|     runtimeInputs = with pkgs; [pamixer libnotify]; | ||||
|     text = '' | ||||
|       notify() { | ||||
|         volume=$(pamixer --get-volume-human) | ||||
|         notify-send --app-name="system-notify" -h string:x-canonical-private-synchronous:sys-notify " $volume" | ||||
|       } | ||||
|       option() { | ||||
|         case "$1" in | ||||
|         up) | ||||
|           pamixer --increase 5 | ||||
|           ;; | ||||
|         down) | ||||
|           pamixer --decrease 5 | ||||
|           ;; | ||||
|         mute) | ||||
|           pamixer --toggle-mute | ||||
|           ;; | ||||
|         *) echo "Invalid option" ;; | ||||
|         esac | ||||
|       } | ||||
|       main() { | ||||
|         option "$@" | ||||
|         notify | ||||
|       } | ||||
|       main "$@" | ||||
|     ''; | ||||
|   }; | ||||
| in | ||||
| 
 | ||||
| { | ||||
|   config = mkIf (elem "audio" features) { | ||||
|     home.packages = [ ookvolume ]; | ||||
|     ooknet.binds.volume = { | ||||
|       up = "ookvolume up"; | ||||
|       down = "ookvolume down"; | ||||
|       mute = "ookvolume mute"; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										14
									
								
								home/modules/desktop/tools/zellijMenu.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								home/modules/desktop/tools/zellijMenu.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| { lib, config, inputs, pkgs, ... }: | ||||
| 
 | ||||
| let | ||||
|   inherit (lib) mkIf; | ||||
|   multiplexer = config.ooknet.console.multiplexer; | ||||
|   launcher = config.ooknet.wayland.launcher; | ||||
| in | ||||
| 
 | ||||
| { | ||||
|   config = mkIf (multiplexer == "zellij" && launcher == "rofi") { | ||||
|     home.packages = [ inputs.ooks-scripts.packages.${pkgs.system}.zellijmenu ]; | ||||
|     ooknet.binds.zellijMenu = "zellijMenu -n"; | ||||
|   }; | ||||
| } | ||||
|  | @ -1,8 +1,6 @@ | |||
| { lib, config, pkgs, inputs, ... }:  | ||||
| { lib, config, pkgs, ... }:  | ||||
| let | ||||
|   wayland = config.ooknet.wayland; | ||||
|   inherit (import ./pkgs {inherit pkgs;}) hyprbrightness hyprvolume; | ||||
|   inherit (inputs.ooks-scripts.packages.${pkgs.system}) powermenu zellijmenu; | ||||
|   inherit (lib) mkIf; | ||||
| in | ||||
| { | ||||
|  | @ -15,12 +13,6 @@ in | |||
|   config = mkIf (wayland.compositor == "hyprland") { | ||||
|     home.packages = [ | ||||
|       pkgs.hyprpicker | ||||
|       hyprvolume | ||||
|       hyprbrightness | ||||
| 
 | ||||
|       # Personal scripts | ||||
|       powermenu | ||||
|       zellijmenu #TODO: only add if zellij enabled | ||||
|       ]; | ||||
|      | ||||
|     wayland.windowManager.hyprland = { | ||||
|  |  | |||
|  | @ -1,9 +0,0 @@ | |||
| { pkgs, ... }: | ||||
| 
 | ||||
| let | ||||
|   packages = { | ||||
|     hyprvolume = pkgs.callPackage ./hyprvolume.nix {}; | ||||
|     hyprbrightness = pkgs.callPackage ./hyprbrightness.nix {}; | ||||
|   }; | ||||
| in | ||||
|   packages | ||||
|  | @ -1,20 +0,0 @@ | |||
| { pkgs, ... }: | ||||
| 
 | ||||
| pkgs.writeShellApplication { | ||||
|   name = "hyprbrightness"; | ||||
|   runtimeInputs = with pkgs; [brillo libnotify]; | ||||
|   text = '' | ||||
|     if [ "$1" == "up" ]; then | ||||
|       brillo -q -u 30000 -A 5 | ||||
|     elif [ "$1" == "down" ]; then | ||||
|       brillo -q -u 30000 -U 5 | ||||
|     else | ||||
|       echo "Invalid argument" | ||||
|       exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     BRIGHTNESS=$(brillo -G | awk -F'.' '{print$1}') | ||||
| 
 | ||||
|     notify-send --app-name="system-notify" -h string:x-canonical-private-synchronous:sys-notify "  $BRIGHTNESS%" | ||||
|   ''; | ||||
| } | ||||
|  | @ -1,19 +0,0 @@ | |||
| { pkgs, ... }: | ||||
| 
 | ||||
| pkgs.writeShellApplication { | ||||
|   name = "hyprvolume"; | ||||
|   runtimeInputs = with pkgs; [pamixer libnotify]; | ||||
|   text = '' | ||||
|     if [ "$1" == "up" ]; then | ||||
|       pamixer --increase 5 | ||||
|     elif [ "$1" == "down" ]; then | ||||
|       pamixer --decrease 5 | ||||
|     elif [ "$1" == "mute" ]; then | ||||
|       pamixer --toggle-mute | ||||
|     fi | ||||
| 
 | ||||
|     VOLUME=$(pamixer --get-volume-human) | ||||
| 
 | ||||
|     notify-send --app-name="system-notify" -h string:x-canonical-private-synchronous:sys-notify " $VOLUME" | ||||
|   ''; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue