You are not logged in.
Currently messing with Openbox Pipe menus, and was hoping there would be a way to insert a folder icon into the script to display next to every entry?
Here is the basic recents script:
#!/bin/sh
echo "<openbox_pipe_menu>"
files=$(
cat ~/.local/share/recently-used.xbel | grep file:/// | tail -n15 | cut -d "\"" -f 2 | tac | while read line;
do
file=$(echo "$line")
name=$(echo -en "$file" | sed 's,.*/,,' | sed 's/%20/ /g')
echo "<item label=\"$name\">
<action name=\"Execute\"><command>xdg-open $line</command></action>
</item>"
done);
echo "$files"
echo "<separator />"
echo "<item label=\"Clear Recents\">
<action name=\"Execute\"><command>rm ~/.local/share/recently-used.xbel</command></action>
</item>"
echo "</openbox_pipe_menu>"
Anyhow, Was hoping someone knows how to accomplish this. Beyond me.
For those wondering about pipe menus, here is the oneliner to put into the menu.xml
<menu execute="pipe-recent-files" icon="/usr/share/icons/gnome-brave/32x32/places/folder.png" id="ID41" label="Recent Files"/>
You will need to change the specifics to match what you want.
"ID" must be changed with each addition.
------
Also, is there a way to bookmark files in Thunar like pcmanfm? - *(This part solved)
They are called "shortcuts" in Thunar.
There is a right-click action to add to side pane from the send to menu.
Last edited by sleekmason (2021-02-07 14:03:25)
Offline
The same way you would put icons in a normal menu entry.
Example:
<item label="7-Zip FM" icon="/home/ohnonot/.config/obmenu-generator/icons/c2b4ed15fc32f402abb928c431631076.png"><action name="Execute"><command><![CDATA[7zFM]]></command></action></item>
So, in a shell script:
echo '<item label="7-Zip FM" icon="/home/ohnonot/.config/obmenu-generator/icons/c2b4ed15fc32f402abb928c431631076.png"><action name="Execute"><command><![CDATA[7zFM]]></command></action></item>'
Where is the problem?
Offline
The same way you would put icons in a normal menu entry.
Example:<item label="7-Zip FM" icon="/home/ohnonot/.config/obmenu-generator/icons/c2b4ed15fc32f402abb928c431631076.png"><action name="Execute"><command><![CDATA[7zFM]]></command></action></item>
So, in a shell script:
echo '<item label="7-Zip FM" icon="/home/ohnonot/.config/obmenu-generator/icons/c2b4ed15fc32f402abb928c431631076.png"><action name="Execute"><command><![CDATA[7zFM]]></command></action></item>'
Where is the problem?
I still cannot get it to work having tried various positions:
#!/bin/sh
echo "<openbox_pipe_menu>"
files=$(
cat ~/.local/share/recently-used.xbel | grep file:/// | tail -n15 | cut -d "\"" -f 2 | tac | while read line;
do
file=$(echo "$line")
name=$(echo -en "$file" | sed 's,.*/,,' | sed 's/%20/ /g')
echo "<item label=\"$name\" icon="/usr/share/icons/gnome-human/32x32/places/folder-documents.png">
<action name=\"Execute\"><command>xdg-open $line</command></action>
</item>"
done);
echo "$files"
echo "<separator />"
echo "<item label=\"Clear Recents\">
<action name=\"Execute\"><command>rm ~/.local/share/recently-used.xbel</command></action>
</item>"
echo "</openbox_pipe_menu>"
Shouldn't this work? (but obviously doesn't).
It seems like the quotes don't line up like they do in the menus?
Last edited by sleekmason (2021-02-06 22:35:17)
Offline
You forgot to escape the quotes around the icon path, just like for the other elements.
If you run the script in a terminal it willmost likely tell you what's up.
Offline
Ha! Brilliant:) Thank you.
echo "<item label=\"$name\" icon=\"/usr/share/icons/gnome-human/32x32/places/folder-documents.png\">
Offline
I highly recommend shellcheck for this sort of thing -- available as a plugin for some editors, and at www.shellcheck.net.
Offline
^agreed!
Just install the Debian shellcheck package and Geany's (default BL editor) "Lint" item in the "Build" menu will run a check on the current file.
Surprising how often a script you think is perfect will turn out to have some bug or typo.
...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 )
Offline
Thank you both for the info!
I have used it before online, and simply forgot it was there.
Using shellcheck with Geany sounds like a good plan.
*Edit - This is nice in Geany! Found a few other obsolete commands in the script. Hell, Think I just found a new toy:)
Last edited by sleekmason (2021-02-09 02:55:26)
Offline
I highly recommend shellcheck for this sort of thing
Agreed. But in this case, simply running the script from a terminal should've helped a long way.
Maybe adding "set -x" or even "set -xv" just under the shebang.
Offline
muppetfan wrote:I highly recommend shellcheck for this sort of thing
Agreed. But in this case, simply running the script from a terminal should've helped a long way.
Maybe adding "set -x" or even "set -xv" just under the shebang.
I see what you are saying. I'm am finding in my limited experience, that it's hard to beat the terminal for simple error control.
Using lint in Geany has been interesting. It made three suggestions for the script, but none of the suggestions actually worked (that is, if I did it right).
Seems like this could throw a twist in the works if you were not sure of your own code, and kept trying to follow the hints while writing a script.
Still, a nice tool overall. I suppose there are other tools for this as well? Reckon I'll find out.
Offline
Using lint in Geany has been interesting. It made three suggestions for the script, but none of the suggestions actually worked (that is, if I did it right).
Seems like this could throw a twist in the works if you were not sure of your own code, and kept trying to follow the hints while writing a script.
Still, a nice tool overall. I suppose there are other tools for this as well? Reckon I'll find out.
shellcheck is quite a respected piece of software, and while it's sometimes a bit picky I've never known it to give wrong advice. There's a website where you can look up a shellcheck complaint by its number (appears in the lint window) and learn more about it.
...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 )
Offline
Careful believing this one every time though, if you are using "echo -e"...
note: Backslash is literal in "\n". Prefer explicit escaping: "\\n".
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
^Yes, yes! Hit that one a few times...
EDIT: but adding the extra backslash probably wouldn't break anything, would it?
Last edited by johnraff (2021-02-12 08:25:21)
...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 )
Offline
sleekmason wrote:Using lint in Geany has been interesting. It made three suggestions for the script, but none of the suggestions actually worked (that is, if I did it right).
Seems like this could throw a twist in the works if you were not sure of your own code, and kept trying to follow the hints while writing a script.
Still, a nice tool overall. I suppose there are other tools for this as well? Reckon I'll find out.
shellcheck is quite a respected piece of software, and while it's sometimes a bit picky I've never known it to give wrong advice. There's a website where you can look up a shellcheck complaint by its number (appears in the lint window) and learn more about it.
Thanks for the link @Johnraff. Good stuff.
Easy enough to check if it was just me. The commands offered by lint would not work, breaking the info the script was trying to provide. Said "useless cat" but without it, (or replaced), The script didn't work.
Same for the other suggestions. This being said, I am certainly no code expert and no doubt left something out/wrong/etc . .
Offline
"useless use of cat" is a perennial favourite. (websearch)
It's not a bug per se, just not considered nice code.
One example:
cat file | grep 'pattern'
could just as well be
grep 'pattern' file
but there are many many others.
You seem pretty busy now, so as long as your code works, and you don't have any real potential breaks like unquoted variables, then sure leave it be.
If you felt like posting the code snippet and shellcheck's issue number though, I'd be happy to have a look...
...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 )
Offline
I must admit I do not use shellcheck all that often :8
It could prevent someone from thinking about good coding practice and instead adopting an attitude of "I just have to run it through shellcheck until there's no more errors". The same goes for all helper applications of this sort.
And, as I said, the shell itself usually gives pretty good hints about what went wrong and where.
Offline
It could prevent someone from thinking about good coding practice and instead adopting an attitude of "I just have to run it through shellcheck until there's no more errors".
In my experience it's the opposite. It pulls you up and reminds you of good coding practice if you get sloppy. Everyone would rather write code that doesn't trigger errors and warnings, surely? And everyone makes typos from time to time. Much better to catch them before running the code.
...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 )
Offline
Your point is just as valid as mine - that's why I used the conditional.
Much better to catch them before running the code.
I don't think shellcheck (or any other such helper) can save you from having to test-run your code.
And there's so much potential for errors that shellcheck can never see.
Offline
For those of us mortals who can't code, we'll take all the help we can get:)
You seem pretty busy now, so as long as your code works, and you don't have any real potential breaks like unquoted variables, then sure leave it be.
Like a whirlwind. Don't know why I put myself under pressure, lol. Sourceforge was fun to get into, but once there has a really neat interface.
Being able to just "read the code" like both of you, and many more here is an ability to strive for. My hacking together bits and pieces really annoys the hell out of me, but slowly over time I'm learning more.
I feel like all of this exploration is a journey I am on. If I just follow the sign posts, more is revealed. Do the next right thing. Mind blowing really.
The snippet in question is above, but no need to go over it:) It works fine. I will use it as an opportunity to learn more. When/if I change it, I'll remember this thread and post the change. Ha!
Offline
For those of us mortals who can't code, we'll take all the help we can get:)
johnraff wrote:You seem pretty busy now, so as long as your code works, and you don't have any real potential breaks like unquoted variables, then sure leave it be.
Like a whirlwind. Don't know why I put myself under pressure, lol. Sourceforge was fun to get into, but once there has a really neat interface.
Being able to just "read the code" like both of you, and many more here is an ability to strive for. My hacking together bits and pieces really annoys the hell out of me, but slowly over time I'm learning more.
I feel like all of this exploration is a journey I am on. If I just follow the sign posts, more is revealed. Do the next right thing. Mind blowing really.
The snippet in question is above, but no need to go over it:) It works fine. I will use it as an opportunity to learn more. When/if I change it, I'll remember this thread and post the change. Ha!
Welcome to coding, because there is no possible way to know it all or even understand it all. It's the pattern recognition that really helps.
Offline