avahe-kellenberger / nimdow

A window manager written in Nim (In Development)
GNU General Public License v2.0
315 stars 19 forks source link

Create a default status bar script #98

Open avahe-kellenberger opened 3 years ago

avahe-kellenberger commented 3 years ago

It would be nice to have a default/example script.

@dakyskye will assist with a bash version, I should probably also write one in Nim.

PMunch commented 3 years ago

I just put xsetroot -name "$(date)" in a script and then put watch -n1 -p settime.sh in my startup programs which just gives me a clock in the corner. This would also serve to let people know about the status bar output thing.

dakyskye commented 3 years ago

What should the default status bar script show as a status, except time and date?

avahe-kellenberger commented 3 years ago

Time, date, volume, network name/status.

I think we could add additional script examples for mem and cpu, but it shouldn't be the default

PMunch commented 3 years ago

How about a folder of scriptlets in a folder named like eg. the xinitrc.d files, so prefixed with a two digit number determining the order to be run in. Then a simple script that just sorts all the scripts in the folder and runs them every N seconds separating their output with |. This way it would be easy for people to throw in new stuff or modify which things they don't want (could also do the whole available folder thing with symlinks into an enabled folder).

avahe-kellenberger commented 3 years ago

I think for now we'll just create an example or two so people can see how setting the status is done - In the future if we want to create a system like this to make setting the status simpler, we can

avahe-kellenberger commented 3 years ago

@dakyskye I'm still wanting this added if you have recommendations - if not I'll add something very simple.

Would be nice to have a whole guide to put on the wiki, as well.

dakyskye commented 3 years ago

Sorry, I was assigned to this task, but I've had no free time. I am still very busy. To my mind the default status bar should show these info: date, time, keyboard layout, battery state (if present).

lf-araujo commented 3 years ago

This is an excellent window manager, however for a less competent linux user it is very hard to set the status bar with simple info like (date, time, keyboard layout, battery state). Could someone share their config so I can use it, until recommended instructions are up in the Wiki?

Many thanks

dakyskye commented 3 years ago

This is an excellent window manager, however for a less competent linux user it is very hard to set the status bar with simple info like (date, time, keyboard layout, battery state). Could someone share their config so I can use it, until recommended instructions are up in the Wiki?

Many thanks

I will show you two of my statusbars: this and that.

To put what you said on the statusbar the script would look like (totally untested):

#!/bin/bash

while true; do
    DATE="$(date '+%a %d.%m.%Y')"

    LAYOUT="$(xkblayout-state print %s)"

    BATTERY_INFO="$(upower -i /org/freedesktop/UPower/devices/DisplayDevice)"
    BATTERY_STATE="$(echo "$BATTERY_INFO" | grep state | awk '{ print $2; }')"
    BATTERY_LEVEL="$(echo "$BATTERY_INFO" | grep percentage | awk '{ print $2; }')"

    xsetroot -name "$DATE | $LAYOUT | $BATTERY_STATE ($BATTERY_LEVEL)"
    sleep 1s
done
Ordained-SubGenii commented 1 year ago

similar to script provided by @dakyskye, you could use a bash script like this to get statusbar as shown in pic. This will only show battery charging state if its not charging and uses command from pw-volume package (https://github.com/smasher164/pw-volume)

``#!/usr/bin/bash

red=$'\e[31m' green=$'\e[32m' blue=$'\e[34m' magenta=$'\e[35m' cyan=$'\e[36m' white=$'\e[0m' green_redbak=$'\e[32;41;'

while true; do

DATE="$(date '+%a %D %R')"  
BATCHRG_TEST="$(cat /sys/class/power_supply/BAT0/status)"
if [[ ! $BATCHRG_TEST =~ "NO" ]]; then
    BATTERY_STATE=$BATCHRGTEST
fi

BATTERY_LEVEL="$(cat /sys/class/power_supply/BAT0/capacity)"  
    WIFI_STATE="$(cat /sys/class/net/wlo1/operstate)" 
while read vol; do
    printf -v VOL "%sVol:%s$vol%%"  
done < <(pw-volume status | awk -F[:,] '{print$2}')

xsetroot -name ""wifi:" $WIFI_STATE | $VOL | "Batt:"$BATTERY_STATE${white}($BATTERY_LEVEL"%") | ${cyan}$DATE"
sleep 60s

done"

Screenshot-2022-10-10_20:55:13

You can also incorporate standlone statusbar programs like polybar, yabar, rsblocks, etc by adding the path to launch such bars in the exec section of nimdow's config.toml

avahe-kellenberger commented 1 year ago

We should test these scripts on desktop machines (that obviously don't have batteries) and make sure everything still looks decent. Also, using as little dependencies as possible, such as pw-volume etc