Gambas Process Watcher (de-clutter)

So you have written that new, must have program. Let us see it here.
Poly
Posts: 8
Joined: Saturday 2nd November 2024 11:10am

Re: Gambas Process Watcher (de-clutter)

Post by Poly »

You are really great. :)
You've even revised the alignment of the ‘btnClean2’ button.
Now it fits perfectly with the German translation and the icon is also displayed in full.
I don't know how you did it, but I noticed it straight away.
Thank you very much. :D
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

Poly wrote: Saturday 16th November 2024 5:39pm You are really great. :)
You've even revised the alignment of the ‘btnClean2’ button.
Now it fits perfectly with the German translation and the icon is also displayed in full.
I don't know how you did it, but I noticed it straight away.
Thank you very much. :D
No worries :)

That was my bad , I had not set "AutoResize" on all of the buttons but now I have :)

I always forget different languages can result in very different size buttons :roll:
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

Some GUI improvements..

This program is getting ready for non beta V1.1 now.

Pretty sure now it's got all the features it needs. (any feature suggestions welcome)

Just some further testing/usage to iron out any possible bugs and it'll be complete.

New to V1.0.15
Added a reload button for easier reloading.
Tray icon displays a red dot if there are dead folders.

Some more code tweaks/optimizations

Known minor issue: sometimes it shows a dead folder that has actually been removed, not sure why yet (probably needs more Wait time somewhere),
it should auto-remove itself from the list when you select it or reload the list.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

aaaand I fixed the issue of it not removing cleaned items from the list.

It was with what i call quick-dead folders. The processes from a non-gui command or a gbs script that may run a function and quit right away so the items are quickly removed just after they are created.

It was just my code that did handle that but removed them from the GBProcessList but not the actual GridView.

so that should be fixed now in 1.0.16
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

One last update for now because it was bugging me..

I noticed the window was not opening in the exact same place.

There seems to be a bug in gambas Settings.class (or the way I am using it) when using Settings.Read(Me) and Settings.Write(Me) to load/save window positions.
There are problems with both gtk and qt, the issue is slightly different between them and took a while to find a fix that worked for both.

I have found the following...
just using Setting.Read in Form_Open makes the window position okay on start but if a persistent window is hidden then shown again it looses it's positioning.
This i fix by also adding Settings.Read to Form_Show

But then just using Settings.Read in Form_Open and Form_Show causes the window to nudge up a little each time it re-opens :-\
So this I have fixed by also adding Settings["WinY"] = Me.Y
So the positioning command now goes like this..

Settings.Read(Me)
Me.Y = Settings["WinY", Me.Y]

Now finally it seems to open and re-open in the same place.
V1.0.17
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

I had an issue if the alert message popped up while i was busy and multiple dead folders appeared.

the issue being that Message() is a modal window the the program is essentially frozen till you close the message causing a queue of alerts. I added the Pause alerts button set a timer that paused the message popup while the alerts cleared, but it was not great.

So now i have added a window with a MessageView in it.
Alert messages now appear here, added to the messageview list,

the messages can be read one at a time or cleared and the window can be closed/re-opened without deleting them.
Attachments
Untitled.png
Untitled.png (144.96 KiB) Viewed 954 times
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

2 updates

fixed a stats refreshing glitch
For some reason the following code gave a bad row index..

For c as integer = 0 to GridView1.Rows.Max
If Not GridView1[c, 0].Tag Then Continue

My guess it the gridview updated it's contents during the loop making the Count invalid.

So i now Lock the gridview during the read and use Catch to skip any errors


I have also added the following code (or similar) to this program, and all my other programs that may sit in the background till reboot/logout.


Public Sub Form_Open()

  Dim iOldID As Integer = Settings["LastID", 0]  ' get last known pid
  If iOldID Then HardKill(iOldID, True)   ' look for and clean old pid temp folders 
  Settings["LastID"] = Application.Id  ' note current pid
  Settings.Save  ' force settings file to save pid right now.

End

Public Sub HardKill(Optional vID As Variant = Application.Id, OnlyClean As Boolean, OnlyHome As Boolean)

  Dim ID As String = CStr(vID)
  If Not ID Or If Not IsInteger(ID) Then Return
  If OnlyClean And If Exist("/proc" &/ ID) Then Return 

  If Exist("~/.cache/org.gambas." & ID) Then Exec ["rm", "-rf", "~/.cache/org.gambas." & ID] Wait
  If Exist("~/.local/share/org.gambas." & ID) Then Exec ["rm", "-rf", "~/.local/share/org.gambas." & ID] Wait

  If Not OnlyHome Then
    If Exist(Env["XDG_RUNTIME_DIR"] &/ "gambas" &/ ID) Then Exec ["rm", "-rf", Env["XDG_RUNTIME_DIR"] &/ "gambas" &/ ID] Wait
    If Exist(File.Dir(File.Dir(Temp())) &/ ID) Then Exec ["rm", "-rf", File.Dir(File.Dir(Temp())) &/ ID] Wait
  Endif

  If Not OnlyClean Then Quit

End



The HardKill function has 2 purposes.
It can be used with no arguments to Quit the program. cleaning up the temp folders before it Quits.

Or with parameters vID and CleanOnly it will clean dead folders for the given ID if no /proc/ counterpart exists.

When the program starts it checks if it's last known pid has dead folders and cleans them if so.

So now if i logout/reboot and start again any running programs that left dead folders clean up their previous junk.

I just could not deal with the ProcWatcher leaving it's own dead folders on logout. didn't seem right.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

I've been having trouble with a bug where if minimized for a while it seemed to show blank gridview when re-opening.

it would say how many live/dead processes there were but nothing on the gridview.

I think/hope I've fixed it now. in 1.0.21
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

Have not seen the blank gridview since the last update so that's good :)

I gave it some more DBus stuff (as it already uses DBus for TrayIcon)

I added dbus interface commands Activate() and Quit()

Now from another program we can simply do this to open/activate it...

  If DBus.Session.Applications.Exist("org.GambasProcWatch") Then
    DBus["org.GambasProcWatch"]["/org/GambasProcWatch","org.command"].Activate()
  Endif


Or quit it...
  If DBus.Session.Applications.Exist("org.GambasProcWatch") Then
    DBus["org.GambasProcWatch"]["/org/GambasProcWatch","org.command"].Quit()
  Endif


It also now uses DBus.Unique to stop multiple instances of the program running.

Now if the program is already running when run a second time it will open the already running program instead.

also added option to not show the message box after doing a "Clean all"
Plus an option to make closing the window always minimize to tray

V.1.0.22 :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1931
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas Process Watcher (de-clutter)

Post by BruceSteers »

Version 2 anyone?
(beta)

This is pretty much a rebuild with some stuff ripped from the V1

Main difference is i made a ProcView.class that inherits ScrollView and _ProcView_Item Control.

So now they are not gridview items they are actual controls.
Click them to expand some details. double click for full details (needs work).

Todo:
As it's already using DBus i'm going to add an option to show a DBus notification instead of the popup MessageView window.
Haven't made the trayicon show different if dead folders are found yet.

New version added to first post.. https://forum.gambas.one/viewtopic.php?p=9501#p9501
Attachments
GPW2.jpg
GPW2.jpg (78.83 KiB) Viewed 149 times
If at first you don't succeed , try doing something differently.
BruceS
Post Reply