waybar: add controller battery status
This commit is contained in:
		
							parent
							
								
									4d6d6357e3
								
							
						
					
					
						commit
						62379e3a62
					
				
					 4 changed files with 47 additions and 0 deletions
				
			
		
							
								
								
									
										38
									
								
								scripts/controller-battery
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										38
									
								
								scripts/controller-battery
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CONTROLLER=$(find /sys/class/power_supply -maxdepth 1 -name '*controller*' || true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if test -z "$CONTROLLER"; then
 | 
				
			||||||
 | 
					    echo
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CAPACITY=$(cat "$CONTROLLER/capacity")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo -n ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if test "$CAPACITY" -ge 90; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 90; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 80; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 70; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 60; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 50; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 40; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 30; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 20; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					elif test "$CAPACITY" -ge 10; then
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    echo ''
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -130,6 +130,7 @@
 | 
				
			||||||
      libratbag
 | 
					      libratbag
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
    vrr-fullscreen = [ ];
 | 
					    vrr-fullscreen = [ ];
 | 
				
			||||||
 | 
					    controller-battery = [ ];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // lib.mapAttrs importScript {
 | 
					  // lib.mapAttrs importScript {
 | 
				
			||||||
    wdmenu = ./wdmenu.nix;
 | 
					    wdmenu = ./wdmenu.nix;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@ in
 | 
				
			||||||
            "mpd"
 | 
					            "mpd"
 | 
				
			||||||
            "custom/playerctl"
 | 
					            "custom/playerctl"
 | 
				
			||||||
            "tray"
 | 
					            "tray"
 | 
				
			||||||
 | 
					            "custom/controller-battery"
 | 
				
			||||||
            "custom/caffeine"
 | 
					            "custom/caffeine"
 | 
				
			||||||
            "pulseaudio"
 | 
					            "pulseaudio"
 | 
				
			||||||
            (lib.optional (osConfig.services.vpn.enable or false) "custom/vpn")
 | 
					            (lib.optional (osConfig.services.vpn.enable or false) "custom/vpn")
 | 
				
			||||||
| 
						 | 
					@ -157,6 +158,12 @@ in
 | 
				
			||||||
          "sway/language" = {
 | 
					          "sway/language" = {
 | 
				
			||||||
            format = "{short} {variant}";
 | 
					            format = "{short} {variant}";
 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
 | 
					          "custom/controller-battery" = {
 | 
				
			||||||
 | 
					            format = "{}";
 | 
				
			||||||
 | 
					            exec = lib.getExe pkgs.controller-battery;
 | 
				
			||||||
 | 
					            interval = 1;
 | 
				
			||||||
 | 
					            tooltip = false;
 | 
				
			||||||
 | 
					          };
 | 
				
			||||||
          "custom/caffeine" = {
 | 
					          "custom/caffeine" = {
 | 
				
			||||||
            format = "{}";
 | 
					            format = "{}";
 | 
				
			||||||
            exec = "systemctl --user status swayidle > /dev/null && echo  || echo ";
 | 
					            exec = "systemctl --user status swayidle > /dev/null && echo  || echo ";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,6 +37,7 @@ window#waybar.solo {
 | 
				
			||||||
#mpd,
 | 
					#mpd,
 | 
				
			||||||
#custom-mpd,
 | 
					#custom-mpd,
 | 
				
			||||||
#custom-playerctl,
 | 
					#custom-playerctl,
 | 
				
			||||||
 | 
					#custom-controller-battery,
 | 
				
			||||||
#tray,
 | 
					#tray,
 | 
				
			||||||
#clock,
 | 
					#clock,
 | 
				
			||||||
#network,
 | 
					#network,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue