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 Wed 17 Sep 2014, 07:55
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Yad sytem tray right click menu
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [11 Posts]  
Author Message
stu91


Joined: 06 Aug 2012
Posts: 145
Location: England. Dpup. Dell Inspiron 1501

PostPosted: 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.
traymenu.gz
Description  remove fake .gz and make executable
gz

 Download 
Filename  traymenu.gz 
Filesize  1.62 KB 
Downloaded  460 Time(s) 
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3282
Location: Ontario

PostPosted: 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
View user's profile Send private message 
stu91


Joined: 06 Aug 2012
Posts: 145
Location: England. Dpup. Dell Inspiron 1501

PostPosted: 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 Cool

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
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3282
Location: Ontario

PostPosted: 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
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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 Cool
though most of that code is "all Greek" to me
tray_menu.png
 Description   
 Filesize   3.24 KB
 Viewed   973 Time(s)

tray_menu.png

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


Joined: 18 May 2008
Posts: 4351

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

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1825
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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
Sad

Cordialement.
130909_114605_525x237_easyshot.png
 Description   Small gui running from an icon inside the quick launch part of the JWM task bar
 Filesize   30.24 KB
 Viewed   445 Time(s)

130909_114605_525x237_easyshot.png


_________________

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


Joined: 23 Nov 2006
Posts: 8252

PostPosted: 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
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1825
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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! Embarassed
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
View user's profile Send private message Visit poster's website 
mikeb


Joined: 23 Nov 2006
Posts: 8252

PostPosted: 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
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1825
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Mon 09 Sep 2013, 08:10    Post subject:  

OK, thanks!
_________________

Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 Posts]  
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.0815s ][ Queries: 13 (0.0043s) ][ GZIP on ]