You are not logged in.

#21 2017-01-24 02:09:00

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

Thanks damo, worked a treat.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#22 2017-01-24 02:43:39

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,661
Website

Re: [Work in Progress] Pipemenus & other tidbits

urxvt doesn't support the --command syntax. Support of -e is defined as a requirement for all terminal emulators providing x-terminal-emulator so that's the safe one to use.

A point: -e "command arguments" doesn't work. Everything after the -e is considered to be a command line (ie a command plus some arguments) and must not be enclosed in quotes, at least by the time it reaches urxvt.

Also, as Damo has pointed out, shell syntax is not supported - only a one-word command followed by some arguments that are accepted by that command. This applies to menu.xml and rc.xml as well as -e lines for urxvt. If you want to include some simple shell syntax in your command, then call the shell as your command, and send it the script (using -c) as its arguments. For example, this works in my menu.xml:

<command>urxvt -e bash -c "sudo service apache2 restart &amp;&amp; { echo OK; sleep 2;} || { echo &apos;ERROR (press a key to close)&apos;; read;}"</command>
damo wrote:

shell functions and aliases are limited to the shell, and don't work in executed shell scripts. You might be able to source the alias in the command (NB untested) (Tested, doesn't work)

You can definitely source some file containing functions in a script, to make those functions available. Aliases don't work though - they're meant for interactive use only.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#23 2017-01-24 03:02:07

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

Thanks John for the detailed explanation.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#24 2017-01-25 19:25:32

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

Back on this as I have worked out how to use pipemenus and I want to now use the recent places pipemenu.

I have the script placed in /usr/bin and this is the error I get:

Invalid output from pipe-menu "usr/bin/bl-recent-files-pipemenu -rl15"

I'm not sure what I am missing to make this work, any guidance would be appreciated.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#25 2017-01-25 19:55:50

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: [Work in Progress] Pipemenus & other tidbits

Have you run it in a terminal? The error may be more specific.

BTW, I always test pipemenus in a terminal first wink


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#26 2017-01-25 20:02:01

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

Here is my error:

lua5.2: /usr/share/lua/5.2/posix/init.lua:29: module 'posix.ctype' not found:
	no field package.preload['posix.ctype']
	no file '/usr/share/lua/5.2/posix/ctype.lua'
	no file '/usr/share/lua/5.2/posix/ctype/init.lua'
	no file '/usr/lib/lua/5.2/posix/ctype.lua'
	no file '/usr/lib/lua/5.2/posix/ctype/init.lua'
	no file './posix/ctype.lua'
	no file '/usr/lib/lua/5.2/posix/ctype.so'
	no file '/usr/lib/lua/5.2/loadall.so'
	no file './posix/ctype.so'
	no file '/usr/lib/lua/5.2/posix.so'
	no file '/usr/lib/lua/5.2/loadall.so'
	no file './posix.so'
stack traceback:
	[C]: in function 'require'
	/usr/share/lua/5.2/posix/init.lua:29: in main chunk
	[C]: in function 'require'
	/usr/bin/bl-recent-files-pipemenu:19: in main chunk
	[C]: in ?

I'm guessing I need posix?

I really need to remember to run these pipemenus in terminal to check.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#27 2017-01-25 20:10:55

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

SO I created a new folder in  /usr/share/lua/5.2/ and copied the posix folder from 5.3.

When I run the script I get:

lua5.2: version mismatch: app. needs 503, Lua core provides 502
stack traceback:
	[C]: in ?
	[C]: in function 'require'
	/usr/share/lua/5.2/posix/init.lua:29: in main chunk
	[C]: in function 'require'
	/usr/bin/bl-recent-files-pipemenu:19: in main chunk
	[C]: in ?

Not sure where to go from here.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#28 2017-01-25 20:57:31

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: [Work in Progress] Pipemenus & other tidbits

The pipemenu is requiring lua 5.2 to run. The first line is

#!/usr/bin/env lua5.2

Try changing it to whichever version your system is using.

You can also remove/comment the first line and run the script with whichever is the lua version in your $ENV

lua /path/to/bl-recent-files-pipemenu

[ I suggest moving this thread to Help & Support (Other)? ]

Last edited by damo (2017-01-25 21:03:28)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#29 2017-01-25 21:13:55

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

Thank you damo.

Replacing the 5.1 with 5.3 and adding lua to the command worked.


Can the mods please move this thread to the other help and support thread?

I take that back, Still nothing

lua5.3: /usr/share/lua/5.3/posix/init.lua:32: posix namespace clash: unistd.getopt
stack traceback:
	[C]: in function 'assert'
	/usr/share/lua/5.3/posix/init.lua:32: in main chunk
	[C]: in function 'require'
	/usr/bin/bl-recent-files-pipemenu:19: in main chunk
	[C]: in ?

Last edited by Döbbie03 (2017-01-25 21:41:42)


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#30 2017-01-25 21:57:01

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: [Work in Progress] Pipemenus & other tidbits

Either change the shebang line to 5.3 and run the script on its own

or

Remove/comment it and run it as a command arg for lua.

$ lua --help
lua: unrecognized option '--help'
usage: lua [options] [script [args]]
Available options are:
  -e stat  execute string 'stat'
  -i       enter interactive mode after executing 'script'
  -l name  require library 'name'
  -v       show version information
  -E       ignore environment variables
  --       stop handling options
  -        stop handling options and execute stdin

Run "lua -v", and make sure the script shebang line matches it.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#31 2017-01-25 22:03:22

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: [Work in Progress] Pipemenus & other tidbits

Googled "lua posix namespace clash: unistd.getopt" and got:
https://github.com/luaposix/luaposix/bl … er/NEWS.md

See the getopt part of "Incompatible changes" - I suspect that the pipemenu needs editing for lua 5.3, or compile luaposix with compatible libraries.

You might be able to run "lua -l" and specify the 5.2 lib. NB I'm not the best person to talk to about this stuff!  8o

Last edited by damo (2017-01-25 22:05:12)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#32 2017-01-25 22:25:45

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

Man this is so far ahead of where I am.  Thanks so far damo.  You have been a great help.

I'm going to come back to this.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#33 2017-01-25 22:40:25

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

I finally have it.  I found the pipemenus that #!++ use.  Worked a freaking treat.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#34 2017-01-25 22:59:40

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: [Work in Progress] Pipemenus & other tidbits

^ Note that the cbpp recent-files pipemenu is a direct copy of @johnraff's bash script for Crunchbang:

#!/bin/sh
#    cb-recent-files-pipemenu - a script to parse .recently-used.xbel
#    and generate openbox pipe menu
#    Copyright (C) 2010  John Crawley
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    version 2012/07/01-cb

# Usage: add
# <menu id="recent" label="Recent Files" execute="/path/to/cb-recent-files-pipemenu" />
# to your .config/openbox/menu.xml, or use with cb-places-pipemenu (see comments there)

maximum_entries=15 # max. number of entries in menu

#######################################################################

# look for recently-used.xbel
if [ $XDG_DATA_HOME ] && [ -r "${XDG_DATA_HOME}/recently-used.xbel" ]
then
    file_path="${XDG_DATA_HOME}/recently-used.xbel"
elif [ -r "${HOME}/.local/share/recently-used.xbel" ]
then
    file_path="${HOME}/.local/share/recently-used.xbel"
elif [ -r "${HOME}/.recently-used.xbel" ]
then
    file_path="${HOME}/.recently-used.xbel"
else
	echo "$0: cannot find a readable recently-used.xbel file" >&2
	echo '<openbox_pipe_menu>
<separator label="No recently-used.xbel file found." />
</openbox_pipe_menu>'
	exit 1
fi

# if argument is --clear, empty .recently-used.xbel
[ "$1" = '--clear' ] && {
cat <<':EOF' > "${file_path}"
<?xml version="1.0" encoding="UTF-8"?>
<xbel version="1.0"
      xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
      xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info"
>
</xbel>
:EOF
exit
}

maximum_entries=$((maximum_entries+2))

pre='    <item label="'
mid='">
    <action name="Execute"><command>'
post='</command></action>
    </item>'

files=$( tac "${file_path}" |  awk -v MAX="$maximum_entries" -v PR="$pre" -v MI="$mid" -v PO="$post" 'BEGIN {
    RS="</bookmark>";
    FS="<info>";
}
(NR == MAX) {exit}
!/<bookmark/ {next}
!/href=[\"'\'']file:\/\// {next}
# $1 is the command, $2 the file path
{
    sub(/^.*exec=\"\&apos\;/,"",$1)
    sub(/\&apos\;.*$/,"",$1)
    sub(/ *%./,"",$1)
    sub(/^.*file:\/\//,"",$2)
    sub(/[\"'\''].*$/,"",$2)
    gsub(/%22/,"\\&quot;",$2)
    gsub(/%3C/,"\\&lt;",$2)
    gsub(/%3E/,"\\&gt;",$2)
    name=$2
    sub(/^.*\//,"",name)
    gsub(/_/,"__",name)
    gsub(/\&apos;/,"\\&apos;\\&quot;\\&apos;\\&quot;\\&apos;",$2)
    print (PR name MI $1 " '"'"'" $2 "'"'"'" PO)
}' )

# use perl to decode urlencoded characters
files=$(perl -MURI::Escape -e 'print uri_unescape($ARGV[0]);' "$files")

output='<openbox_pipe_menu>
'"$files"'
<separator />
    <item label="Clear Recent Files">
        <action name="Execute">
            <command>
            &apos;'"$0"'&apos; --clear
            </command>
        </action>
    </item>
</openbox_pipe_menu>
'
printf '%s' "$output"  # printf because echo sometimes eats backslashes

If it does the job for you - great smile  I can't recall why @nobody developed a lua script, but I guess it is better in some way.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#35 2017-01-26 00:15:19

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,871

Re: [Work in Progress] Pipemenus & other tidbits

damo wrote:

^ Note that the cbpp recent-files pipemenu is a direct copy of @johnraff's bash script for Crunchbang:

#!/bin/sh
#    cb-recent-files-pipemenu - a script to parse .recently-used.xbel
#    and generate openbox pipe menu
#    Copyright (C) 2010  John Crawley
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    version 2012/07/01-cb

# Usage: add
# <menu id="recent" label="Recent Files" execute="/path/to/cb-recent-files-pipemenu" />
# to your .config/openbox/menu.xml, or use with cb-places-pipemenu (see comments there)

maximum_entries=15 # max. number of entries in menu

#######################################################################

# look for recently-used.xbel
if [ $XDG_DATA_HOME ] && [ -r "${XDG_DATA_HOME}/recently-used.xbel" ]
then
    file_path="${XDG_DATA_HOME}/recently-used.xbel"
elif [ -r "${HOME}/.local/share/recently-used.xbel" ]
then
    file_path="${HOME}/.local/share/recently-used.xbel"
elif [ -r "${HOME}/.recently-used.xbel" ]
then
    file_path="${HOME}/.recently-used.xbel"
else
	echo "$0: cannot find a readable recently-used.xbel file" >&2
	echo '<openbox_pipe_menu>
<separator label="No recently-used.xbel file found." />
</openbox_pipe_menu>'
	exit 1
fi

# if argument is --clear, empty .recently-used.xbel
[ "$1" = '--clear' ] && {
cat <<':EOF' > "${file_path}"
<?xml version="1.0" encoding="UTF-8"?>
<xbel version="1.0"
      xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
      xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info"
>
</xbel>
:EOF
exit
}

maximum_entries=$((maximum_entries+2))

pre='    <item label="'
mid='">
    <action name="Execute"><command>'
post='</command></action>
    </item>'

files=$( tac "${file_path}" |  awk -v MAX="$maximum_entries" -v PR="$pre" -v MI="$mid" -v PO="$post" 'BEGIN {
    RS="</bookmark>";
    FS="<info>";
}
(NR == MAX) {exit}
!/<bookmark/ {next}
!/href=[\"'\'']file:\/\// {next}
# $1 is the command, $2 the file path
{
    sub(/^.*exec=\"\&apos\;/,"",$1)
    sub(/\&apos\;.*$/,"",$1)
    sub(/ *%./,"",$1)
    sub(/^.*file:\/\//,"",$2)
    sub(/[\"'\''].*$/,"",$2)
    gsub(/%22/,"\\&quot;",$2)
    gsub(/%3C/,"\\&lt;",$2)
    gsub(/%3E/,"\\&gt;",$2)
    name=$2
    sub(/^.*\//,"",name)
    gsub(/_/,"__",name)
    gsub(/\&apos;/,"\\&apos;\\&quot;\\&apos;\\&quot;\\&apos;",$2)
    print (PR name MI $1 " '"'"'" $2 "'"'"'" PO)
}' )

# use perl to decode urlencoded characters
files=$(perl -MURI::Escape -e 'print uri_unescape($ARGV[0]);' "$files")

output='<openbox_pipe_menu>
'"$files"'
<separator />
    <item label="Clear Recent Files">
        <action name="Execute">
            <command>
            &apos;'"$0"'&apos; --clear
            </command>
        </action>
    </item>
</openbox_pipe_menu>
'
printf '%s' "$output"  # printf because echo sometimes eats backslashes

If it does the job for you - great smile  I can't recall why @nobody developed a lua script, but I guess it is better in some way.

The skill knowledge of the people here astound me.  The helpful attitude here is amazing too, many Linux orientated forums could learn a lesson or two.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

Board footer

Powered by FluxBB