Open GHLieven opened 7 years ago
Why not use
<Include>$HOME/my-tray</Include>
Rather than an include inside the tray? For a menu it makes sense
<RootMenu onroot="2">
<Include>exec:jwm-menu</Include>
<Menu label="Things">
<!-- whatever stuff -->
</Menu>
<Program icon="system-shutdown">systemctl poweroff</Program>
</RootMenu>
But I don't understand the full use case of why a tray include would be useful to use. If the traybuttons could be dynamically redrawn I could see the use, something like pseudo indicator icons like volume or battery based in a dynamically generated tray which changes the icons... though using yad or writing a small program in c is useful enough for this for me. But you have to run jwm -restart
rather than jwm -reload
so the whole screen is redrawn with those changes
It would be nice if it was possible to display terminal output (i.e. memory usage) as a label on a traybutton. I would let it update by clicking the traybutton (or using some shortcut key). I know conky can achieve almost the same, but compared to the free-command, the output seems wrong.
@GHLieven This is possible to do with yad, but only as a tooltip, or menu item. You can change the icon to some symbolic thing. But I think it is also possible to do what you want with Swallow I have used Swallow for htop before as a test, and I use it with xload. I think Swallow is your best low cost choice. You can write a small script to get the specific information you want and display it that way. Or you can write a small c program or use @technosaurus sdesk program to do something like you are intending.
@GHLieven exactly as @Israel- said, I used such configuration 5 years ago with Swallow (just xterm with specified background and foreground color and the running command). In case you need some advanced graphics (not expected if it's just for tray, but anyway), give Nuklear with the X11 backend a try.
@GHLieven This is possible to do with yad, but only as a tooltip, or menu item. You can change the icon to some symbolic thing. But I think it is also possible to do what you want with Swallow I have used Swallow for htop before as a test, and I use it with xload. I think Swallow is your best low cost choice. You can write a small script to get the specific information you want and display it that way. Or you can write a small c program or use @technosaurus sdesk program to do something like you are intending.
Sorry the necroposting but I'm trying to do what you said (swallowing a shell script) without success, could you please point out how you did it?
1) simple "echo" system info shell script: jwmtray2
#!/bin/bash
while(true);do
sleep 1
LOAD=`sudo cat /proc/loadavg|awk '{print $1}'`
CPUTEMP="`sensors | grep "Core 0" | awk '{print $3}' | cut -d. -f1 | cut -d+ -f2`°"
CPUGOV=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | tail -1`
CRAM=`free -t | awk 'FNR == 2 {printf("%.2f%"), $3/$2*100}'`
echo "RAM: $CRAM | CPU: $LOAD/$CPUTEMP"
done
2) swallowing the script from .jwmrc
<Swallow name="jwmtray2" width="0" height="24">
~/jwm/scripts/jwmtray2
</Swallow>
But my tray shows nothing. Any clue?
Thank you in advance.
First, you need to make sure you are the owner of jwmtray2 and that the file is executable. You can do this as follows (replace james with your username)
sudo chown -R james:james $HOME/jwm/scripts/jwmtray2
sudo chmod 700 $HOME/jwm/scripts/jwmtray2
Next, I found three little mistakes in your script: you don't need to use sudo in the LOAD-line, in the CRAM-line the second %-sign is not needed and you use a variable CPUGOV that you don't use in the output.
I also added the line tput civis at the top, if you don't know what that means, it's simly an option of xterm (see below) to get rid of the cursor while displaying the output of your script.
Finally, I replaced the echo command with printf, this seems to work better and it allows me to use a newline character to split the output over 2 lines (I like that, but you need a tray of at least 38 pixels high for it to work properly)
#!/bin/bash
tput civis
while(true);do
sleep 1
LOAD=`cat /proc/loadavg|awk '{print $1}'`
CPUTEMP="`sensors | grep "Core 0" | awk '{print $3}' | cut -d. -f1 | cut -d+ -f2`°"
CRAM=`free -t | awk 'FNR == 2 {printf("%.2f"), $3/$2*100}'`
printf "\n RAM $CRAM \n CPU $LOAD/$CPUTEMP"
done
That's all for the script, next is the swallow part in .jwmrc: Here, you need to make sure to swallow xterm (the terminal) and not the script itself. If you don't have xterm on your system, you will need to install it. You have to define a width (here 103 pixels seemed sufficient, but you need to adapt if you want to show more output) and then, inside the tags, need to give the command to run, in this case xterm. Xterm accepts a few arguments, for example the -fa argument allows to change the font (I used Monospace) the -fs argument allows to change the font size (9 here) and the -fg and -bg arguments allow to set the foreground (black) and the background (light yellow) color of the terminal, respectively. Finally the -e argument allows to run a command in the terminal, and there we add the script.
<Swallow width="103" name="xterm">
xterm -fa 'Monospace' -fs 9 -fg "#000000" -bg "#ffffc0" -e ~/jwm/scripts/jwmtray2
</Swallow>
You're my savior, man. My own personal Jesus Christ - choi/Matrix
Thank you a bunch :) (haven´t tested yet, but I'm pretty sure it will work)
Currently it seems not possible to add an Include-tag within the Tray-tag.
<Tray>
<Include>some include</Include>
This is NOT possible</Tray>
<Rootmenu>
<Include>some include</Include>
This is possible</Rootmenu>