Script to put usbdrive icon in systray (Solved)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
wow
Posts: 1052
Joined: Fri 30 Jun 2006, 00:18
Location: Peru

#21 Post by wow »

http://www.murga-linux.com/puppy/viewto ... 888#946888

Arreglado: el montaje de partiticones vfat era demasiado rápido para darle tiempo al menú de actualizarse.

Fixed: vfat partition mounting was too fast for the menu to update.

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#22 Post by B.K. Johnson »

@wow, nilson
I called wow's first script usb_systray, placed it in /root/my-applications/bin/ and put a symlink to it in /root/Startup. . The icon shows in the tray and seemed to work. Clicking the Plus sign before an unmounted device, mounted it and clicking Minus unmounted it. The NTFS device (sda1) was not listed. PMount worked. I didn't know what Actualizer meant and nothing visible seem to happen when activated.

I set up the new script, pusitray (the last version after Edit9 here), on a different tahr-6.0.5 as before. Additionally, I unzipped pusitray_langpack_english01.zip, renamed *.mo to pusitray.mo and put it in /usr/share/locale/en/LC_MESSAGES/. See attached screenshots. Nothing happens neither when I click the script in /root/my-applications/bin/ nor on booting. The icon does not show.

Do I have the right script? Am I missing something? What am I doing wrong?

Edit10 was posted just before mine so haven't tried the revision yet, but don't anticipate any change. I'll report later.
Attachments
pusitray_placements.png
confirmation of files placement
(57.32 KiB) Downloaded 522 times
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

wow
Posts: 1052
Joined: Fri 30 Jun 2006, 00:18
Location: Peru

#23 Post by wow »

Español: Esta es una nueva versión de prueba, es ligeramente más rapida porque ahora solo realiza actualizaciones parciales en lugar de generar todos desde 0. Pero me parece que consume algo más de cpu.

English:This is a new test version, it is slightly faster because now it only writes partial updates instead of generate all items from 0. But it seems to me that it uses more cpu.

Bugfix: puppy boot(usbflash) device is now detected properly. and won't be un/mounted when clicked.
https://app.box.com/s/7nvvc5qpbbuol6jqhzyyr9ylvl2tpuaf
corvus wrote:...I personally use, via command line, a script (created by Yan Li in 2009), that need sdparm.

http://sg.danny.cz/sg/sdparm.html: "sdparm is designed for both the 2.6 and 2.4 Linux kernel series."
Argolance wrote:- There is a window that displays messages down right of the screen.
That's just an small notification to tell me the script has updated its menu and is ready to mount or unmount the next device. It is set to "echo" but it will use the next line if available, gxmessage, then yaf-splash, yad and notify-send.
You can comment out these lines to disable it.

Code: Select all

[ "$(which gxmessage)" ] && MSG_CMD="gxmessage -borderless -nofocus -bg black -fg white -timeout 3"
[ "$(which yaf-splash)" ] && MSG_CMD="yaf-splash -close box -timeout 3 -placement bottom-right -bg black -fg white -text"
[ -e "/usr/lib/gtkdialog/box_splash" ] && MSG_CMD="/usr/lib/gtkdialog/box_splash -close box -timeout 3 -placement bottom-right -bg black -fg white -text"
[ "$(which yad)" ] && MSG_CMD="yad --no-buttons --borders 10 --skip-taskbar --no-focus --undecorated --timeout-indicator bottom --text-align=left --timeout 5 --geometry=200x50-10-50 --text"
[ "$(which notify-send)" ] && MSG_CMD="notify-send -t 5000 -u normal"	
B.K. Johnson wrote:I called wow's usb_systray, ... renamed *.mo to pusitray.mo and put it in /usr/share/locale/en/LC_MESSAGES/
Try to rename the .mo file to usb_systray.mo. Both must have the same filename.
B.K. Johnson wrote:The NTFS device (sda1) was not listed. PMount worked.
This script its designed to work only with usb drives, it will ignore puppy boot device, internal sata drives or other storage devices.
B.K. Johnson wrote:Nothing happens neither when I click the script in /root/my-applications/bin/ nor on booting. The icon does not show.
Try to install a more recent version of yad, also try to run the script from command line.
Last edited by wow on Wed 29 Mar 2017, 18:43, edited 3 times in total.

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#24 Post by B.K. Johnson »

wow suggested here
Try to install a more recent version of yad, also try to run the script from command line.
Sure enough, when pusitray is executed from the command line, I got this error:

Code: Select all

root# pusitray
MSG_CMD=yad
Unable parse command line: Unknown option --borders
root# 
YAD-0.38.2 is available from SourceForge.
From the README, it doesn't look like the standard ./configure && make && make install procedure.
Can some good soul please compile and prepare a pet or sfs?
Thanks.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
nilsonmorales
Posts: 972
Joined: Fri 15 Apr 2011, 14:39
Location: El Salvador

#25 Post by nilsonmorales »

Version 11: I've tried to do different events, so far everything seems to work fine. Is nice 'honesty' :D
Image
[b][url=http://nilsonmorales.blogspot.com/]My blog |[/url][/b][b][url=https://github.com/woofshahenzup]| Github[/url][/b]
[img]https://i.postimg.cc/5tz5vrrX/imag018la6.gif[/img]
[img]http://s5.postimg.org/7h2fid8pz/botones_logos3.png[/img]

User avatar
nilsonmorales
Posts: 972
Joined: Fri 15 Apr 2011, 14:39
Location: El Salvador

#26 Post by nilsonmorales »

B.K. Johnson
greengeek provides this package for 32 bits here http://murga-linux.com/puppy/viewtopic. ... 055#890055
[b][url=http://nilsonmorales.blogspot.com/]My blog |[/url][/b][b][url=https://github.com/woofshahenzup]| Github[/url][/b]
[img]https://i.postimg.cc/5tz5vrrX/imag018la6.gif[/img]
[img]http://s5.postimg.org/7h2fid8pz/botones_logos3.png[/img]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#27 Post by B.K. Johnson »

nilsonmorales
Thanks for the link, Let you know how it works out.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#28 Post by B.K. Johnson »

Nilson wrote:

greengeek provides this package for 32 bits here http://murga-linux.com/puppy/viewtopic. ... 055#890055
Got it. It is a version several revisions earlier than the latest on the website. However, it is good enough for psuitray to display its icon in the tray. WORKING (almost, see below). Thanks again.

However there is a particular niggle that needs work.
Nilson, as your command of English is better than wow's, please translate for him.

ATM, I have 3 storage devices attached
sda1 HD NTFS
sdb1 Flash FAT32 boot drive tahr-6.0.5
sdc1 Flash FAT32
Prior to installing pusitray and since installing it, at boot, sdb1 is mounted and so indicated with a tab; other devices are unmounted - no tabs.
In the psuitray infobox, sda1, being an NTFS it doesn't appear (understood). Both sdb1 and sdc1 have + before them in the infobox to indicate unmounted.but this is not true. sdb1 is mounted. It is /home, is always mounted and should have a permanent '-' sign. Secondly, when the '+' before sdc1 is clicked, the contents are displayed, but a tab on the icon to indicate mounted does not appear. Thirdly, if I click on the sdc1 icon, the indicator tab appears and contents listed, but the '+' in psuitray does not change. Clicking '+' once displays the contents and message that it is being mounted when it already has been. Then on clicking the '-' sign, the device is unmounted and the tab correctly removed.

To summarize:
(1) the boot drive should always have a '-'
(2) when '+' is selected to mount a device, an indicator tab should appear on the corresponding icon.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

wow
Posts: 1052
Joined: Fri 30 Jun 2006, 00:18
Location: Peru

#29 Post by wow »

B.K. Johnson wrote:...
sdb1 Flash FAT32 boot drive tahr-6.0.5
...
Both sdb1 and sdc1 have + before them in the infobox to indicate unmounted.but this is not true. sdb1 is mounted. It is /home, is always mounted and should have a permanent '-' sign
Fixed. It now displays puppy version and won't allow user to mount or unmount.
Image
http://murga-linux.com/puppy/viewtopic. ... 888#946888

User avatar
nilsonmorales
Posts: 972
Joined: Fri 15 Apr 2011, 14:39
Location: El Salvador

#30 Post by nilsonmorales »

YAD version 0.38.2 shows the icon too small in the tray, so I compiled 0.38.1 in x-tahr (tahrpup fork), that seems to work fine

Code: Select all

autoreconf -ivf
./configure --prefix=/usr
make
make DESTDIR=/tmp/yad-0.38.1 install
cd /tmp
dir2pet yad-0.38.1
petget yad-0.38.1.pet
$ yad --version
0.38.1 (GTK+ 2.24.23)
https://my.pcloud.com/publink/show?code ... 3IHFiyrJH7
[b][url=http://nilsonmorales.blogspot.com/]My blog |[/url][/b][b][url=https://github.com/woofshahenzup]| Github[/url][/b]
[img]https://i.postimg.cc/5tz5vrrX/imag018la6.gif[/img]
[img]http://s5.postimg.org/7h2fid8pz/botones_logos3.png[/img]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#31 Post by B.K. Johnson »

@wow, nilson
Thanks guys. I'll get around to testing soon.
BK
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#32 Post by slavvo67 »

I'm not sure if this is solved. Maybe this runs different in Quirky than Puppy but I notice the following:

1. There is no way to remove. Luckily, I rebooted and it went away.

2. It did not recognize SDA1 and SDA2. It only recognized SDB1 and SDB2.

Possibly unrelated but I had trouble opening my browsers after installing, too.

Nice little project but not sure how practical this is.

Slavvo67

User avatar
nilsonmorales
Posts: 972
Joined: Fri 15 Apr 2011, 14:39
Location: El Salvador

#33 Post by nilsonmorales »

slavvo67
The script tries to show when a usb is inserted from the system tray, that way I do not forget that physically there is one inserted in my computer, the other are extras that the programmer has added, eg, mount and unmount, tooltips, etc. from the systray.
1. There is no way to remove. Luckily, I rebooted and it went away
.
to test the script you need open a terminal and type ./the-script-name, to cancel just type ctrl+c or close the terminal, if you did a click on it, just open the terminal and type pkill the-script-name
2. It did not recognize SDA1 and SDA2. It only recognized SDB1 and SDB2.

Are sda1,sda2 hard disks? this don't work with hard disk just usb drives
Possibly unrelated but I had trouble opening my browsers after installing
Yes, unrelated.
not sure how practical this is.
It is to me, forgive my alzhaimer
[b][url=http://nilsonmorales.blogspot.com/]My blog |[/url][/b][b][url=https://github.com/woofshahenzup]| Github[/url][/b]
[img]https://i.postimg.cc/5tz5vrrX/imag018la6.gif[/img]
[img]http://s5.postimg.org/7h2fid8pz/botones_logos3.png[/img]

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#34 Post by slavvo67 »

Thanks for the though on this. Yes, for remembering the USB is there is quite important!! I tend to have other problems such as having multiple USB's plugged in and forgetting which is the system. LOL

Anyway, based on what your telling me the project is for, it seems to work good.

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#35 Post by B.K. Johnson »

@Nilson
Sorry to say, It's not solved!
@wow
It needs another tweak to make the script GUI and the desktop drive icon be always in sync, conveying the same info on the device's mount/unmount status.
.
In the attached screenshots, sdb1 is the boot drive with always mounted indicator.

When a usb drive is mounted from the script's dialogbox, rhe drive contents are displayed in ROX and the "Mounting" message is displayed, but the mount indicator tab is not appended to the desktop drive icon. A subsequent right-click shows the Minus sign against that drive. So, I can't tell from the desktop drive icon that the drive is already mounted. And since the drive is indeed mounted, a subsequent clicking on the drive icon in that state does not add the indicator. I get only the ROX display. Of course, Reload (GUI) changes nothing in the GUI, and has no effect on the drive icon. See Fig. 1.

Fig. 2 shows what happens from a fresh boot followed by a click of the drive icon.

If after booting to a virgin desktop and executed script, I click on a drive icon, the mount indicator is attached to the drive icon, but the script's display is unchanged i.e. it retains its Plus sign, indicating an unmounted state. The script GUI and the desktop drive icon is out of sync - .the drive icon is shown as mounted, but the GUI does not reflect this state Although Reload brings them back in sync, that IMHO is a crutch we don't want.

It seems to me that the script needs code to check the drive state, and to bring the GUI and drive icon in synch..
Attachments
attachment-pusitray-bug.png
GUI and drive icon mount indicator out of sync
(45.23 KiB) Downloaded 203 times
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

some1
Posts: 117
Joined: Thu 17 Jan 2013, 11:07

#36 Post by some1 »

Please!!!

wow has provided a very nice script.
---
The script does this:
1. Notifies user WHEN an usb-storage is ATACHED or DETACHED.
2. Allows user to MOUNT/UNMOUNT attached usb-storages
3. Provides info on attached usb-storages.
4. Allows user to call pmount.
The script is not - as is - intended to handle HDs,CDs or FDs.
---
The script is very well commented.
If spanish is a problem:- run the comments through a translator -f.x Google translate.
---
Its correct - that the script - as is -does not update the desktop-drive-icons following a mount/unmout from inside the script-menu.

Not everyone has drive-icons on the desktop -some really like a clean desktop.
Some only have removable storages.
---
Coders may want to take a look -and learn some.

Thanks wow.

wow
Posts: 1052
Joined: Fri 30 Jun 2006, 00:18
Location: Peru

#37 Post by wow »

B.K. Johnson wrote:It needs another tweak to make the script GUI and the desktop drive icon be always in sync, conveying the same info on the device's mount/unmount status.
That would be a nice feature, but it's not meant to work like that. Also, the pinboard icons won't be updated if you mount a vfat o ntfs filesystem with the script because it mounts those filesystems with the "mount-FULL" command instead of "mount" (which is a wrapper for mount-FULL) and I don't want to modify external scripts like the "mount" script/wrapper.

tenochslb

pusiTRAY is not PMOUNT or wants to be PMOUNT

#38 Post by tenochslb »

The script is intended as a helpful option for those users that prefer a clean desktop (no icons). PUSITRAY is NOT intended as a replacement for PMOUNT. It was coded out of the need to be able to see if usb/sdcard (NOT Hard Drives) storage devices are plugged into the system from the ptray. It is very easy to lose flash drives by simply forgetting they are connected to usb ports in cpu towers.
The developer included the ability to launch pmount, a faster mounting for vfat, and an information box.
Final code can be read here

High Quality Screenshot
Image

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#39 Post by B.K. Johnson »

Nilson asked for help with his script
that notify me when un/plug a usbdrive device in the systray
and
show an icon in systray when I plug my usbdrive, and if possible showme some kind of info like mount point, space left, i dont know, mount/umount would be great.
The capability to mount/unmount was the least important functionality, an afterthought.

Nilson gave as his reason for wanting the tray icon:
just because somethimes forget unplug when leave
and tenochslb wrote:
It was coded out of the need to be able to see if usb/sdcard (NOT Hard Drives) storage devices are plugged into the system from the ptray. It is very easy to lose flash drives by simply forgetting they are connected to usb ports in cpu towers. (my emphasis)
I must be missing some brain cells here for I don't understand. Would it not take the same effort to look at the tower's USB port as it does to look at the systray? If you are going to remember to look for the tray icon, why would you not remember to look at the tower's usb port? What is it that will stop you from leaving /ending the session with the tray icon still showing and the drive in the USB port?

tenochslb contends without saying where it is stated that
The script is intended as a helpful option for those users that prefer a clean desktop (no icons).
However, Nilson did not say that he had a non-standard desktop, without drive icons. Neither did wow make such an assertion. JWM is the standard window manager on most puppies including mine. Slacko and tahr which are the current puppy standard bearers, as well as all of Barry's pups and near pups, have drive icons. If your puppy is non-standard by these criteria, then be happy that pusitray meets your needs. As it exists now, it doesn't meet mine and will not meet that of the majority of users. On reflection, it could have been inferred that Nilson was operating from a 'clean desktop' also. Without an explicit statement that the script was needed for or designed for 'clean desktops', it was natural for me to assume a standard desktop with drive icons.

What interested me when Nilson posted his request was the audio. When I have all my three desktop panels/windows filled and then insert a usb device, I either have to scroll up pages in one window or toggle the Show Desktop icon in the tray in order to see if the inserted USB is recognized and to mount it. No big deal, but with the script, I anticipated that the audio would be a quick indicator, leaving me only to right-click and mount the device from the script GUI. No clearing of panel. I further expected to use right-click and mount/unmount the device(s), using the script's GUI, but the thought of the desktop drive icon and the GUI having a different status never entered my mind.

@wow
Implicit in Nilson's post was a request for mount point, free space and the ability to mount/umount the SINGLE device that had been just plugged in. You should have been aware of the need for your GUI and drive icons to be in sync. A single device out of sync is bad, but having multiple devices potentially out of sync is a disaster. How can you treat it as nothing? How can you say
That would be a nice feature, but it's not meant to work like that.
Feature? How was it meant to work? Like it does now - out of sync? Are you satisfied with the non-sync situation?
Also, the pinboard icons won't be updated if you mount a vfat o ntfs filesystem with the script because it mounts those filesystems with the "mount-FULL" command instead of "mount" (which is a wrapper for mount-FULL) and I don't want to modify external scripts like the "mount" script/wrapper.and offer reasons why it can't be done.
NTFS, you stated before. First time for VFAT. But why are you bringing VFAT and NTFS into the conversation? Those formats were not in the issue I wrote about. The drive was a USB flash drive thst is formated as FAT32. The problem arose from making choices without any consideration of those systems with drive icons, perhaps because your system is without drive icons.

Clearly, you don't see this synchronization issue as a problem and won't be doing anything about it. If I understood Spanish and was a coder, I would (for my personal use only) disable both the left-click and right-click functionality, leaving me only with the sound at insertion and removal, the tooltip and the tray icon. Can you at least indicate what lines can be deleted/modified to accomplish this?
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

wow
Posts: 1052
Joined: Fri 30 Jun 2006, 00:18
Location: Peru

#40 Post by wow »

B.K. Johnson wrote:why would you not remember to look at the tower's usb port?
I told him so. But he has his reasons and I was really bored and want to take a look at thad YAD thing he was talking on IRC and learn some bash scripting.
B.K. Johnson wrote:However, Nilson did not say that he had a non-standard desktop, without drive icons. Neither did wow make such an assertion.
He told us that on IRC, after the "why don't you look at the usb ports? /slap!" question. Were is where all of this started.
B.K. Johnson wrote:You should have been aware of the need for your GUI and drive icons to be in sync. A single device out of sync is bad, but having multiple devices potentially out of sync is a disaster.
This is a standalone project, it is not designed to work along with puppy's desktop drive icons, in the same way it is not designed to work with this script.

And now I will tell you a "secret", this is how mounting works. For example, I want to mount /dev/sda2(ext4) on /mnt/sda2, so I run

Code: Select all

mount-FULL /dev/sda2 /mnt/sda2
- In puppy "mount" is a script, not the real "mount" program.
- "mount-FULL" is the real program. This script uses it to mount vfat and ntfs filesystems.
- Puppy's desktop drive icon for sda2 remain unchanged, it doesn't show the "Unmount Button" in the upper right corner.
- The "mount" script/wrapper is the one that runs that kind of stuff like send a signal to change the icon on the pinboard.

Image

I don't want to change other people scripts (mount), that's why it's not in "sync" with the pinboard.
B.K. Johnson wrote:What interested me when Nilson posted his request was the audio.
You don't need to write a script, just run this line:

Code: Select all

while true; do EVENTS=$(pup_event_ipc "block:usbdrvsound"); [ "${EVENTS::3}" = "add" ] && aplay /usr/share/sounds/bark.au || aplay /usr/share/sounds/2barks.au done

Post Reply