How to add additional Panel Widgets?

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
Neo_78
Posts: 407
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 232 times
Been thanked: 11 times

How to add additional Panel Widgets?

Post by Neo_78 »

The FatDog panel at the bottom is configured by default to show the CPU activity. Checking the panel configuration menu, this seems to be the only widget available.

Is there a way to add and configure additional, even custom widgets? Like, e.g.:

- Total memory consumption
- Incoming / outgoing network traffic
- Memory used by the file system

For instance, could you display the output of df -h / in the panel?

Conky is a great option as a system monitor for the desktop. The problem is that it can only be displayed on the desktop and not be configured to be permanently visible on top of all other windows. So the bottom panel, which is always visible, might be the only way to have permanent visibility of key system functions.

user1111

Re: How to add additional Panel Widgets?

Post by user1111 »

program 'sit' is included in Fatdog by default IIRC, if not its in gslapt. Enables you to stuff things into the tray and assign a icon and left/right clicks to that.

sit image.png tooltip left-click-action right-click-action ... type syntax

Another option is to create a larger virtual workspace that you can pan around by moving the mouse to screen edges. Run xrandr to identify your screen name, maybe VGA-0 or eDP .... or something like that, and try

xrandr --output eDP --rate 60 --mode 1366x768 --panning 2000x1000

... which works for my laptops 60Hz 1366x768 that's called eDP

Within that larger workspace you might add the likes of bmon, htop, whatever system monitors you might like to use. I quite like cwm when running like that as it has no windows decorations nor panel ...etc. Great on a laptop where you mostly use the keyboard. I've defined my cwm to use keys such as WIN x to close a window, WIN tab to step between windows, WIN left mouse to move a window, ALT left mouse to resize window, WIN space to show the command menu ...etc. Awkward at first, but once second nature productivity tends to be magnitudes better. To launch rox for instance WIN space space r <enter> might be typed to launch your command window and select the rox entry whilst not even looking at the screen let alone having to reach for the mouse and drag it to a corner and click and roll the mouse up to filemanagers and then across to rox ... etc.

ss.jpg
ss.jpg (174.87 KiB) Viewed 1539 times

If you open your browser and set that down the right edge with its width fitting your actual display then a quick flip of the mouse to the right screen edge shows that browser. Set your monitors down the left screen edge and you can flip the mouse over to the left to view those.

Alternatively just open each of bmon, htop, chrome, whatever and maximise then and flip between them using usual alt-tab (or in my cwm case WIN tab)

cwm isn't in Fatdog nor gslapt, has to be compiled. jwm can be set up to do very similar in many respects but I do like the cwm predictive menus that jwm doesn't include.

Yet another option is to create your own

Code: Select all

#!/bin/sh

/root/cpuused &    # start CPU usage monitor

_find_func() {      # find function for Locate where to read cpu temperature from
        FILES="$1"
        for n in `echo $FILES`; do
            read p < $n
            if [ $? = 0 ];then
                FILE=$n                                                # found it
                break
            else
                continue                              # didn't find, search again
            fi
        done
                                  # if we get here we didn't find anything useful
}
                                    # Scan for where to read cpu temperature from
for a in `find /sys/devices/platform -type f -name 'temp*_input'|sort`          `find /sys/devices/pci* -type f -name 'temp*_input'|sort`          `find /sys/devices/virtual -type f -name 'temp'|sort`
do _find_func "$a"
        [ -z "$FILE" ] && continue || break                # if we found data break
done
CPU_TEMP=$FILE
###

_temperature() {                                  # Container temperature tray icon
        last=55
        if [ -f $CPU_TEMP ]; then
            while :; do
                x=$(cat $CPU_TEMP)
                x=$((x/1000))
                if [ $x -gt 1 ]; then
                    if [ $x -ne $last ];then
                        last=$x
                        echo $last >/tmp/cputemp
                    fi
                fi
                sleep 2
            done
        else
            Xdialog --msgbox "cpu temperature not found" 0 0
        fi
}

_temperature &

trap 'exec $0' HUP # Restart itself
trap 'tput cnorm; exit 1' INT QUIT TERM

tput civis # Hide cursor

while true; do

TEMPERATURE=`cat /tmp/cputemp`

D=`date +"%a %d %b %Y"`
T=`date +"%H:%M"`

B_MAX=$(cat /sys/class/power_supply/BAT1/charge_full)
B_NOW=$(cat /sys/class/power_supply/BAT1/charge_now)
B_MAX=$((B_MAX / 100))
BATT=$((B_NOW / B_MAX))

CPUUSED=$(cat /tmp/cpuused)

SOUNDLEVEL=`amixer | grep "Mono: Playback" | grep -oh '\[[0-9].*\]' | head -c 7 | sed 's/.*\[\([^]]*\)\].*/\1/g'
`

# 0 black, 1 red, 2 green, 3 yellow, 4 blue, 5 magenta, 6 cyan, 7 white

TEMPREDTHRESHOLD=59                    # CPU temp 60 degrees or more then red/blink
BATTLOWREDTHRESHOLD=40                         # Battery 40% or less then red/blink

if (( $TEMPERATURE > $TEMPREDTHRESHOLD ));then
   CPUCOLOR="$(tput blink) $(tput setaf 1)"
else
   CPUCOLOR="$(tput setaf 2)"
fi
if (( $BATT < $BATTLOWREDTHRESHOLD ));then
   BATTCOLOR="$(tput blink) $(tput setaf 1)"
else
   BATTCOLOR="$(tput setaf 3)"
fi
DATECOLOR=$(tput setaf 7)
SEPARATORCOLOR=$(tput setaf 4)

BAR="${DATECOLOR}$T $D${SEPARATORCOLOR} ▋ $(tput setaf 5)Volume ${SOUNDLEVEL}${SEPARATORCOLOR} ▋ ${BATTCOLOR}Battery ${BATT}%$(tput sgr0)${SEPARATORCOLOR} ▋ ${CPUCOLOR}CPU temperature ${TEMPERATURE}°$(tput sgr0)${SEPARATORCOLOR} ▋ $(tput setaf 6)CPU ${CPUUSED}   "

  # tput clear cup 1 0  # flashes if have this so commented out
  tput cup 0 0
  printf "%s" "${BAR}"
  #printf "%110.110s" "${BAR}"
  sleep 60
done

tput cnorm # Show cursor

cpuused

Code: Select all

#!/bin/bash
# by Paul Colby (http://colby.id.au), no rights reserved ;)

PREV_TOTAL=0
PREV_IDLE=0

while true; do

  CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics.
  unset CPU[0]                          # Discard the "cpu" prefix.
  IDLE=${CPU[4]}                        # Get the idle CPU time.

  # Calculate the total CPU time.
  TOTAL=0

  for VALUE in "${CPU[@]:0:4}"; do
    let "TOTAL=$TOTAL+$VALUE"
  done

  # Calculate the CPU usage since we last checked.
  let "DIFF_IDLE=$IDLE-$PREV_IDLE"
  let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
  let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
  echo -en "$DIFF_USAGE%" >/tmp/cpuused

  # Remember the total and idle CPU times for the next check.
  PREV_TOTAL="$TOTAL"
  PREV_IDLE="$IDLE"

  # Wait before checking again.
  sleep 60
done

works for me, part of the code used to create a terminal bar showing time, date, battery, sound level, cpu temperature, cpu used indicator in a single line so can be started in a xterm window with -geometry set to the width and 1 character height. In cwm you can set a gap at each/any of the screen edges that windows wont overwrite so is ideal for such a terminal bar.

Yet another option might be to use gkrellm. Maybe set the openbox panel height to be taller and not so wide to leave space for a gkrellm monitor(s) to be placed.

Yet another option is to load all your monitors onto desktop 2 and use desktop 1 as your workspace, so a quick flip over to desktop 2 reveals the system info.

Some spend much time 'ricing' their desktop. Mike Walsh has created some pretty nice looks where he incorporates various monitors/tools along with icon placements and wallpaper image to make a really nice looking desktop.

user1111

Re: How to add additional Panel Widgets?

Post by user1111 »

Here's a snippet of code I use to repeatedly load the temperature into a tray icon. This first function creates the image file that 'sit' will use

Code: Select all

_tempsvg() {                                               # cpu temperature .svg

        cat <<EOF >/tmp/.temperature.svg
<svg height='32' width='32' viewBox='0 0 16 16'>
 <radialGradient id='rg' fx='50%' fy='50%' cx='50%' cy='50%' r='50%'>
   <stop offset='80%' stop-color='white' stop-opacity='1'/>
   <stop offset='100%' stop-color='$2' stop-opacity='1' />
 </radialGradient>
<rect width='14' height='13' x='1' y='1' rx='2' ry='3' fill='url(#rg)'/>
<g font-size='8' font-style='normal' font-variant='normal' font-weight='bold'
font-stretch='normal' text-align='center' line-height='125%' letter-spacing='0'
word-spacing='0' text-anchor='middle' fill='$3' fill-opacity='1' stroke='none'
font-family='sans' dominant-baseline='central'>
<text x='52%' dy='11'>$1</text>
</g>
</svg>
EOF
}

So its called with something like
_tempsvg 55 cyan black

Invoked within a while loop and it creates a /tmp/temperature.svg icon that I can then load into the tray using 'sit'

But only useful for at most 3 digit values, maybe more but would have to scale things down to levels where it starts to be too small

Code: Select all

_temperature() {                   # Container (DISPLAY=:2) temperature tray icon

        if [ -f $CPU_TEMP ]; then
            last=55
            _tempsvg 55 cyan black
            sit /tmp/.temperature.svg "cpu temperature" &
            PIDsittemp=$!
            while :; do
                x=$(cat $CPU_TEMP)
                x=$((x/1000))
                if [ $x -gt 1 ]; then
                    if [ $x -ne $last ];then
                        last=$x
                        [[ $x -ge $REDTHRESHOLD ]] && colour=red || colour=cyan
                        [[ $colour = "red" ]] && textcol=red || textcol=black
                        _tempsvg $x $colour $textcol
                    fi
                fi
                sleep 10
            done
        else
            Xdialog --msgbox "cpu temperature not found" 0 0
        fi
}

that's only part of the code, there's additional code to find where the temperature value is stored within the system. Repeatedly reads that which in your case might be the repeated reading of maybe the used space from df -h / ... or whatever.

In the above example case it recreates a new icon for the sit process every 10 seconds if the temperature value has changed. And also changes the icon colour if the value has moved above a certain level as stored in $REDTHRESHOLD that I set to 60 for my system.

step
Posts: 546
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 57 times
Been thanked: 198 times
Contact:

Re: How to add additional Panel Widgets?

Post by step »

Neo_78 wrote: Sun Mar 20, 2022 1:09 pm

The FatDog panel at the bottom is configured by default to show the CPU activity. Checking the panel configuration menu, this seems to be the only widget available.

There are more widgets, though maybe not all the ones you need. Right click the panel, choose Manage Widgets, click the Plus (+) icon on the right side of the dialog, add some widgets. Sensors and system statistics, although pretty lame, are a possibility.
If you want to roll your own custom widgets, the way rufwoof explained, but don't want to use sit for some reason, yad is another program that can show a custom tray icon.

Neo_78
Posts: 407
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 232 times
Been thanked: 11 times

Re: How to add additional Panel Widgets?

Post by Neo_78 »

Thanks for the detailed explanation @rufwoof. Funny, I also use mainly top and bmon... :D Let me check out the cwm window manager. I guess using some sort of window manger that allows you to organize the screen in predefined layouts is the way to go.

Thanks @step. Yep, there are not so many widget options under "Mange Widgets" unfortunately.

Feek
Posts: 398
Joined: Sun Oct 18, 2020 8:48 am
Location: cze
Has thanked: 54 times
Been thanked: 90 times

Re: How to add additional Panel Widgets?

Post by Feek »

Yet another option is to load all your monitors onto desktop 2 and use desktop 1 as your workspace, so a quick flip over to desktop 2 reveals the system info.

I recently installed btop (from the FatDog's repository).
It provides many information, while only the required ones can be displayed.

I launch the maximized btop window on the desktop 2.
Then I can switch between the desktops with ctrl+alt+left/right arrow.

It's not bad at all.

user1111

Re: How to add additional Panel Widgets?

Post by user1111 »

Neo_78 wrote: Mon Mar 21, 2022 7:55 pm

Thanks for the detailed explanation @rufwoof. Funny, I also use mainly top and bmon... :D Let me check out the cwm window manager. I guess using some sort of window manger that allows you to organize the screen in predefined layouts is the way to go.

Thanks @step. Yep, there are not so many widget options under "Mange Widgets" unfortunately.

jwm is better than cwm in many ways and you can set up key bindings to have jwm pretty much mirroring cwm, whilst jwm also includes the tray and other functionality. What I miss in jwm however are the short key codes - being able to define something like

<Program icon="viewnior.png" label="&viewnior">viewnior</Program>

where the &v has the v underlined in the menu and enables the menu item to be selected by pressing 'v'

that is were cwm betters jwm, its predictive focus as you type is excellent.

I don't tend to move/resize windows in cwm with the hjkl keys and instead have ctrl-mouse-drag and alt-mouse-drag to do the move/resize action, but that does mean two hands, left to press the ctrl (or alt) and right for the touchpad movements. jwm with the drag window title bar with just the mouse is nicer. But I tend to have each window maximised, WIN+m in my settings, ctrl-alt-m more usually. And then alt-tab between windows. So for my workflow moving/resizing windows is a relatively lightly used action.

user1111

Re: How to add additional Panel Widgets?

Post by user1111 »

Feek wrote: Mon Mar 21, 2022 8:42 pm

Yet another option is to load all your monitors onto desktop 2 and use desktop 1 as your workspace, so a quick flip over to desktop 2 reveals the system info.

I recently installed btop (from the FatDog's repository).
It provides many information, while only the required ones can be displayed.

I launch the maximized btop window on the desktop 2.
Then I can switch between the desktops with ctrl+alt+left/right arrow.

It's not bad at all.

Does require quite a small font for all of the additional i and d options to be visible. On my setup I run it using (xterm in Fatdog is actually urxvt)

Code: Select all

xterm -title network -geometry 166x50 -font "xft:DejaVuSansMono:size=7" +sb -e bmon -p 'wlan*,eth*,lo*' &

on a 1366x768 laptop and the visible font is quite small. But otherwise a great utility IMO.

Feek
Posts: 398
Joined: Sun Oct 18, 2020 8:48 am
Location: cze
Has thanked: 54 times
Been thanked: 90 times

Re: How to add additional Panel Widgets?

Post by Feek »

rufwoof wrote: Tue Mar 22, 2022 12:46 am
Feek wrote: Mon Mar 21, 2022 8:42 pm

Yet another option is to load all your monitors onto desktop 2 and use desktop 1 as your workspace, so a quick flip over to desktop 2 reveals the system info.

I recently installed btop (from the FatDog's repository).
It provides many information, while only the required ones can be displayed.

I launch the maximized btop window on the desktop 2.
Then I can switch between the desktops with ctrl+alt+left/right arrow.

It's not bad at all.

Does require quite a small font for all of the additional i and d options to be visible. On my setup I run it using (xterm in Fatdog is actually urxvt)

Code: Select all

xterm -title network -geometry 166x50 -font "xft:DejaVuSansMono:size=7" +sb -e bmon -p 'wlan*,eth*,lo*' &

on a 1366x768 laptop and the visible font is quite small. But otherwise a great utility IMO.

I tried your syntax with bmon. My screen is also 1366x768. You're right, the font doesn't look too huge on such a screen.

In my previous post, I meant btop:
"btop is Resource monitor that shows usage and stats for processor, memory, disks, network and processes.
It is the C ++ version and continuation of bashtop and bpytop"
.

In my opinion it is also worth trying. It's available in gslapt.

user1111

Re: How to add additional Panel Widgets?

Post by user1111 »

Opps! I'm dislegsic (for real. Type once, proof read making corrections, proof read again - making even more corrections, and more often there are still errors. Same for code but thankfully the compiling is much less forgiving than spell checkers).

Post Reply

Return to “FatDog64”