How to place an executable icon in the systray area?[SOLVED]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#31 Post by fredx181 »

Hi again Mike,
Just thinking, if your only need is simply to click on the icon and execute your script, just try musher0's suggestion for a one-liner (at one of the first posts in this thread)
Something like (this avoids the PIPE creating stuff, which has more possibilities (such as right-click menu), but apparently could be problematic, as you experienced):

Code: Select all

yad --notification --command='/usr/local/bin/spot-to-root' --image='/usr/local/share/icons/green-tick.png' 2>/dev/null
Should work ! (I'll eat my hat if it doesn't :) )

Fred

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#32 Post by Mike Walsh »

Hi, Fred.

Hm. I must have missed that one, somehow...

Just tried it out, and.....no need to go any further, mate. That does exactly what I want. How does that mantra go? 'K.I.S.S..' (Keep it simple, stupid... :lol: )

I've learnt quite a bit during the course of this thread.....about Zenity/Yad, for one thing. (And how it seems to be very easy to get carried away when you're scripting... :lol:)

Credits to both you and musher0. The final 'S2R.sh' script looks like this:-

Code: Select all

#!/bin/sh
#
#YAD 'one-liner' from musher0 / fredx181, to place executable tray icon in notification area
#
yad --notification --text="S2R file transfer" --command='/usr/local/bin/spot-to-root' --image='/usr/local/share/icons/green-tick.png' 2>/dev/null
I've added in the code for the tooltip text. Which gives us this:-


Image

-------------------------------------------------------------

The script to run is this one:-

Code: Select all

#!/bin/sh
#
# spot chown script to return ownership to root & move files between directories - Mike Walsh (02/02/17)
#
# Move contents of ~/Spot/Downloads to intermediate folder, change ownership, then move those files to your 'Downloads' folder 
#
mv -v ~/spot/Downloads/* /usr/share/Spot2Root/
chown root:root -R /usr/share/Spot2Root/
mv -v /usr/share/Spot2Root/* ~/Downloads/"#1CHROME_Downloads"
#
# Finish by deleting contents of Spot2Root ready for next time
#
rm -rf /usr/share/Spot2Root/*
#
# Run Zenity dialogue to confirm transfer was successful
#
zenity --info --title="File transfer successful..." --text="Your files have been transferred to
/root/Downloads/#1CHROME_Downloads
------------------------------------------------------
        Ownership has been changed
                     to root:root"
(I had to enclose the target directory in "quotes" because I use the hash mark (#) in the folder name. Bash (of course) interprets it as a 'comment out' symbol, doesn't it? :roll:)

I also added a Zenity info-text box which confirms the transfer was successful:-

Image

And before anyone says it, yah, I know Zenity is the forerunner of YAD.....but I happen to think it just looks neater, somehow.


And what all this ultimately does, is as follows; a wee video to demonstrate:-

https://www.youtube.com/watch?v=eWZPd5H ... e=youtu.be

(Apologies if the first few seconds of this are 'out-of-focus'. For some unknown reason, my YouTube vids always seem to do this....)

----------------------------------------------------------------------------------------------------

Postscript/background:- What prompted all this was the way in which current 64-bit Chrome will only run as 'spot' (Pup's equivalent of a 'normal user'). This, for me, is in Tahr64. However, I'm also running an older version of the Iron browser as 'spot' in Slacko 570. Both download with 'spot' permissions; this was an interesting wee excercise in seeing whether I could script a method for moving these from ~/spot/Downloads to a dedicated folder in my main 'Downloads folder (which is sym-linked into every Pup from a remote partition).....and change ownership along the way.

It's also taught me about some of the basic Bash commands.....which I've been meaning to get a handle on for ages. I started working on this script sometime around 12 months ago, when peebee and I both had to start employing methods to fool Chrome/Chromium into thinking it was running as a normal user.....even while running as /root. This is when head honcho Micko pointed me towards Iguleder's libpuppygc.so; a small library Iggy had written to do exactly this, implemented via the 'LD_PRELOAD' command:-

http://www.murga-linux.com/puppy/viewtopic.php?t=72667

.....so, for a while (at least), this got put aside again.

Anyway, it's been an interesting excercise in joining-up several bits & pieces I've been fooling around with for some time now. It's astonishing (to me, at any rate) just how many different files you need to put together even for something as basic like this...

Once again, many thanks to all who've contributed to the thread.

I'll mark this as 'Solved'! Cheers, guys.


Mike. :wink: Image
Last edited by Mike Walsh on Tue 13 Mar 2018, 10:04, edited 1 time in total.

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

#33 Post by MochiMoppel »

Mike Walsh wrote:Just tried it out, and.....no need to go any further, mate. That does exactly what I want. How does that mantra go? 'K.I.S.S..' (Keep it simple, stupid... :lol: )
Hi Mike, I see that you are happy and I don't want to spoil the party, but what I still don't understand: This seems to be exactly what a much more simple TrayButton would do. Why was this never an option for you? Now you have an instance of yad running permanently, doing nothing but waiting for you to click the icon. Seems to me like a complicated way to mimic a static shortcut and a lot of waisted processing power. Or is there more to this? If you want to "start" your icon only occasionally I would see a point, but without such background info I'm puzzled.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#34 Post by Mike Walsh »

Morning, Mochi.

'TrayButtons'... Hm. I think that's what drunkjedi was talking about back near the start of this thread, wasn't it?

I tried this, Mochi, but simply could not get a TrayButton to show up on the right-hand side (in the notification area). I'll own that I'm still pretty much a noob with all this kinda stuff, so.....it's quite 'on the cards' that I wasn't doing it correctly, or didn't have my syntax right, or something like that.

If there's a simpler way of doing this kind of thing.....I'm all ears. The K.I.S.S principle works pretty well for most things; the less there is to go wrong, the better, as far as I'm concerned.

YAD got mentioned during this thread; YAD and Zenity are both things I've been meaning to have a play around with for a long time. Example scripts got published; more examples (with modifications) came in; okay, I admit it.....we all got kinda focused on one way of solving the problem.

I'm in the early stages of 'playing-around', and experimenting with a lot of different things, Mochi. I'm more than happy to try anything out; I've got no fixed 'conceptions' of what should (or shouldn't) be done, so.....if you have any suggestions for a different (or simpler) way of doing the above (a single, static icon in the notification area, with tooltip, which when clicked on will execute a script), then I would love to hear it.

Processing power is not really an issue here. Although this is a 12-year old desktop PC, it was powerful for its time, and has long since been 'tricked out to the max' with the highest grades and amounts of everything it'll run. Having said that, I also run an even older Puppy laptop that does have serious constraints on what it'll do.....so I'm more than happy to try out multiple ways of approaching the same problem.

:?: What would you suggest? :?:


Mike. :wink:

User avatar
puppy_apprentice
Posts: 299
Joined: Tue 07 Feb 2012, 20:32

#35 Post by puppy_apprentice »

"if you have any suggestions for a different (or simpler) way of doing the above (a single, static icon in the notification area, with tooltip, which when clicked on will execute a script), then I would love to hear it."

I'm not Mochi but i put on a table my 3 cents ;)
Attachments
try_2.png
Code
(23.9 KiB) Downloaded 225 times
try_1.png
Two buttons on right side
(8.2 KiB) Downloaded 227 times

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

#36 Post by MochiMoppel »

You may not be Mochi but you can read his mind :lol:
Left of the clock is a good place for a TrayButton.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#37 Post by Mike Walsh »

puppy_apprentice wrote:"if you have any suggestions for a different (or simpler) way of doing the above (a single, static icon in the notification area, with tooltip, which when clicked on will execute a script), then I would love to hear it."

I'm not Mochi but i put on a table my 3 cents ;)
Well, you're both absolutely right, it seems! I've just been playing around with this for the last half-hour or so.

I wasn't aware that you could place TrayButtons anywhere on the tray. I thought these had to stay on the 'launcher' side..... (*shrug*)

I apparently didn't read drunkjedi's post carefully enough:-
drunkjedi wrote:Make the code as in left side area and put it in the swallow area before the code for clock.
And you will get the icon there. That's what I remember.
I thought this had to be written in 'Swallow' format, y'see; probably why I couldn't make it work.

Anyway; modifying the tail-end of /root/.jwmrc-tray to read as follows:-

Code: Select all

<!--	<Swallow name="freememapplet" width="34">
			freememappletshell
		</Swallow> -->
		<Swallow name="xload" width="32">
			xload -nolabel -bg "gray45" 
		</Swallow>
		<TrayButton popup="S2R file transfer" icon="/usr/local/share/icons/green-star.png">exec:/usr/local/bin/spot-to-root</TrayButton>
		<Clock format="%a %d %b %H:%M">PupClockset</Clock>
	</Tray>
</JWM>
....gives us this (I'm now using a green star instead of a check-mark):-


Image


.....and clicking on it, /usr/local/bin/spot-to-root executes as normal. I'm happy with that, too!

As for a 'point to all this', essentially it's there for transferring any downloads from the ~/spot/Downloads folder across to my main, sym-linked Downloads folder (which runs from a remote partition), and changing ownership along the way. Whenever I download from any browser I have running as 'spot', I can click on it and transfer the files across. Some days I may not download anything at all; other days, I may be downloading a lot of stuff, much of which I may be wanting to use straight away.

peebee has set his current Chromium builds up to automatically transfer to /root/Downloads and change ownership as it does so. I, however, have my Chrome & Chromium-based browsers set to ask me where I want to send the download to.....so if I transfer things to the specified sub-folder, I can then move them to where I want, as and when I want.

I might even set things up, now I know you can do this, to have two or three buttons (each with a different-coloured star), to send stuff to one of 3 specific folders I generally send stuff to.....

------------------------------------------------------------

Quick question: I know /etc/xdg/templates/_root_jwmrc generates /root/.jwmrc. Does anything 'generate' /root/.jwmrc-tray.....or will this stay as I've set it, i.e., will it get overwritten by anything?

------------------------------------------------------------

Like I said, I'm trying out a lot of stuff at the moment.....just seeing what's what. That's now two methods I know of for doing this.

Thanks, Mochi (and puppy_apprentice).

Cheers!


Mike. :wink:
Last edited by Mike Walsh on Tue 13 Mar 2018, 16:30, edited 1 time in total.

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#38 Post by drunkjedi »

I am glad it worked.
I was away from home so couldn't test it myself and report, all I had was snippet from memory.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#39 Post by Mike Walsh »

Hiya, dj.

Yes, it certainly does work; nicely, too. As I said in the last post, I thought it had to be written in 'Swallow' format for that side of the tray. Don't know why I thought that, but.....there you go. :lol:

Now I know differently! Cheers.


Mike. :wink:

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#40 Post by greengeek »

Sounds like a good tip to be included in the newsletter don'cha think Mike?
:-)
Attachments
LongWayHome.jpg
(55.83 KiB) Downloaded 165 times

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#41 Post by Mike Walsh »

Hah!

Ah reckon ah was 'barking up the wrong tree', mate..... (*groan*)

It's all too easy to get tunnel-vision when you're trying to work on a specific problem!
greengeek wrote:Sounds like a good tip to be included in the newsletter don'cha think Mike?
Indeed I do. But I think credit should go to Mochi and drunkjedi for that one.....not me.


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#42 Post by fredx181 »

Hi Mike, good that it finally works for you. :)

Indeed for JWM, the TrayButton option is the best, sorry if I've put you on the wrong track.
(don't know much about JWM, also thought that a button is only possible on left hand side)

On the other hand the "yad tray-icon" might be useful also, since it works with all desktop environments, e.g. LXDE, XFCE, and panels e.g. tint2 , etc...
And it has some useful options, such as right-click menu etc.. (which you didn't explore.... yet... ?? :wink: )

Fred

User avatar
puppy_apprentice
Posts: 299
Joined: Tue 07 Feb 2012, 20:32

#43 Post by puppy_apprentice »

Mike Walsh wrote:I might even set things up, now I know you can do this, to have two or three buttons (each with a different-coloured star), to send stuff to one of 3 specific folders I generally send stuff to.....
or one button which starts script TryButton.sh:

Code: Select all

#!/bin/sh
gxmessage -nearmouse -buttons "HDD1:42,HDD2:52,HDD3:62,CANCEL:255" "Where to save?"
case $? in
  42) echo "Copying to HDD1" ;;
  52) echo "Copying to HDD2" ;;
  62) echo "Copying to HDD3" ;;
  *) echo "Operation Canceled" # or empty
esac
Mike Walsh wrote:Quick question: I know /etc/xdg/templates/_root_jwmrc generates /root/.jwmrc. Does anything 'generate' /root/.jwmrc-tray.....or will this stay as I've set it, i.e., will it get overwritten by anything?
Should persist everything. If no you can always do it again ;)
Last edited by puppy_apprentice on Tue 13 Mar 2018, 19:39, edited 1 time in total.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#44 Post by musher0 »

Being so jwm-centric is a sickness, you all know that, don't you? I think i'll suggest the
whole bunch of you "jwm tribe" for study at the local department of anthropology.

At least the yad solution has the merit of being available independently of any WM.

Geez.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#45 Post by Mike Walsh »

@fredx181:-
fredx181 wrote:Indeed for JWM, the TrayButton option is the best, sorry if I've put you on the wrong track.
(don't know much about JWM, also thought that a button is only possible on left hand side)
No worries. I know you've been working on yad-radio in recent days.... You're forgiven..! :lol: And I always like to keep my options open, anyway; the more the merrier, mate.
fredx181 wrote:And it has some useful options, such as right-click menu etc.. (which you didn't explore.... yet... ?? :wink: )
I haven't finshed playing about with it just yet.... :lol:

----------------------------------------

@puppy_apprentice:-

Mmm... Sehr interessante, Kolonel..!

I'll have a look into that when I get a chance. Cheers.

----------------------------------------

@musher0:-

Musher, Musher, Musher..... it's not a sickness at all, y'know. (Maybe a bit of an 'affectation', perhaps, but er.....a-HEM!!!)

Not all my Pups use JWM. One uses Openbox.....and Lucid (under rerwin's careful maintenance) uses fbPanel. (Mind you, learning how to use fbPanel is a whole different ball-game.....yes, indeedy!)

You're right in one respect, though; every 'panel' or WM out there has its own peculiarities.....but, 'JWM-centric'? Puh-leeze...


Mike. :wink:

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#46 Post by smokey01 »

http://murga-linux.com/puppy/viewtopic. ... =985608536

This should do what you want as well.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#47 Post by Mike Walsh »

smokey01 wrote:http://murga-linux.com/puppy/viewtopic. ... =985608536

This should do what you want as well.
Cheers for that, Grant. Nice to know we have plenty of options available. And to think all the elder 'guru' critics accuse Puppy of being a 'toy' distro..! (As if Ubuntu, Slackware, Debian, et al, are all so bloody perfect..!!!) :roll: :shock: :lol:

I tell you one thing, mate; browsing many of the other Linux forums I belong to, you quickly realize one thing. Most of the mainstream distro's users are content to sit on their arses, bitch & moan loudly online, and wait for (and expect) someone else to write the software they want....

What do we do in Puppy? We get on with it, and write the software ourselves! Is it any wonder I love this community of ours..?

I think not. Pup rules, oh yes.... ♥ ♥ ♥ Image


Mike. :wink:

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

#48 Post by MochiMoppel »

Mike Walsh wrote:I apparently didn't read drunkjedi's post carefully enough: <snip> I thought this had to be written in 'Swallow' format
Good guess. Maybe you thought that for drunkjedi (look at his bottle!!) everything has to be in "swallow format" :wink:
Quick question: I know /etc/xdg/templates/_root_jwmrc generates /root/.jwmrc. Does anything 'generate' /root/.jwmrc-tray.....or will this stay as I've set it, i.e., will it get overwritten by anything?
puppy_apprentice already answered this. Only one additional thought: Judging from your video you already have customized your tray considerably. Particularly the fixed width items in your task list (right of the pager) look like buttons and in "normal" configurations would occupy whatever space is available in the tasklist. In your setup it leaves parts of the tasklist unused, which I find unusual and hard to set up manually without a good knowledge of JWM. So my guess is that you use a fronted GUI for your configurations (radky's excellent tools come to mind). If so then I see a chance that your right-sided TrayButton might not be recognized when you use such tool in the future. Such tools can never be as flexible as a manual edit and in my experience should either be used for all alterations or not at all. Mixing both methods can lead to unexpected results.

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#49 Post by drunkjedi »

MochiMoppel wrote:
Mike Walsh wrote:I apparently didn't read drunkjedi's post carefully enough: <snip> I thought this had to be written in 'Swallow' format
Good guess. Maybe you thought that for drunkjedi (look at his bottle!!) everything has to be in "swallow format" :wink:
Ha ha ha, that's somewhat true, I am a occasional drinker but when I drink I "swallow" whatever drink my friends throw at me. :wink:
The name is actually a mix of Jakie Chain's "Drunken Master" and a know it all "Jedi", from all the google searches that's the only pic I liked.

Anyways I should have worded that sentence differently to put emphasis on what I had to say. But it was almost midnight and closing time at work, so had to fill up logbooks, reports. So typed it in hurry.
When I have time I will look at tray in fatdog too and add to this thread what I find.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#50 Post by Mike Walsh »

Morning, Mochi.
MochiMoppel wrote:So my guess is that you use a fronted GUI for your configurations (radky's excellent tools come to mind).
Spot-on, actually. I do use radky's PupControl; didn't find out till several days after I'd first installed it that it also included the JWM DeskManager. Brilliant tool. Far more intuitive, and easier to use than the normal JWM settings panel (Menu->Desktop->JWM configuration). But then I've always liked big, bold GUIs.

Never liked a lot of Windoze GUIs, 'cos they're always so cramped, and jammed-full of tiny type that's hard to read. (I don't mind using the command-line either nowadays.....but if I'm going to use a GUI, then I want to able to see it clearly...)

In many respects, modern Linux wins hands-down in this respect.

---------------------------------------------
MochiMoppel wrote:...I see a chance that your right-sided TrayButton might not be recognized when you use such tool in the future. Such tools can never be as flexible as a manual edit and in my experience should either be used for all alterations or not at all. Mixing both methods can lead to unexpected results.
Point taken. We shall see what happens when I next run JWMDesk.

Anyway, the TrayButton for my script has persisted through several re-boots so far. All things being equal, it'll remain there indefinitely.

Time will tell.


Mike. :wink:

Post Reply