Author |
Message |
stu91

Joined: 06 Aug 2012 Posts: 145 Location: England. Dpup. Dell Inspiron 1501
|
Posted: Wed 31 Oct 2012, 11:05 Post subject:
Yad sytem tray right click menu Subject description: Example |
|
Here is an example script of a yad system tray right click menu:
Code: | #!/bin/bash
## yad simple system tray right click menu ##
## menu file example in plain text file name!command ##
#Terminal!urxvt
#Paint!mtpaint
## Application menu file ###############################################
GET_MENU="$@"
########################################################################
function START_MENU () {
## MENU items ##########################################################
MENU_ITEMS="` cat "$GET_MENU" | tr '\n' '|' | sed '$s/.$//' `"
## Defaults ############################################################
TRAY_ICON="/usr/share/icons/hicolor/24x24/apps/yad.png"
POPUP_TEXT="system tray menu"
PIPE_FIFO=$(mktemp -u /tmp/menutray.XXXXXXXX)
## Action on left mouse click ###########################################
function LEFT_CLICK () {
exec 3<> $PIPE_FIFO
echo "quit" >&3
rm -f $PIPE_FIFO
}
export -f LEFT_CLICK
export PIPE_FIFO
## 1 Create PIPE_FIFO file #############################################
mkfifo $PIPE_FIFO
## 2 Attach a filedescriptor to this PIPE_FIFO #########################
exec 3<> $PIPE_FIFO
## 3 Run yad and tell it to read its stdin from the file descriptor ####
GUI=$(yad --notification --kill-parent --listen \
--image="$TRAY_ICON" \
--text="$POPUP_TEXT" \
--command="bash -c LEFT_CLICK" <&3 ) &
## 4 Write menu to file descriptor to generate MENU ####################
echo "menu:$MENU_ITEMS" >&3
}
## Check if menu file is provided ######################################
if [ -z "$GET_MENU" ]; then
echo "traymenu usage: $0 /path/to/menu/file" && exit
else
START_MENU
fi
######################################################################## |
Tray icon and popup text can be customised in script:
TRAY_ICON=
POPUP_TEXT=
Usage: is with a separate menu file which contains menu item name ! menu item command (see below, left is name - right is command - menu order top is first)
Code: | Terminal! urxvt
Paint! mtpaint
Text Edit! geany
Media! gnome-mplayer
Home! rox /root
Sda2! rox /mnt/sda2 |
To run: /path/to/script /path/to/menu/file
cheers.
Description |
remove fake .gz and make executable
|

Download |
Filename |
traymenu.gz |
Filesize |
1.62 KB |
Downloaded |
750 Time(s) |
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 4984 Location: Ontario
|
Posted: Thu 01 Nov 2012, 11:51 Post subject:
|
|
It worked when I tried it in Precise.
It would be more useful if running the terminal command
wasn't necessary each time the menu file was changed.
__________________________________________
|
Back to top
|
|
 |
stu91

Joined: 06 Aug 2012 Posts: 145 Location: England. Dpup. Dell Inspiron 1501
|
Posted: Thu 01 Nov 2012, 13:39 Post subject:
|
|
don570 wrote: | It worked when I tried it in Precise.
It would be more useful if running the terminal command
wasn't necessary each time the menu file was changed.
__________________________________________ |
Hi don570,
Thanks for testing and feedback
Im not quite sure i understand what you mean in the second lines of your post, could you give an example?
You do not need to use a menu file instead the menu could be put in the script by changing:
GET_MENU="$@"
to
GET_MENU='Terminal! urxvt
Paint! mtpaint
Text Edit! geany
Media! gnome-mplayer
Home! rox /root
Sda2! rox /mnt/sda2
'
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 4984 Location: Ontario
|
Posted: Thu 01 Nov 2012, 14:17 Post subject:
|
|
I was referring to a menu editor. (A couple already exist for Puppy)
So the user filled in fields rather than create a file.
Geany can open a document for example ---> so two fields
would be needed for each app
and maybe a button to click so previous tray icons quit.
Probably too much work.
__________
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 3431 Location: www.eussenheim.de/
|
Posted: Sat 10 Nov 2012, 11:01 Post subject:
Yad sytem tray right click menu Subject description: I'd like to have more of them |
|
Hi stu9x
I have have been playing with your script
TRAY_ICON="/usr/share/doc/puppylogo48.png"
POPUP_TEXT="one of my special mini menus "
Using
GET_MENU='Terminal! urxvt
Paint! mtpaint
'
MENU_ITEMS= has to be changed to
MENU_ITEMS="` echo "$GET_MENU" | tr '\n' '|' | sed '$s/.$//' `"
Having different TRAY_ICON and POPUP_TEXT for each menu now
Launched by Startup in precise
Very cool
though most of that code is "all Greek" to me
Description |
|
Filesize |
3.24 KB |
Viewed |
2816 Time(s) |

|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Wed 14 Nov 2012, 16:39 Post subject:
|
|
the way I got around all of the complexity in sit (simple icon tray) was to use user defined commands for the left and right click menus ... these can be simulated in gtkdialog by setting window-placement="2" in the <window> tag (I forget what it is in yad, but most dialog apps including Xdialog have similar near mouse window positioning abilities)
Also in sit all tooltips and icons get automagically refreshed if the image or tooltip file is changed and since the user defines the click actions, those can be changed on the fly too. so changing behavior is as simple as copying one icon over another icon, echoing to a tooltip text file or modifying the right/left-click action script/function/executable. The number of icons is unlimited, so AFAIK sit covers 99% of needs for creating tray apps and is only ~5kb
http://www.murga-linux.com/puppy/viewtopic.php?t=76431
There are also a lot of tips scattered throughout the thread for generating simple yet useful svg images within scripts as well as some examples for parsing data in a way that is useful for tray apps.
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3255 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Mon 09 Sep 2013, 05:40 Post subject:
|
|
Bonjour,
This Yad sytem tray right click menu is great and very useful.
Thanks!
I would like to know if it is possible to get small icons at the head of the entries of this right click menu? And if yes, how?
I succeeded in making such a menu using gtkdialog and by setting window-placement="2" in the <window> tag but:
- the bottom of the menu is hidden behind the JWM task bar.
- the icon is in the quick launch part of the JWM task bar
Cordialement.
Description |
Small gui running from an icon inside the quick launch part of the JWM task bar |
Filesize |
30.24 KB |
Viewed |
2088 Time(s) |

|
_________________

|
Back to top
|
|
 |
mikeb

Joined: 23 Nov 2006 Posts: 11100
|
Posted: Mon 09 Sep 2013, 06:55 Post subject:
|
|
oops I wish I could read but updating the menu is just a case of echoing to the pipe on >3 by whatever convenient means
mike
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3255 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Mon 09 Sep 2013, 07:07 Post subject:
|
|
Quote: | oops I wish I could read but updating the menu is just a case of echoing to the pipe on >3 by whatever convenient means |
Sorry, I don't understand what you mean!
Is it to say that such a menu exists, but simplier, without the "echoing to the pipe on >3". If yes where could I find it?
Cordialement.
_________________

|
Back to top
|
|
 |
mikeb

Joined: 23 Nov 2006 Posts: 11100
|
Posted: Mon 09 Sep 2013, 07:49 Post subject:
|
|
Sorry to confuse It was more a general reply to yad usage plus I messed up my post and quickly edited it... hence the 'oops'
Quote: | It would be more useful if running the terminal command
wasn't necessary each time the menu file was changed. |
rather than an answer to your question Argolance.
As for Icons the yad wiki might be helpful to you
http://code.google.com/p/yad/wiki/NotificationIcon
regards
Mike
Last edited by mikeb on Mon 09 Sep 2013, 08:21; edited 1 time in total
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3255 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Mon 09 Sep 2013, 08:10 Post subject:
|
|
OK, thanks!
_________________

|
Back to top
|
|
 |
|