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
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

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

#41 Post by B.K. Johnson »

@wow
I appreciate you taking the time to respond to my last post, :D for the "secret" lesson on how mounting works :D :D and the code for the barks on insertion and removal :D :D :D . Thanks.

You wrote:
I don't want to change other people scripts (mount)...
I heard you the first time and accept that you are on solid ground. :) That's why at the end of my last post, I asked in an indirect way if you could tell me how to modify the script to disable the right-click functionality. When that is done, I can't mount/unmount any device and the issues of (a) changing other people's scripts and (b) synchronization disappear. I will still hear the barks and have the tooltip with info on the inserted USB drive(s). That is what I wanted, nothing more. :wink:

If you prefer to instruct by PM, that is fine with me. However, a statement in the thread like
If your puppy has desktop drive icons, you should modify the script as follows:
<<script modifications instructions.>>
would result in the thread providing a solution to those with 'clean desktops' as well as those without - a win-win.

Your choice.
Please consider and thanks in advance, whichever you choose.
[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
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#42 Post by MochiMoppel »

@nilsonmorales
wow has put together a really nice little app that obviously does everything you asked for, but I still fail to understand why you need this. The main purpose, as I understand it, is to remember to unplug USB devices that you added after booting so your computer, when you reboot, does not try to boot from such "forgotten" device. Is that right? This would be a problem I can relate to since it happens to me too. But in your first post you stated "im trying to make a little script using yad that notify me when un/plug a usbdrive device in the systray ( just because somethimes forget unplug when leave )". How does the un/plug notification would help to remember to unplug after shutdown? For the same reason, how would the mounted/unmounted information help?

I understand that after a long day and after finally shutting down the machine it is unrealistic to expect you to check all your USB ports for leftovers, especially when the machine sits under the table. But I find it also unrealistic to expect that an icon, sitting in the tray, is a better protection. What am I missing here?

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

#43 Post by wow »

MochiMoppel wrote:I understand that after a long day and after finally shutting down the machine it is unrealistic to expect you to check all your USB ports for leftovers, especially when the machine sits under the table. But I find it also unrealistic to expect that an icon, sitting in the tray, is a better protection. What am I missing here?
The script autohides its icon if there are no usb storage devices detected. The icon will only be visible if an usb flash drive is plugged in.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#44 Post by MochiMoppel »

wow wrote:The icon will only be visible if an usb flash drive is plugged in.
I boot from a SD card and keep this card plugged it permanently (to avoid booting from HDD), which means that the icon is always visible. :cry:

But even if it would ignore the boot device and only show newly added devices I know that I probably wouldn't always pay attention to this icon when shutting down. On trains here I'm constantly reminded by announcements not to leave anything behind when I get off. Doesn't work either. I need stronger stimulants for my brain cells.

Anyway, if this works for nilsonmorales I have no point. For my own needs I've now created a small routine that doesn't use icons, tray or yad (and therefore doesn't fit his conditions). It's part of my shutdown script and simply checks if any devices that were added after booting are still plugged in. If there are, a big dialog warns me. Hopefully I won't see it too often :lol:

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

#45 Post by B.K. Johnson »

wow wrote:
The script autohides its icon if there are no usb storage devices detected. The icon will only be visible if an usb flash drive is plugged in.
That's a nice feature but like MochiMoppel, I boot from a flash drive so the icon is always in the tray. This feature doesn't answer the basic question I asked here and MochiMoppel here and you say here that you asked nilsonmorales in IIRC: How does the icon in the tray prevent forgetting that a flash drive is left when you leave. It would be nice for Nilson and tenochslb to let us understand the unique conditions they face. But I won't ask again. Let sleeping dogs lie.

MochiMoppel wrote:
I've now created a small routine that ... [is] part of my shutdown script and simply checks if any devices that were added after booting are still plugged in. If there are, a big dialog warns me.
I like that idea. :) It is a practical solution for when using kiosks, public libraries etc. and are permitted to boot your puppy. I can't personally relate to that as my library does not allow me to boot from my puppy. But I can relate to the possibility of packing away my laptop with the flash drive attached and breaking/bending it in the port. I once broke an earphone plug in my laptop audio jack in similar circumstances.

Would you mind posting your shutdown script 'as is' or modified? TIA.
[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]

Post Reply