From time to time i see questions in the forum about how to add an icon to the desktop.
If you know about ROX-Filer and its pinboard it is quite easy. Open /usr/share/applications, drag a .desktop file to the desktop and edit item from its right click menu.
Many users, who may be new to Puppy, do not know how ROXs pinboard works. Also, many new users may have heard about so called launchers or have already set them up in other Linux Distros. I can't recall i have ever seen the term launcher in Puppy Linux.
On the other hand, i was confused trying to add desktop icons to porteus' (IIRC it was mate) desktop. Tie!
So i made an attempt to write a script that will add a jwm menu item to ROX-Filer pinboard.
I found that menumanager would be a good basis to start with.
Code: Select all
#!/bin/bash
export TEXTDOMAIN=roxiconman
[ "$(ps | grep "ROX-Filer \-p" | grep -v "grep")" ] || exec /usr/lib/gtkdialog/box_ok "$(gettext "Error")" error "$(gettext "ROX-Filer is not running as desktop app")"
mkdir -p /tmp/roxiconman
build_list() {
echo -n > /tmp/roxiconman/list
CATEGORIES="$1"
PTN="$(grep -o "Category>.*<" /etc/xdg/menus/puppy-${CATEGORIES,}.menu | sed 's/y>/ies=/;s/<$/|/' | tr -d '\n')"
grep -liE "${PTN/%|}" /usr/share/applications/* > /tmp/roxiconman/list_all
while read I; do
[ "`grep -F 'NoDisplay=true' "$I"`" ] && continue
IFS='=' read C1 NAME <<< "`grep "^Name\[${LANG::2}\]=" "$I"`"
if [ ! "$NAME" ]; then
IFS='=' read C1 NAME <<< "`grep -F 'Name=' "$I"`"
fi
[ ! "$NAME" ] && NAME="${I##*/}"
echo "${NAME}|$I" >> /tmp/roxiconman/list
done < /tmp/roxiconman/list_all
}
func_rox_addicon(){
APP="$1"
[ -z "$APP" ] && return
LABEL="$(grep "$APP" /tmp/roxiconman/list | cut -f 1 -d '|')"
PARAM="$(Xdialog --title "$(gettext "Add to desktop:")" --stdout --check "$(gettext "Locked")" --inputbox "${APP##*/}\n\n$(gettext "You can edit some options for the icon here.")\n\n$(gettext "Text displayed under the icon:")" 0 0 "${LABEL}")"
[ -z "$PARAM" ] && return
LABEL="${PARAM%$'\n'*}"
LOCK="$(echo "${PARAM}" | sed '/checked/!d; s/^checked/true/; s/^unchecked/false/')"
rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
<PinboardAdd>
<Path>${APP}</Path>
<Label>${LABEL}</Label>
<Locked>${LOCK}</Locked>
</PinboardAdd>
</env:Body>
</env:Envelope>
EOF
}
export -f build_list func_rox_addicon
build_list Desktop
export menuManager='
<window title="'$(gettext "ROX Icon Manager")'" icon-name="gtk-properties" default-width="550">
<vbox space-fill="true" space-expand="true">
'"`/usr/lib/gtkdialog/xml_info fixed desktop.svg 60 "$(gettext "Add a Launcher icon to your desktop. Click on app to add it to desktop.")"`"'
<vbox space-fill="true" space-expand="true">
<frame '$(gettext "Menu items")'>
<hbox height-request="350" space-fill="true" space-expand="true">
<hbox space-expand="false" space-fill="false">
<tree name="category" selected-row="0" exported_column="1" column-visible="true|false" space-expand="false" space-fill="false">
<label>'$(gettext 'Category')'|command</label>
<variable>CATEGORY</variable>
<item stock="gtk-Desktop">'$(gettext 'Desktop')'|Desktop</item>
<item stock="gtk-System">'$(gettext 'System')'|System</item>
<item stock="gtk-Setup">'$(gettext 'Setup')'|Setup</item>
<item stock="gtk-Utility">'$(gettext 'Utility')'|Utility</item>
<item stock="gtk-Filesystem">'$(gettext 'Filesystem')'|Filesystem</item>
<item stock="gtk-Graphic">'$(gettext 'Graphic')'|Graphic</item>
<item stock="gtk-Document">'$(gettext 'Document')'|Document</item>
<item stock="gtk-Business">'$(gettext 'Business')'|Business</item>
<item stock="gtk-Personal">'$(gettext 'Personal')'|Personal</item>
<item stock="gtk-Network">'$(gettext 'Network')'|Network</item>
<item stock="gtk-Internet">'$(gettext 'Internet')'|Internet</item>
<item stock="gtk-Multimedia">'$(gettext 'Multimedia')'|Multimedia</item>
<item stock="gtk-Fun">'$(gettext 'Fun')'|Fun</item>
<width>140</width><height>112</height>
<action signal="changed">build_list $CATEGORY</action>
<action signal="changed">refresh:LIST</action>
</tree>
</hbox>
<hbox space-fill="true" space-expand="true">
<tree hover-selection="true" exported_column="1" column-visible="true|false">
<variable>LIST</variable>
<label>'$(gettext "App")'|file</label>
<input file>/tmp/roxiconman/list</input>
<action signal="button-release-event">func_rox_addicon "$LIST"</action>
</tree>
</hbox>
</hbox>
</frame>
</vbox>
<hbox space-expand="false" space-fill="false">
<button ok></button>
</hbox>
</vbox>
</window>'
ln -s /usr/local/lib/X11/pixmaps/*48.png /tmp/roxiconman 2>/dev/null
echo '
style "icon-style" {
GtkStatusbar::shadow_type = GTK_SHADOW_NONE
stock["gtk-Desktop"] = {{ "x48.png", *, *, *}}
stock["gtk-System"] = {{ "pc48.png", *, *, *}}
stock["gtk-Setup"] = {{ "configuration48.png", *, *, *}}
stock["gtk-Utility"] = {{ "utility48.png", *, *, *}}
stock["gtk-Filesystem"] = {{ "folder48.png", *, *, *}}
stock["gtk-Graphic"] = {{ "paint48.png", *, *, *}}
stock["gtk-Document"] = {{ "word48.png", *, *, *}}
stock["gtk-Business"] = {{ "spread48.png", *, *, *}}
stock["gtk-Personal"] = {{ "date48.png", *, *, *}}
stock["gtk-Network"] = {{ "connect48.png", *, *, *}}
stock["gtk-Internet"] = {{ "www48.png", *, *, *}}
stock["gtk-Multimedia"] = {{ "multimedia48.png", *, *, *}}
stock["gtk-Fun"] = {{ "games48.png", *, *, *}}
stock["gtk-BB"] = {{ "pet48.png", *, *, *}}
}
class "GtkWidget" style "icon-style"' > /tmp/roxiconman/gtkrc
export GTK2_RC_FILES=/root/.gtkrc-2.0:/tmp/roxiconman/gtkrc
. /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
eval $(gtkdialog -p menuManager)
rm -r /tmp/roxiconman
Problem was to get the menu items in my LANG (de_DE.UTF-8). menumanager is a nice little app to add or remove apps from jwm menu, but if you have installed a langpack, many translated menu items no longer match appnames in menumanager.
Next problem is that categories in menumanager seem to be outdated (category network shows two apps). The script now gets the categories from /etc/xdg/menus/puppy-*.menu files.
Also .desktop files can have more than one category in a semi-colon separated list. Some menu items may not be displayed.
Another problem is, where to place the icon. By default rox seems to add an icon to pinboard automatically, if you don't specify the coordinates. But it also seems that rox uses a different icon grid step than the one you specify in rox options. But you need to drag the icon to a desired place anyway.
This is, what i made of it yet:
Thoughts about it:
1) will this be useful for anybody?
2) does it work for other languages in other Puppies?
3) does it make sense to spend hours on editing gtk2 apps nowadays???
Comments welcomed
EDIT:
I have rebuild the function build_list and removed attached script. (see code box above)
EDIT:
Updated code and .mo (de)
EDIT:
Messed up attachments...
.pet can be found here