Scriptable lightweight panel for bspwm with lemonbar

Continuing the discussion from Modular structure for Limepanel:

Hi all.
If you use bspwm and want to tinker with custom scriptable panel, you are welcome to try my simplepanel.

You can install it like this:

curl -O https://raw.githubusercontent.com/kainonergon/simplepanel/master/PKGBUILD && makepkg -si

Install optional dependencies to get functional panel modules.
Start it with simplepanel &

Config file ~/.simplepanelrc is generated on the first run. You can modify default panel modules or script your own.

It may have issues if you have fancy audio configuration or multi-monitor system.

Screenshots:
2018-03-06-100856_1366x768_scrot_1

2018-03-06-100856_1366x768_scrot_2

7 Likes

I wrote modules that I use myself. It is easy to write your own modules, it takes just some simple shell scripting. Make a copy of module definition in .simplepanelrc and modify it as you like. If you feel something is really useful for other people, your pull requests are welcome.

I moved discussion here so that not to spam screenshot thread.

Check if weather-report works from command line. Maybe it needs some initial configuration to work properly.

I have weather module in my default config, so you don’t need to add it. Just change LOCATION. Also notice, that weather module works inside status line, so don’t add it into regular panel structure, it won’t work there.

1 Like

That clue helped me identify that my METAR was not listed in the “stations”. i added the data manually and i could get it work ! thanks for pointing me there !

Alternatively, i wanted to know if wttr.in can be used [ there is a AUR package for this in the repo]
instead of METAR, exact location can be provided by typing our location !

as i am not a coder nor a programer, i will need lots of tie to dig into understanding the function to add additional modules… CPU load / temp; MEM used / %; MPD etc… though i can say shell scripts i use for all of these… only to learn how to make it display in panel !

weather-report can search location by name, for example

weather-report "New York"

will list 12 matches and then you can choose which one to use, for example

weather-report knyc

If you just want to see some info on the panel,there are several ways to do that:

  1. If the info you want is static (for example distribution name, kernel name etc) you can add it to the main panel structure. Add a function definition to the rc file:
my_panel_module()
{
	my_info="$(command_line_to_show_my_info)"
	begin_module "$1"
		printf "%s" "$my_info"
	end_module
}

Keep that "$1" after begin_module, it is important.
If you know how to see the info from command line, just use the same shell command in the module, for example my_info="$(uname -r)".
Then add this module into sp_modules string where you want it to appear:

sp_modules="
my_panel_module
sp_menu
...
sp_padding
"

You can do the same to add info to status line (see below)

  1. If the info you want is dynamic (like cpu or memory usage), it should be added to status line. This line updates its modules every 3 seconds (you can change the interval), so that you see current values. Status line modules use slightly different format, so add this
my_status_line_module()
{
	my_info="$(command_line_to_show_my_info)"
	begin_status_module
		printf "%s" "$my_info"
	end_status_module
}

and then add its name to sp_status_modules line.

If you want some clickable or interactive modules, see the modules defined in default config and tweak them.

P.S. I added those begin_module and other definitions to make the code more readable and easy to understand, but really you can use your own way to write the modules.

EDIT. I corrected some explanations.

Idea: source configs in /usr/share/simplepanel/conf.d/ so we can install plugins/modules with other packages for it?

1 Like

It would require more strict conventions what variables and functions should the code of the module use. For example, I defined formatting for icons or vertical bar indicator and use them several times in different modules. If modules were defined in several files or even packages, it would be harder to do that.
Though it is possible, it may take some higher level of development to do it properly.

1 Like

I think this would work in a status line module:

    LOCATION="New York"                                                                                                              
    temperature=$(curl -s "en.wttr.in/${LOCATION}?T0qQm"|sed -n '2s/.\{15\}//p'|sed 's/ *$//')

Though I think soon you will get refusal of service from wttr.in because of too many requests (it updates data every 3 seconds). weather package has its own cache, so repeated requests will return data from the cache that will be updated in proper intervals.

1 Like

yes… for my other wms, i use the poll interval [say 1800 seconds, which does the job]…

will be very nice if impleented, but as @kainonergon said… conventions ! so it works on all wms / distros !

will implement and update !

a comparision can be made, as in a polybar config, seperators [with iconic symbols] using nerd font are predefined as a module {left-seperator, arrow-left, arrow-right etc} which is loaded in the polybar modules-left / modules-center / modules-right listings ? i just correlate and visualise instances on multiple calls !

does it apply to begin_status_module too ?
i tried this

....
sp_status_hwmon()
{
  ICON="${SP}${i_fa_hwmon}${SP}"
  temp="$(execpi 30 ~/scripts/coretemp)°C"
    begin_status_module
       printf "%s" "$temp"
    end_status_module
}
.....
....

script runs prefect, but fails to show on panel… at desired position. alternatively i tried adding custom script and that isplays, which means that the data is being read …

No, status line modules does not need that

I did not use that in my modules. Try to use just the script.

tried this

sp_status_hwmon()
{
  ICON_TEMP="${SP}${i_fa_hwmon}${SP}"
  temp="$(sh ~/scripts/coretemp)°C"
    begin_status_module
       print_icon "$ICON_TEMP"
       printf "%s" "$temp"
    end_status_module
}

only " °C " is displayed…

i also wish add a power button in top right that gives option to “bspc quit” / “systemctl reboot” / “systemctl poweroff”

This is shell script, so don’t add sh before your script name. Use just $(~/scripts/coretemp).

Make sure you added character definition for that hwmon icon.

If you want it as a dropdown menu, rofi can be usefull.

no result… same ! will dig into this… then add other modules [power, mpd on the cards as of now]

will try this and update you

Forum kindly sponsored by