You are not logged in.
^ Hi tynman
It's a simple
^sep()
in the description field (the first field).
So a menu file could like like this
Terminal,xterm
^sep()
Browser,firefox
There are a couple of jgmenurc options for it too:
sep_height = 5
color_sep_fg = #ffffff 20
It also understands
^sep(some text)
Last edited by malm (2017-03-05 12:50:09)
Offline
Offline
Thank you!
Offline
Figured out how to use the jgmenu with the yad --list dialog
What is needed is another layer on top of yad dialog like gtk application in this case. Otherwise it's not going to work.
Ok, now a short how to. Two scripts are required, jgmenu, yad, xclip, firefox, python3-gi (gobject-introspection libraries):
1. Name it however you like, just change the path to the other script in this file
#!/bin/bash
function run_jgmenu
{
python3 << END
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import subprocess
class jgMenu:
def __init__(self):
jgmenu = subprocess.Popen(['/home/misko/Desktop/jgmenu03', '$1'])
stdoutdata, stderrdata = jgmenu.communicate()
exit()
def main(self):
Gtk.main()
if __name__ == "__main__":
app = jgMenu()
app.main()
END
}
export -f run_jgmenu
yad --list --column="#":text --column="Nick":text --width=500 --height=600 \
--dclick-action='bash -c "run_jgmenu $1"' "1" "Misko" "2" "Damo" "3" "Malm" "4" "Head Without a Stick"
2. name it jgmenu03
#!/bin/bash
printf \
"Copy,sh -c 'echo $1 | xclip -selection clipboard',gtk-copy\n\
Google Search,firefox https://www.google.com/search?q=$1,google" \
| jgmenu --at-pointer --stay-alive 2>/dev/null
(edit) *Forgot to mention double-click on a yad list item to activate the menu.
To use it with buttons check this post
Last edited by misko_2083 (2017-04-07 15:16:04)
Offline
Wow. That's very clever, bordering on mind boggling.
I'm not near a machine, but will have a play tomorrow.
Offline
If you can add "Paste" and "New Row" functionality that'd be perfect.
This yad --list dialog can listen for stdin data and can be cleared with echo -e '\f' before inserting new data.
Offline
^
Here is an alternative version. It avoids the python code and gtk dependency.
It also keeps all the code in one file.
#!/bin/bash
# In case jgmenu is already running in stay-alive mode
killall jgmenu >/dev/null
printf "%b" \
'Copy,cat /tmp/misko | xclip -selection clipboard,gtk-copy\n
Google Search,q=$(cat /tmp/misko | tr " " "+"); firefox https://www.google.co.uk/#q=$q,google\n' \
| jgmenu --at-pointer --stay-awake --hide-on-startup &
yad --list --column="#":text --column="Nick":text --width=500 --height=600 \
--dclick-action='bash -c "echo $1 >/tmp/misko; jgmenu_run"' "1" "Misko" "2" "Damo" "3" "Malm" "4" "Head Without a Stick"
test -e /tmp/misko && rm -f /tmp/misko
killall jgmenu >/dev/null
Do you mean "paste" and "new row" functionality for jgmenu or yad?
I found a bug in jgmenu whilst playing with this. I've just pushed a fix, so it'd advise pulling and re-compiling.
Last edited by malm (2017-04-08 22:38:07)
Offline
^
I found a bug in jgmenu whilst playing with this. I've just pushed a fix, so it'd advise pulling and re-compiling.
Thank you for fixing that bug, that makes things easier. I can run jgmenu without that py hack.
Your script works fine only on first run. After the second double-click on a yad list, it launces the pmenu.
Made some modifications and additions. Paste function is giving me a headake (xclip trouble), when pasting from external source. What can I do, I'm a lousy coder.
#!/bin/bash
test -e /tmp/yadpipe03 && rm -f /tmp/yadpipe03
# Named pipe initialization
export PIPE_03=/tmp/yadpipe03
mkfifo $PIPE_03
exec 3<> $PIPE_03
# Function to paste into new line (BROKEN)
# -----------------------------
function paste_new
{
if ! xclip -selection clipboard -o 2>&1 >/dev/null; then
:
else
echo "" > $PIPE_03
xclip -selection clipboard -o 2>/dev/null | sed 's/\&/\&/g' > $PIPE_03
fi
}
# ------------------------------
export -f paste_new
# Function to (re)load data
# ------------------------------
function load_data
{
local YAD_DATA=("1" "Misko" "2" "Damo" "3" "Malm" "4" "Head Without a Stick")
for DATA in "${YAD_DATA[@]}";do echo "$DATA" | sed "s/\&/\&/g" > $PIPE_03;done
}
# ------------------------------
export -f load_data
# Function to show the menu
# ------------------------------
function show_jg
{
local EXEC_NEW='yad --form --field="Number":num --separator="" | sed "s/\&/\&/g" > $PIPE_03; yad --form --field="Data":ce --separator="" | sed "s/\&/\&/g" > $PIPE_03'
local EXEC_COPY="echo '${@}' | xclip -selection clipboard"
local EXEC_CLEAR='echo "\f" > $PIPE_03; load_data'
local EXEC_GSEARCH="firefox \'https://www.google.com/#q=${@}\'"
killall jgmenu &>/dev/null
printf "%b" \
"New Row,$EXEC_NEW,gtk-new\n
Copy,$EXEC_COPY,gtk-copy\n
Paste in a New Row(Broken),paste_new,gtk-paste\n
Reload Data,eval $EXEC_CLEAR,gtk-refresh\n
Google Search,eval $EXEC_GSEARCH,google\n" \
| jgmenu --at-pointer
}
# --------------------------------
export -f show_jg
# Main Dialog
yad --list --column="#":text --column="Nick":text --width=500 --height=600 \
--dclick-action='bash -c "show_jg $1"' \
--listen --print-all < $PIPE_03 &
# Load data
load_data
One thing; is there a way of changing the internal field separator in jgmenu? Does it only creates new menu items on new lines "\n"?
The icons were missing, when I tried something like this:
OIFS=$IFS
IFS="\t"
printf .... \
..... \t
..... \t
..... \t \
| jgmenu
IFS=$OIFS
Offline
i don't know what your script is doing, but i noticed that you can eliminate a few pipes (each one opens a subshell) by using bash builtin string manipulation.
exampkle:
#!/bin/bash echo "$DATA" | sed "s/\&/\&/g" etc.
better:
echo "${DATA//&/&}"
BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
Offline
i don't know what your script is doing, but i noticed that you can eliminate a few pipes (each one opens a subshell) by using bash builtin string manipulation.
exampkle:
misko_2083 wrote:#!/bin/bash echo "$DATA" | sed "s/\&/\&/g" etc.
better:
echo "${DATA//&/&}"
Thanks, it's hard to get rid of the bad habbits.
The scrpipt is using jgmenu to manipulate with the data from yad --list dialog without closing that dialog. Just experimenting what jgmenu can do.
It cold be usefull if I decide to play with the zenity scripts I made for Linux Lite.
For example, I could use jgmenu to load different categories of software in Lite Software.
Lite Software
Or I could use it to add tasks in Lite Tweaks.
Lite Tweaks
Jerry (LL) has always insisted that we stick to zenity. I liked yad more, and now when I'm not in LL dev team I play with it even more. The problem is I don't have much free time as before.
Offline
@Misko, sorry I had missed these last couple of posts.
Your named pipe is neater than my simple tmp file
Although I think it would be easier to run jgmenu in short-lived mode for these yad scripts (recently added --simple for this).
Sorry to mess around with the defaults. I want to make it as easy as possible for those using jgmenu as a long-running start menu. Still early days
I'll have a play with yad. I'm sure between us we'll get there.
Offline
@malm Hey no problem at all.
That is what you designed it for in the first place.
This is a very usefull project for the community. Thank you creating jgmenu.
Offline
@misko
I've had a play with the code you posted on 10 April.
I think it works very well It's a nice solution.
Regarding the "xclip problem", if you put
echo "" > $PIPE_03
after the xclip line too if works fine (unless I'm missing the point of what you expect it to do).
Offline
^ regarding the IFS, yes we use fgets() and then change '\n' to '\0', so it's very much '\n'.
I think I'd prefer to keep it as it is, but am of course happy to re-consider if it is going to help solve a problem.
Offline
@misko
Regarding the "xclip problem", if you putecho "" > $PIPE_03
after the xclip line too if works fine (unless I'm missing the point of what you expect it to do).
Yes that works if I want to paste into the next available column. Pasting into column number 2 (Nick) sometimes work, sometimes not.
^ regarding the IFS, yes we use fgets() and then change '\n' to '\0', so it's very much '\n'.
I think I'd prefer to keep it as it is, but am of course happy to re-consider if it is going to help solve a problem.
No problem at all.
Though, maybe, sometimes setting the field separator could be usefull.
Offline
It worked consistently when I played with it.
Are you using --simple?
Does the xclip selection contain '\n' when you get the inconsistent behaviour?
If you're happy, I can commit this script to the jgmenu repo so that we make sure we talk about the same version.
Offline
I'm thinking of writing a jgmenuconf tool using shell + yad. It will probably be small and just cover some options that tint2conf doesn't.
Python+gtk/qt might be a more conventional choice, but I rather like yad
Offline
It worked consistently when I played with it.
Are you using --simple?
Does the xclip selection contain '\n' when you get the inconsistent behaviour?
If you're happy, I can commit this script to the jgmenu repo so that we make sure we talk about the same version.
Checked. Sorry it was an older version. Updated now.
Works. I will check that simple option.
I'm thinking of writing a jgmenuconf tool using shell + yad. It will probably be small and just cover some options that tint2conf doesn't.
Python+gtk/qt might be a more conventional choice, but I rather like yad
Hey that's great. "Yell" if you need any help.
Last edited by misko_2083 (2017-05-14 15:15:13)
Offline
jgmenu can be used in Thunar Custom Actions.
If jgmenu is used in the Thunar Custom Action, and the file name contains \n in it's name or path, it makes a fuzzy menu.
Regular files and paths are ok.
Command used for the Custom Action:
killall jgmenu; printf "Mousepad,mousepad %f,mousepad\nFirefox,firefox %f,firefox" | jgmenu --simple --at-pointer
Since it's possible to assign keyboard shortcuts to the Thunar Custom Actions,
after the file is selected a simple key/key-combo would launch the jgmenu.
E: Hmm, maybe, I can hack "Yet Another Start Menu" for this use.
Last edited by misko_2083 (2017-05-14 15:38:48)
Offline
Malm,
I have been building a new system this weekend. When it came time to install jgmenu (which is now part of my "standard setup" (I love it )), I noticed one change in the Installation instructions on https://github.com/johanmalm/jgmenu since I did this the last time - you have added a handy new script, "install-debian-dependencies.sh".
Which is very nice enhancement, although I didn't notice it until after I had typed in all those "apt install" commands for the various lib*-dev packages. Anyway, I thought in the instructions,
./scripts/install-debian-dependencies.sh
mkdir ~/src && cd ~/src
git clone https://github.com/johanmalm/jgmenu.git
cd jgmenu
make
make install
the order is wrong, because the "install-debian-dependencies.sh" script won't exist until after you run the "git clone" command. I think the step to run the "install-debian-dependencies.sh" script needs to go between "cd jgmenu" and "make", as in:
mkdir ~/src && cd ~/src
git clone https://github.com/johanmalm/jgmenu.git
cd jgmenu
./scripts/install-debian-dependencies.sh
make
make install
Ben
Offline
Thanks. Good spot! I've changed it.
I'm delighted that you use+like it.
Depending on how old your jgmenurc is, you may do well to delete/update it to allow tint2 integration to take place (assuming you use tint2).
Do shout if there are any config mismatches between jgmenu+tint2. jgmenu should pick up on all the tint2 colour scheme and positioning automatically.
If you modify your tint2rc, you'll need to do a `killall jgmenu` to re-load the config (for the time being anyway).
In terms of "interfaces", beware that icon-caching has now been implemented in C and happens automatically, so there is no need to do `jgmenu_run cache` anymore.
I've got a few things to sort out before v0.5.2 (see the TODO2 file).
Offline
P.S.
- We also honour bl-tint2zen, so it should work even if you don't use a plain tint2rc.
- The recent addition of `jgmenu_run lx` is still a bit experimental. It's an alternative to pmenu and is just a front-end to libmenu-cache (LXDE's lib for parsing XDG menus). I've noticed a few peculiarities with it and will try to iron them out.
Offline
I'm not sure if it is - easily? - possible, but I'd like to suggest a menu configuration feature to consider: (Vertical) Mirroring.
The categories are on the left side and sub-menus open on the right side. In certain configurations (e.g. when the start button is in the upper right corner) the other way around would work more convenient.
Offline
Good to hear from you.
I'll have a go. Shouldn't be too hard. It'll have to be tomorrow/weekend though.
Offline