bbidulock / icewm

A window manager designed for speed, usability, and consistency
Other
587 stars 99 forks source link

Feature Request: Additional customizable tray monitors ( I would like a Drive Space Monitor, for example ) #386

Closed cheapy closed 1 year ago

cheapy commented 5 years ago

It could be similar to or possibly use the same code as one of the other monitors since the calculations would be very similar.

It would have a tray icon like a disk drive Maybe round with rings, or a flat bar, and the label could be in a foreground text color underneath, and empty space would be green by default, used space would be red by default.

The Default would be space monitoring for "/", but possibly like the network and battery monitors additional monitored locations like "/home" could be added.

I have tried a number of ways to get this, and all the tray icons available take between 25 and 40 mb of memory, so are not sensible for the older systems. I have also looked at coding a tray icon program to do it myself, but don't have the coding skills to do it.

PS: I was thinking more about this, and what might be both easier and better would be to have up to 4 generic tray icons 1 thru 4 available where I could specify in preferences to turn on tray icon #1 with a tooltip command and click command and icon drivespace-root.svg, and refresh it every 1000 milliseconds. Then icewm would display the icon and check every 2000 milliseconds by default to see if the icon file had been changed, and if so, refresh the icon. There could be a refesh program preference to run a script to create a refreshed icon based on whatever calculations I want. I would guess the effort would be much less and it would have very little impact on memory or performance, and people could use them to show the weather or drive space or whatever else might be important to them.

gijsbers commented 5 years ago

If you have icons, could you perhaps post a few as an example of what you have in mind?

cheapy commented 5 years ago

icewm-drivespace90 icewm-drivespace80 icewm-drivespace70 icewm-drivespace60 icewm-drivespace50 icewm-drivespace40 icewm-drivespace30 icewm-drivespace20 icewm-drivespace10

I'm not sure if these are good or bad, but i guess they don't need to be noticeable until 70% or over I was thinking to display the percent full in the middle.

Maybe the bar looks better? I would say choose something not too difficult to program but gets the point across. I left enough space underneath for the label.

I am not a graphic artist, but a circle where the water level rises and its green below till it hits 70% then changes to yellow till 90% then goes red. If it changes 10% at a time that would be reasonable. The top free space could be blue sky. Maybe in the middle is the digital letters same as clock like 53% showing percent free, and underneath the label, up to X chars which would be / on the default one, and if somebody puts too many characters in, just truncate and they will learn to abbreviate. icewm-drivespace

cheapy commented 5 years ago

Another would be a bar that starts green and goes yellow then red as the drive fills like this one, or the circle one they use for a logo (but i think that would be tricky to code) drivespacetrayicon

spaceview-indicator

bbidulock commented 5 years ago

Why not use a systray drive space monitor?

cheapy commented 5 years ago

The slimmest drive space tray monitor I could find needs 26mb of memory, if I could get it to work. The one that did work was 35mb, about double what IceWM takes. On the old machines many are maxxed out on memory, ie 256mb or 372mb, and the browsers have gotten huge, and those same machines are the ones with the small drives that are tight on space. A reload takes 1/2 a day, so I rather not see them run out of space.

I found 2 programs that looked light enough to be possible, but the one was a patch for DWM, and the other an ancient C program of an embedded tray example that I managed to get to compile and run (not actually to DO anything, just run) and go into the tray for 6mb, but it needed 100% of the CPU to sleep. I bought a C book and one of my projects is to learn to debug it, but I haven't gotten there, yet.

cheapy commented 5 years ago

I am an idiot!

Disk storage is just like memory storage, it is either used or free and usage goes from 0 to 100%. Therefore, why can't it just be a status monitor just like the memory one? The only location really important on most systems is /.

If a Disk Space Monitor was over to the left of the battery monitor, you would know at a glance it was for disk space, and it could have a tooltip showing the obvious info, and a click command that could be configured to bring up your favorite disk space management program.

The code and config could almost be a copy of the memory monitor. Would that be feasible?

Here are snips of the calculations used by DWM's script one...

https://github.com/joestandring/dwm-bar/blob/master/bar-functions/dwm_resources.sh

# Used and total storage in /home (rounded to 1024B)
STOUSED=$(df -h | grep '/home$' | awk '{print $3}')
STOTOT=$(df -h | grep '/home$' | awk '{print $2}')
STOPER=$(df -h | grep '/home$' | awk '{print $5}')

    printf "💻 MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
gijsbers commented 5 years ago

I can see that a monitor internal to icewm would cost the least amount of memory, but the danger is that it would take several iterations of new and changed feature requests that it would all in all still take quite some time to develop, even though its demands could in theory be well-stated before coding begins. Your assumption that root is the most important is not general. One needs to be able to specify which filesystems, like the network monitors can use wildcarded specifications. For instance, when using a Logical Volume Manager you get many critical filesystems which can fill up. Maybe one wishes to exclude network filesystems, because polling causes extra network traffic? Should the monitor consist of vertical bars like the battery monitor or a graph of multiple levels like the memory monitor. The latter is quite boring I think. Maybe its time should be logarithmic? Does a percentage of full capicity suffice or do you need free MB remaining? Etc. The difficulty is getting all the details precisely stated and be general for all uses for everyone.

The code example you quote is actually quite inefficient, because it causes so many processes to be started. It could have been:

df -h /home | if read a STOTOT STOUSED d STOPER; then 
    printf "💻 MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
fi
cheapy commented 5 years ago

Yes, I was thinking about the type of graph over night, and what would suffice would be a single line down from the simple percentage used of total to the 0 line filled with that color for that timeframe. Perhaps the color could have 5 change increments rather than just green, greenish yellow, yellow, orange, and red and go with a white filler at the top to distinguish it from the other monitors visually. Obviously, making it look nice would be appreciated. My circles looked horrible. Well intentioned, but horrible :)

And yes, making it configurable like the network monitors to allow for more than one monitor would be good, but if that makes it a big project, it is a "nice to have", not "absolutely needed". For most distros I install it is the root filesystem that runs out of space installing programs or downloading videos or ISO's or making movies because usually the /home filesystem is not separate by default. I'm not saying it wouldn't be a good feature, just that on the older systems where memory and CPU time are precious, installs tend to be pretty basic.

Disk status monitor could be off by default, and an example could be provided showing how to turn it on for the root directory (and another if allowing multiple monitors). The tooltip would show a label ie / and both values, units and percentages for Total, Used and Free on 3 lines. The command on click could run any of the disk usage analysis programs that are installed by default if turned on. I could come up with a command line to default it with from the distro's I have installed.

cheapy commented 4 years ago

I wish I could do it myself but its not a good beginner project.

cheapy commented 3 years ago

I have thought about this more, and have tried a few times now to do it, but basically a disk is like a battery, it has a capacity=100%, already used, and available to use.

The default colors could be sky blue for capacity as the background, and deep red for already used. The tooltip could show these as percentages and human readable. Different drives would be akin to different batteries, and the default could be /. Each drive could be repeated for X configurable width of the DFMonitor graph. Maybe I would want them set at 3 wide and have 4 drives monitored for a total monitor width of 12. If one drive was getting full it's bars would be taller. That way we don't have 10 separate DFMonitors taking up the tray. Hover over it and it shows a list of the drives being monitored and the values of each in the same sequence as they are displayed. Click on it and it runs a designated program like the CPU, Memory or Network monitors can.

If you are willing to be fancy, add a warning alert color at XX percent full, and a severe warning alert at XX percent full at which time it blinks and plays a sound (if specified) every time its checked and >= to the percentage.

Much of the logic could be cloned from the existing APM logic and called DFM logic. Existing APM Configuration settings could be cloned by exchanging the letters APM for DFM, plus the warning alert ones and click on monitor program to run.

I don't really know enough about Linux to know what are the limits that you are capable of in terms of what could be monitored, but I can see above it's way beyond what I could anticipate. I would suggest that my request should be viewed on the simple side, for example if df were used to retrieve the values, then a limit of what df is able to retrieve would be fine, and I would think that would help most users. They probably run out of space all the time like I do occasionally. I did again the other day. Its pretty easy to do when running off a flashdrive.

I hope you understand that my purpose is to make this the GoTo window manager for those who don't have the best computers, but need to get from point A to point B with them just the same. antiX is supporting a school in Germany, and making their almost antique Linux boxes run rings around the pokey MS crap, based on antiX and IceWM. And the beauty of it is that everytime we make it better for them, it's better for everyone else, too.