Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 18 Aug 2017, 14:44
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Script to put usbdrive icon in systray (Solved)
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 3 [45 Posts]   Goto page: Previous 1, 2, 3
Author Message
B.K. Johnson

Joined: 12 Oct 2009
Posts: 599

PostPosted: Fri 24 Mar 2017, 12:09    Post subject:  

@wow, nilson
Thanks guys. I'll get around to testing soon.
BK

_________________
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

Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1421
Location: The other Mr. 305

PostPosted: Mon 27 Mar 2017, 20:06    Post subject:  

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
Back to top
View user's profile Send private message 
nilsonmorales


Joined: 15 Apr 2011
Posts: 910
Location: El Salvador

PostPosted: Mon 27 Mar 2017, 23:41    Post subject:  

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.
Quote:
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
Quote:
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
Quote:
Possibly unrelated but I had trouble opening my browsers after installing

Yes, unrelated.
Quote:
not sure how practical this is.

It is to me, forgive my alzhaimer

_________________
My blog | | Github


Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1421
Location: The other Mr. 305

PostPosted: Tue 28 Mar 2017, 14:59    Post subject:  

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.
Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 599

PostPosted: Wed 29 Mar 2017, 10:09    Post subject:  

@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..
attachment-pusitray-bug.png
Description  GUI and drive icon mount indicator out of sync
png

 Download 
Filename  attachment-pusitray-bug.png 
Filesize  45.23 KB 
Downloaded  31 Time(s) 

_________________
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

Back to top
View user's profile Send private message 
some1

Joined: 17 Jan 2013
Posts: 72

PostPosted: Wed 29 Mar 2017, 12:32    Post subject:  

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.
Back to top
View user's profile Send private message 
wow

Joined: 29 Jun 2006
Posts: 1034
Location: Peru

PostPosted: Wed 29 Mar 2017, 18:21    Post subject:  

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.
Back to top
View user's profile Send private message 
tenochslb

Joined: 10 Jul 2010
Posts: 62
Location: Mexico

PostPosted: Wed 29 Mar 2017, 23:22    Post subject: pusiTRAY is not PMOUNT or wants to be PMOUNT
Subject description: Puppy Usb/Sdcard Simple Interface TRAY (p.u.s.i.Tray)
 

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
Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 599

PostPosted: Fri 31 Mar 2017, 02:16    Post subject:  

Nilson asked for help with his script
Quote:
that notify me when un/plug a usbdrive device in the systray

and
Quote:
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:
Quote:
just because somethimes forget unplug when leave

and tenochslb wrote:
Quote:
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
Quote:
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
Quote:
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?

Quote:
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?

_________________
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

Back to top
View user's profile Send private message 
wow

Joined: 29 Jun 2006
Posts: 1034
Location: Peru

PostPosted: Fri 31 Mar 2017, 16:52    Post subject:  

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



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:
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
Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 599

PostPosted: Fri 31 Mar 2017, 23:07    Post subject:  

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

You wrote:
Quote:
I don't want to change other people scripts (mount)...

I heard you the first time and accept that you are on solid ground. Smile 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.

_________________
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

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1326
Location: Japan

PostPosted: Sat 01 Apr 2017, 00:54    Post subject:  

@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?
Back to top
View user's profile Send private message 
wow

Joined: 29 Jun 2006
Posts: 1034
Location: Peru

PostPosted: Sat 01 Apr 2017, 03:52    Post subject:  

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.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1326
Location: Japan

PostPosted: Sat 01 Apr 2017, 09:37    Post subject:  

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. Crying or Very sad

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 Laughing
Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 599

PostPosted: Sat 01 Apr 2017, 13:10    Post subject:  

wow wrote:
Quote:
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:
Quote:
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. Smile 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.

_________________
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

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 3 [45 Posts]   Goto page: Previous 1, 2, 3
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0718s ][ Queries: 15 (0.0052s) ][ GZIP on ]