Scriptable lightweight panel for bspwm with lemonbar

plus the rofi-menu should be a perfect icing on the cake !

That is definately planned addition as limepanel mainmenu

2 Likes

@rvc

Ctrl+Tab, Ctrl+Shift+Tab also work

1 Like

Also notice, that .simplepanelrc is a shell script, so you can add there a check what window manager is running and set panel modules string according to that.

if [ "$(wmctrl -m|sed -n '/Name: /s///p')" = "bspwm" ]; then
    desktops_module="sp_bspwm"
fi
sp_modules="
	sp_main_menu
	sp_separator_l
	$desktops_module
	...
"
1 Like

for ease of naming sake, i edited to wm_module [instead of desktops_module]
perhaps this convention can be elaborated to load respective modules while checking ?
say i3 / openbox / fluxbox / hlwm / xmonad(?) etc....

1 Like

waiting for pkg update :slight_smile:

@kainonergon
i am exploring usage of simplepanel [same config as bspwm i currently use but copy same as obpanelrc so i can edit and explore]. i try simple method to label the 4 workspaces and place it in lieu of "sp_bspwm", but not showing up !. if i can get it, then perhaps clickable option to switch workspace can be managed....?
as openbox is ewmh compatible, i felt i can use "wmctrl" to get workspace name ?

wmctrl -d and then some cut or sed will do.

wmctrl -s N can switch to desktop number N.
Maybe xdotool can be usefull too.

iinitial steps i just wish to list WS1 / 2 e/3/4.
then i wish to make it clickable.

BTW, when i add sp_workspaces in sp_modules, panel fails to list the workspaces. [i run openbox autostart with "simplepanel --config ~/.obpanelrc" so the bspwm version is safe]
Screenshot_2018-03-27_21-54-07

EDIT: another help !
on bspwm rofimenu, i need to edit Browser part [nothing happens on click]
i issue "export BROWSER=chromium.desktop" still bspwm cant set default browser

I fear this feature is not implemented. Simplepanel just uses ~/.simplepanelrc. Maybe I should add it when I have time.

1 Like

@kainonergon
i did this in panelrc

# workspace names for non-bspwm
sp_workspaces()
{
	
	ws_icon_1="%{T3}%{F#ffffccaa}${SP}${i_fa_ws1}${SP}%{F-}%{T1}${SP}"
	ws_icon_2="%{T3}%{F#ffffccaa}${SP}${i_fa_ws2}${SP}%{F-}%{T1}${SP}"
	ws_icon_3="%{T3}%{F#ffffccaa}${SP}${i_fa_ws3}${SP}%{F-}%{T1}${SP}"
	ws_icon_4="%{T3}%{F#ffffccaa}${SP}${i_fa_ws4}${SP}%{F-}%{T1}${SP}"

		workspaces="[$ws_icon_1] [$ws_icon_2] [$ws_icon_3] [$ws_icon_4]"

		echo "$workspaces" 
}

AND....

# check running windowmanager
if [ "$(wmctrl -m|sed -n '/Name: /s///p')" = "bspwm" ]; then
    wm_module="sp_bspwm"      
fi

if [ "$(wmctrl -m|sed -n '/Name: /s///p')" = "Openbox" ]; then
    wm_module="sp_workspaces"      
fi


sp_modules="
sp_main_menu
sp_separator
$wm_module
....
....

panel not returning any error but in openbox, the panel does not display the WS names !
perhaps if names are displayed then clickable option can be given?

Try to check your commands from command line and see if they work as expected. Begin with simple module that just prints some text. Check that if does what you expect. In short, debug it.

1 Like

was working in command... missed out the syntax in echo "$workspaces", i read your first part of rc file, then edited to echo "$1:$workspaces" and that did it !
thank you for pointing me !

now i will check for active workspace to be highlighted !

1 Like

added [W I P] openbox module

sp_obox()
{

while true ; do

 if [ "$(xdotool get_desktop)" = "0" ]; then
    ws_icon_1="%{T3}%{F#ff00cc99}${i_fa_ws1}%{F-}%{T1}"  
    ws_icon_2="%{T3}%{F#ffb87333}${i_fa_ws2}%{F-}%{T1}"
    ws_icon_3="%{T3}%{F#ffb87333}${i_fa_ws3}%{F-}%{T1}"
    ws_icon_4="%{T3}%{F#ffb87333}${i_fa_ws4}%{F-}%{T1}"      
 fi

 if [ "$(xdotool get_desktop)" = "1" ]; then
    ws_icon_1="%{T3}%{F#ffb87333}${i_fa_ws1}%{F-}%{T1}"  
    ws_icon_2="%{T3}%{F#ff00cc99}${i_fa_ws2}%{F-}%{T1}"
    ws_icon_3="%{T3}%{F#ffb87333}${i_fa_ws3}%{F-}%{T1}"
    ws_icon_4="%{T3}%{F#ffb87333}${i_fa_ws4}%{F-}%{T1}"      
 fi

 if [ "$(xdotool get_desktop)" = "2" ]; then
    ws_icon_1="%{T3}%{F#ffb87333}${i_fa_ws1}%{F-}%{T1}"  
    ws_icon_2="%{T3}%{F#ffb87333}${i_fa_ws2}%{F-}%{T1}"
    ws_icon_3="%{T3}%{F#ff00cc99}${i_fa_ws3}%{F-}%{T1}"
    ws_icon_4="%{T3}%{F#ffb87333}${i_fa_ws4}%{F-}%{T1}"      
 fi

 if [ "$(xdotool get_desktop)" = "3" ]; then
    ws_icon_1="%{T3}%{F#ffb87333}${i_fa_ws1}%{F-}%{T1}"  
    ws_icon_2="%{T3}%{F#ffb87333}${i_fa_ws2}%{F-}%{T1}"
    ws_icon_3="%{T3}%{F#ffb87333}${i_fa_ws3}%{F-}%{T1}"
    ws_icon_4="%{T3}%{F#ff00cc99}${i_fa_ws4}%{F-}%{T1}"      
 fi
	  	
		workspaces="[$ws_icon_1] [$ws_icon_2] [$ws_icon_3] [$ws_icon_4]"

		echo "$1:$workspaces${SEPARATOR_L}"
	sleep "$UPD_INT"
done
}

manually switching desktop works ... now clicable function to add....

sp_modules update....

.......
......
# check running windowmanager
if [ "$(wmctrl -m|sed -n '/Name: /s///p')" = "bspwm" ]; then
    wm_module="sp_bspwm"      
fi

if [ "$(wmctrl -m|sed -n '/Name: /s///p')" = "Openbox" ]; then
    wm_module="sp_obox"      
fi


sp_modules="
sp_main_menu
sp_separator
$wm_module
sp_title
......
......

icon define for workspaces

i='1:♚' i_fa_ws1=$i
i='2:♛' i_fa_ws2=$i
i='3:♜' i_fa_ws3=$i
i='4:♞' i_fa_ws4=$i

OBPANEL_1OBpanel_2

EDIT: sp_button_close perhaps needs attention as bspc close wont work in other WMs

1 Like

xdo close should work

Maybe later I will rewrite simplepanel so that it is less dependent on bspwm.

1 Like

will try out....
And yes, simplepanel [autostart] should be delayed by say 10-15 seconds. once WM loads, then the module identifies the WM and loads respective module.... if no delay, then previously loaded (cached (?)) module loads and it has to be restarted.

EDIT: xdo close works fine in bspwm :+1:. so only WM specific modules [to display workspaces] should suffice...

whenever updated, wil be nice if packaged so it can be installed thru pacman and user config @ $HOME :+1:

1 Like

@kainonergon

i updated the sp_obox as below [to have individual clickable option [?]

sp_obox()
{

while true ; do

 if [ "$(xdotool get_desktop)" = "0" ]; then
    ws_icon_1="%{T3}%{F#ff37d2b5}${i_fa_ws1}%{F-}%{T1}"
else
    ws_icon_1="%{T3}%{F#ffd1b536}${i_fa_ws1}%{F-}%{T1}"
 fi

 if [ "$(xdotool get_desktop)" = "1" ]; then
    ws_icon_2="%{T3}%{F#ff37d2b5}${i_fa_ws2}%{F-}%{T1}" 
else
    ws_icon_2="%{T3}%{F#ffd1b536}${i_fa_ws2}%{F-}%{T1}"    
 fi

 if [ "$(xdotool get_desktop)" = "2" ]; then
    ws_icon_3="%{T3}%{F#ff37d2b5}${i_fa_ws3}%{F-}%{T1}"  
else
    ws_icon_3="%{T3}%{F#ffd1b536}${i_fa_ws3}%{F-}%{T1}"   
 fi

 if [ "$(xdotool get_desktop)" = "3" ]; then
    ws_icon_4="%{T3}%{F#ff37d2b5}${i_fa_ws4}%{F-}%{T1}"  
else
    ws_icon_4="%{T3}%{F#ffd1b536}${i_fa_ws4}%{F-}%{T1}"
 fi

	workspaces="[ $ws_icon_1 | $ws_icon_2 | $ws_icon_3 | $ws_icon_4 ]"

	echo "$1:$workspaces${SEPARATOR_L}"

	sleep "$UPD_INT"
done
}

Now for clickable option, do i need to add options with in this loop [ if yes, then i am cluless on how and where i start] as

click "1" "wmctrl -s [0/1/2/3]" (depending on which icon i click ws_icon_1/2/3/4)
i tried within my limited understanding but could not get result...

For a panel script, it would be more efficient to use case statement instead of multiple if statements. On panel script performance actually matters, since it runs constantly in while loop.

I can help you with that after work.

2 Likes

thank you... i understand but as i am not code savvy, i knew it has to be polished.... but i didnt know how !

I did notice....
when i start bspwm from login, after all my bg startups like compositor, mpd etc.... its ~250MB usage and in openbox, its ~335MB usage. perhaps its the while loop for workspaces thats running periodically !

another TODO in obox module...
i notice after closing of windows, the xtitle still displays the last closed window. perhaps i lack some line to be added ?

Here is a module that should work on any EWMH/NetWM compatible X Window Manager

# desktops module for any EWMH/NetWM compatible X Window Manager

sp_desktops()
{
	module_index="$1"
	xprop -root -spy -notype _NET_CURRENT_DESKTOP _NET_DESKTOP_NAMES \
	| while read line; do
		dt_line=$(
			wmctrl -d \
			| while read dt_number dt_active c3 c4 c5 c6 c7 c8 c9 dt_name; do
				[ "$dt_name" ] || dt_name="$c9"
				if [ "$dt_active" = "*" ] ; then
					printf "%s" "${BC1}${SP}${dt_name}${SP}${BC}"
				else
					if [ $(xdotool search --desktop $dt_number --limit 1 --class "") ] ; then
						printf "%s" "%{A1:wmctrl -s $dt_number:}${SP}${dt_name}${SP}%{A1}"
					fi
				fi
			  done
		)
		echo "${module_index}:\
			%{A4:xdotool set_desktop --relative 1:}\
				%{A5:xdotool set_desktop --relative -- -1:}\
					${dt_line}\
				%{A5}\
			%{A4}"
	done
}

It shows all desktops names, highlights active desktop and switch desktops on click.

EDIT. Now it hides empty desktops and scrolls desktops with mouse wheel.

EDIT 2. Now it waits for change of desktops state, so it takes less resources

2 Likes

Forum kindly sponsored by