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 22 Jun 2018, 21:29
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to place an executable icon in the systray area?[SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 4 [50 Posts]   Goto page: Previous 1, 2, 3, 4 Next
Author Message
fredx181


Joined: 11 Dec 2013
Posts: 3105
Location: holland

PostPosted: Mon 12 Mar 2018, 15:53    Post subject:  

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:
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 Smile )

Fred

_________________
Dog Linux website
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 3800
Location: King's Lynn, UK.

PostPosted: Mon 12 Mar 2018, 20:06    Post subject:  

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... Laughing )

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... Laughing)

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

Code:
#!/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:-




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

The script to run is this one:-

Code:
#!/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? Rolling Eyes)

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



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=eWZPd5Hm6s8&feature=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

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------


Last edited by Mike Walsh on Tue 13 Mar 2018, 06:04; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1538
Location: Japan

PostPosted: Tue 13 Mar 2018, 02:43    Post subject:  

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... Laughing )

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


Joined: 28 Jun 2014
Posts: 3800
Location: King's Lynn, UK.

PostPosted: Tue 13 Mar 2018, 06:26    Post subject:  

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.

Question What would you suggest? Question


Mike. Wink

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
puppy_apprentice


Joined: 07 Feb 2012
Posts: 184

PostPosted: Tue 13 Mar 2018, 10:57    Post subject:  

"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 Wink
try_2.png
 Description   Code
 Filesize   23.9 KB
 Viewed   175 Time(s)

try_2.png

try_1.png
 Description   Two buttons on right side
 Filesize   8.2 KB
 Viewed   177 Time(s)

try_1.png

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


Joined: 26 Jan 2011
Posts: 1538
Location: Japan

PostPosted: Tue 13 Mar 2018, 11:20    Post subject:  

You may not be Mochi but you can read his mind Laughing
Left of the clock is a good place for a TrayButton.
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 3800
Location: King's Lynn, UK.

PostPosted: Tue 13 Mar 2018, 11:47    Post subject:  

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 Wink


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:
<!--   <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):-





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

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------


Last edited by Mike Walsh on Tue 13 Mar 2018, 12:30; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
drunkjedi


Joined: 24 May 2015
Posts: 897

PostPosted: Tue 13 Mar 2018, 12:21    Post subject:  

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


Joined: 28 Jun 2014
Posts: 3800
Location: King's Lynn, UK.

PostPosted: Tue 13 Mar 2018, 12:34    Post subject:  

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

Now I know differently! Cheers.


Mike. Wink

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
greengeek


Joined: 20 Jul 2010
Posts: 5054
Location: Republic of Novo Zelande

PostPosted: Tue 13 Mar 2018, 14:10    Post subject:  

Sounds like a good tip to be included in the newsletter don'cha think Mike?
Smile
LongWayHome.jpg
 Description   
 Filesize   55.83 KB
 Viewed   118 Time(s)

LongWayHome.jpg

Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 3800
Location: King's Lynn, UK.

PostPosted: Tue 13 Mar 2018, 14:45    Post subject:  

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

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
fredx181


Joined: 11 Dec 2013
Posts: 3105
Location: holland

PostPosted: Tue 13 Mar 2018, 15:30    Post subject:  

Hi Mike, good that it finally works for you. Smile

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

_________________
Dog Linux website
Back to top
View user's profile Send private message 
puppy_apprentice


Joined: 07 Feb 2012
Posts: 184

PostPosted: Tue 13 Mar 2018, 15:38    Post subject:  

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:
#!/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 Wink

Last edited by puppy_apprentice on Tue 13 Mar 2018, 15:39; edited 1 time in total
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 12323
Location: Gatineau (Qc), Canada

PostPosted: Tue 13 Mar 2018, 15:38    Post subject:  

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
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 3800
Location: King's Lynn, UK.

PostPosted: Tue 13 Mar 2018, 16:40    Post subject:  

@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..! Laughing 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.... Laughing

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

@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

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 3 of 4 [50 Posts]   Goto page: Previous 1, 2, 3, 4 Next
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.2980s ][ Queries: 13 (0.1001s) ][ GZIP on ]