Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Application-specific recent files pipe-menus for Openbox
Here's an example for GIMP:
For other applications, the grep line must be adjusted accordingly, changing the grepped application name and the relevant file extensions. And the application in the "execute" line, of course.
Perhaps it could even be generalized so that the application is "$1" and the extensions are in "$2", and then the same script would be used with different parameters for different applications, but "on the fly".
Something like:
But the "\|." also probably needs to be escaped, somehow.
If one doesn't care for the full paths appearing in the menus, or find it even to be helpful, then the script would be somewhat minimally faster, without the basename-generated label variable.
Edit: added a chek to see if the file still exists.
2 - the actual item apparently is better be echoed than printfed. Printf was resulting in a bug with some file name, presumably (I guess the name had "-B" on it, but apparently it's "%2B"), echo doesn't result in the same problem.
Code:
#!/bin/bash printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?><openbox_pipe_menu>" # Instead of just "gimp" in the next line, it could even be a series of # related programs, if you juggle between different applications with # these files. Such as "gimp\|inkscape\|krita\|mypaint" grep -B 10 gimp ~/.local/share/recently-used.xbel | \ grep href | sed 's|.*file://||;s|" added.*||' | \ grep -i ".jpg\|.jpeg\|.png\|.gif\|.ora\|.kra\|.xcf\|.psd" | \ tac | while read file ; do file="$(printf 'b' "${file///\\x}")" # url-decode the file [ -f "$file" ] && # only prints the menu item if the file is still there ( label=$(basename "$file") echo "<item label=\"$label\"><action name=\"Execute\"><execute>mypaint "$file"</execute></action></item>" ) done printf "</openbox_pipe_menu>"
Perhaps it could even be generalized so that the application is "$1" and the extensions are in "$2", and then the same script would be used with different parameters for different applications, but "on the fly".
Something like:
Code:
</item><menu id="libreoffice-writer-recent" label="recent" execute="/$USER/scripts/app-specific-recent.sh lowriter ".ods\|.doc\|.rtf\|.xls\|etc""/>
If one doesn't care for the full paths appearing in the menus, or find it even to be helpful, then the script would be somewhat minimally faster, without the basename-generated label variable.
Edit: added a chek to see if the file still exists.
2 - the actual item apparently is better be echoed than printfed. Printf was resulting in a bug with some file name, presumably (I guess the name had "-B" on it, but apparently it's "%2B"), echo doesn't result in the same problem.
Total Comments 0