mirror of
				https://github.com/ItsDrike/dotfiles.git
				synced 2025-11-04 09:16:36 +00:00 
			
		
		
		
	Add trayer applet to lemonbar
This commit is contained in:
		
							parent
							
								
									e412aba38e
								
							
						
					
					
						commit
						5f65b8d756
					
				
					 2 changed files with 39 additions and 2 deletions
				
			
		
							
								
								
									
										36
									
								
								home/.config/lemonbar/applet-trayer
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								home/.config/lemonbar/applet-trayer
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# Generates whitespace in the bar based on the width
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PANEL_FIFO="$1"
 | 
				
			||||||
 | 
					PREFIX="$2"
 | 
				
			||||||
 | 
					MONITOR="$3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exec 5>"$PANEL_FIFO"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					main() {
 | 
				
			||||||
 | 
					    size="$1"
 | 
				
			||||||
 | 
					    # Trayer should always be on primary monitor
 | 
				
			||||||
 | 
					    # TODO: If possible, it would be better to get the monitor trayer lives on dynamically
 | 
				
			||||||
 | 
					    trayer_mon="$(bspc query -M -m primary --names)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [[ "$trayer_mon" != "$MONITOR" ]]; then
 | 
				
			||||||
 | 
					        RESULT="%{O0}"
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        RESULT="%{O$size}"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{print init; stdbuf -oL xprop -name panel -f WM_SIZE_HINTS 32i ' $5\n' -spy WM_NORMAL_HINTS} | while read line; do
 | 
				
			||||||
 | 
					    case ${line} in
 | 
				
			||||||
 | 
					        init)
 | 
				
			||||||
 | 
					            size="$(xprop -name panel -f WM_SIZE_HINTS 32i ' $5\n' WM_NORMAL_HINTS | cut -d' ' -f 2)"
 | 
				
			||||||
 | 
					            main "$size"
 | 
				
			||||||
 | 
					            print "$PREFIX $RESULT" >&5
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					        *)
 | 
				
			||||||
 | 
					            size="$(echo "$line" | cut -d' ' -f 2)"
 | 
				
			||||||
 | 
					            main "$size"
 | 
				
			||||||
 | 
					            print "$PREFIX $RESULT" >&5
 | 
				
			||||||
 | 
					            ;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ SEPARATOR=("%{F#50FFFFFF} | %{F-}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LEFT_MODULES=("title" "workspaces" "windowname")
 | 
					LEFT_MODULES=("title" "workspaces" "windowname")
 | 
				
			||||||
CENTER_MODULES=()
 | 
					CENTER_MODULES=()
 | 
				
			||||||
RIGHT_MODULES=("kernel" "battery" "memory" "storage" "cpu" "volume" "uptime" "bitcoin" "time")
 | 
					RIGHT_MODULES=("kernel" "battery" "memory" "storage" "cpu" "volume" "uptime" "bitcoin" "time" "trayer")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typeset -A CMDS
 | 
					typeset -A CMDS
 | 
				
			||||||
CMDS[volup]="pulsemixer --change-volume +3"
 | 
					CMDS[volup]="pulsemixer --change-volume +3"
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@ SUFFIX[windowname]="%{F-}"
 | 
				
			||||||
#SUFFIX[title]="%{F-}"
 | 
					#SUFFIX[title]="%{F-}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Don't escape % signs in these modules (they define their own colors)
 | 
					# Don't escape % signs in these modules (they define their own colors)
 | 
				
			||||||
NO_ESCAPE=("workspaces")
 | 
					NO_ESCAPE=("workspaces" "trayer")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Unique WM_NAME of the panel
 | 
					# Unique WM_NAME of the panel
 | 
				
			||||||
| 
						 | 
					@ -107,6 +107,7 @@ run_applet "storage" "storage" 60 "/;/home" ";"
 | 
				
			||||||
run_applet "battery" "battery" 5 ";;;;"
 | 
					run_applet "battery" "battery" 5 ";;;;"
 | 
				
			||||||
run_applet "window" "windowname" 5 65
 | 
					run_applet "window" "windowname" 5 65
 | 
				
			||||||
run_applet "workspaces" "workspaces"
 | 
					run_applet "workspaces" "workspaces"
 | 
				
			||||||
 | 
					run_applet "trayer" "trayer" "$MONITOR"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ---- DYNAMIC CONFIGURATION ----
 | 
					# ---- DYNAMIC CONFIGURATION ----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue