Set icon for script - how ??

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

Set icon for script - how ??

#1 Post by greengeek »

Lets say i wish to put a special purpose script in /root (ok normally you would put it in /usr/bin or similar but this time i'm not going to...)

Now lets say I want that script to have an icon so it doesn't look so ugly. I know that I can rightclick that script and choose "set icon" and drag an icon there - but my question is - what does that actually achieve? Where is the config file that gets updated?

I have checked the files in /root/Choices/ROX-Filer but they dont get updated (because I'm not modifying the desktop...) so where is the actual file that tells my puppy that I have set the icon?

EDIT - I should have noted I am running a Slacko 5.6 derivative.

cheers!
Attachments
Screenshot.jpg
(36.6 KiB) Downloaded 273 times
Last edited by greengeek on Wed 06 Jul 2016, 22:48, edited 1 time in total.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#2 Post by rcrsn51 »

Check /root/.config/rox.sourceforge.net/ROX-Filer/globicons

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#3 Post by greengeek »

Ahh yes. Thank you very much!

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#4 Post by rcrsn51 »

I'm sure that there's a good reason why ROX spreads this information over several files, but it seems convoluted.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#5 Post by greengeek »

Note to self:

To manually allocate icon to script use a text editor to open the /root/.config/rox.sourceforge.net/ROX-Filer/globicons file (be warned it is an xml file) then add something like the following rule:

Code: Select all

  <rule match="/root/tapcontrol">
    <icon>/usr/share/icons/gnome-fs-desktop.xpm</icon>
  </rule>
Then open a terminal and enter the following command:
fixmenus
(no need to do a jwm restart or reload)
A second or two later the script will inherit the specified icon.

Warning: - this may be an unsafe way to go about this. May need to investigate SOAP mods for xml files in preference to manually using a text editor on a running system.

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#6 Post by tallboy »

I have done exactly what you describe on several scripts, to open hTop, pfind, xpdf, despace and others, it works just fine.

Learned the hard way: To avoid an accidental deletion of an icon, it may be an advantage to copy it to an excisting icon file, like one of those named icon or pixmap, and link to it from there. The globicons file lists several examples.

If you right-click the icon, and choose Edit item, you can add a name under the icon.

You can also right-click the icon, choose File 'something', and open Set icon to choose another one, the change will appear i globicons.

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#7 Post by MochiMoppel »

greengeek wrote:Then open a terminal and enter the following command:
fixmenus
(no need to do a jwm restart or reload)
...and no need to run fixmenus. I can't see any connection between fixmenus and ROX icons. It's sufficient to place the mouse cursor over an edited icon to see the effect. ROX-Filer keeps globicons in memory, but rereads the file whenever it changes (to be precise: whenever globicon's time stamps change). It doesn't matter if the change was made manually or programmatically.
Warning: - this may be an unsafe way to go about this. May need to investigate SOAP mods for xml files in preference to manually using a text editor on a running system.
Unless you wreck the XML structure it should be safe.

Actually there is a good reason to edit globicons manually: ROX nevers cleans up this file, so it grows and grows. What happens if you decide to remove your script from the desktop? Unless you clear the icon first, using the Set Icon dialog, the globicons item remains. Or if you rename the file or change the link address? If you do it the "proper" way and use the ROX Set Icon dialog you can attach the same icon again to your renamed file, but this will create a second globicons item. Slacko 5.6 already ships with a lot of junk in its globicons file and over time you will accumulate a lot more dead links, so it might be worthwhile to occasionally clean the file manually and keep it slim.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#8 Post by greengeek »

MochiMoppel wrote:...and no need to run fixmenus. I can't see any connection between fixmenus and ROX icons.
Actually on my system it DOES seem necessary to do the fixmenus. Otherwise i don't get any update of the script icon. Maybe this is to do with the script not being in my path? Or maybe some oddity to do with the layer structure of my puppy? Whatever the reason the icon does not update when I mouseover the script icon. Mysteries.
ROX nevers cleans up this file, so it grows and grows.... Slacko 5.6 already ships with a lot of junk in its globicons file and over time you will accumulate a lot more dead links, so it might be worthwhile to occasionally clean the file manually and keep it slim.
Interesting. After a fresh boot I had a look at the globicons file and it does not even exist. It only appeared after I rightclicked a script and set an icon that way. And when I looked at the globicons file after that there was all kinds of unneeded rubbish in there (as well as entries for the few valid icons I do have on my desktop. I wonder where it got all the extra junk rules from?
Example:

Code: Select all

  <rule match="/usr/local/bin/defaultemail">
    <icon>/usr/local/lib/X11/pixmaps/email48.png</icon>
  </rule>
  <rule match="/usr/local/bin/defaulthtmleditor">
    <icon>/usr/local/lib/X11/pixmaps/webedit48.png</icon>
  </rule>
  <rule match="/usr/local/bin/pdrive">
    <icon>/usr/local/lib/X11/pixmaps/drive48.png</icon>
  </rule>
  <rule match="/usr/sbin/mut">
    <icon>/usr/local/lib/X11/pixmaps/drive48.png</icon>
  </rule>
  <rule match="/usr/local/bin/opera">
    <icon>/usr/local/lib/X11/pixmaps/www48.png</icon>
  </rule>
None of these icons is in use on my system. They must be specified in some default file that I unknowingly brought across from the original Slacko 5.6 I used as the base for this derivative.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#9 Post by MochiMoppel »

greengeek wrote:I wonder where it got all the extra junk rules from?
MochiMoppel wrote:Slacko 5.6 already ships with a lot of junk
"Kaffeine or tea, Sir?"-"No thanks, just bring me the mozmail"

Code: Select all

<?xml version="1.0"?>
<special-files>
  <rule match="/usr/local/kde/bin/kaffeine">
    <icon>/usr/local/lib/X11/pixmaps/multimedia48.png</icon>
  </rule>
  <rule match="/usr/local/bin/mozmail">
    <icon>/usr/local/lib/X11/pixmaps/email48.png</icon>
  </rule>
  <rule match="/usr/local/kde/bin/konqueror">
    <icon>/usr/local/lib/X11/pixmaps/www48.png</icon>
  </rule>
  <rule match="/usr/local/bin/tea">
    <icon>/usr/local/lib/X11/pixmaps/edit48.png</icon>
  </rule>

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#10 Post by greengeek »

MochiMoppel wrote:Slacko 5.6 already ships with a lot of junk
Yes - but I don't understand exactly where within Slacko 5.6 it is sourced from. My remastered version of Slacko 5.6 does not have this globicons file at all until after I right click a file and "set icon".

Then the globicons file appears as if by magic. It must be sourced from some other location. It would be nice if i could find that location and D_E_A_L to it permanently.

I guess a pfind session is in order...

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#11 Post by greengeek »


User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#12 Post by MochiMoppel »

greengeek wrote:Yes - but I don't understand exactly where within Slacko 5.6 it is sourced from.
/root/Choices/ROX-Filer/globicons

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#13 Post by greengeek »

MochiMoppel wrote:/root/Choices/ROX-Filer/globicons
Thank you. Yes of course. For some reason I thought I had cleared that file out. Maybe it is necessary to clear both /root/Choices/ROX-Filer/globicons and /root/.config/rox.sourceforge.net/ROX-Filer/globicons at the same time.

I need to sort that during my next remaster.

I have decided I can use a modified version of the code you suggested in a pinstall.sh when I create a pet. The pinstall code will bind the script and icon for those times when I am not adding a .desktop file.

Here is the script that binds the script and icon

Code: Select all

#!/bin/bash
#"scripticonbinder"
#2016 July 08
#Greengeek script to associate an icon with a script.
#(without using a .desktop file)
#It will add an icon definition to /root/.config/rox.sourceforge.net/ROX-Filer/globicons to allow script to have specific icon.
#Based on MochiMoppel code to write to globicons xml file.
#Thread here: http://murga-linux.com/puppy/viewtopic.php?t=107415

#Usage suggestion: Use this script as a pinstall.sh (or incorporate it
#into a lager pinstall.sh) to allocate an icon to a script or program
#that is being installed by your pet. (Useful if your programme does not have
#a menu entry created by placing a .desktop file in usr/share/applications)
#Just type the correct filename (scriptname) and icon name into these fields:

#User must define the name of their chosen script (full path):
FILE=/root/examplescript

#User must define the name of their chosen icon (full path):
ICON=/usr/local/lib/X11/pixmaps/info.xpm

#Check that /root/.config/rox.sourceforge.net/ROX-Filer/globicons file exists
#Create it if not:
#(Copy /root/Choices/ROX-Filer/globicons ??)

#Write the info to the globicons file:
CONTENT=' <rule match="'$FILE'">\n    <icon>'$ICON'</icon>\n  </rule>'
sed -i "/<special-files>/ a\ $CONTENT" /root/.config/rox.sourceforge.net/ROX-Filer/globicons
fixmenus
And here is a test .pet which offers an example of installing a script into /root (horror!) and binding a pre-existing icon:
Attachments
examplescript_gg-0.0.pet
(1.42 KiB) Downloaded 41 times

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#14 Post by Mike Walsh »

MochiMoppel wrote:Actually there is a good reason to edit globicons manually: ROX nevers cleans up this file, so it grows and grows. What happens if you decide to remove your script from the desktop? Unless you clear the icon first, using the Set Icon dialog, the globicons item remains. Or if you rename the file or change the link address? If you do it the "proper" way and use the ROX Set Icon dialog you can attach the same icon again to your renamed file, but this will create a second globicons item. Slacko 5.6 already ships with a lot of junk in its globicons file and over time you will accumulate a lot more dead links, so it might be worthwhile to occasionally clean the file manually and keep it slim.
Ah. That would explain why, after I've uninstalled a program/app (for instance, say it's a browser, and I want to install a newer version), and I then go to install the new version, and look in /usr/bin, there's the executable with the icon already looking back at me. Sometimes I drag the /bin file to the desktop, sometimes it's the .desktop file; in the case of the Chrome/Chromium-based browsers, it's sometimes the wrapper-script I drag to the pinboard. (I'm not consistent in my choice; any of these will act to execute the application.....a lot depends on which I look at first!)

I have a sizeable store of .png icons, which I've been adding to for some years.....png, because of the transparent backgrounds with these files; which works perfectly for a desktop icon. If any of mine goes haywire, or goes missing, I merely reset it from the 'icon store'....

Thanks for the info, MochiMoppel.


Mike. :wink:

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#15 Post by MochiMoppel »

I made a small script to find all dead links in the globicons file. Based on the list the user might decide if to keep or delete the junk.

Code: Select all

#!/bin/bash
### Tests globicons file for dead links

NL=$'\n' TAB=$'\t' IFS=$NL
GLOBFILE=/root/.config/rox.sourceforge.net/ROX-Filer/globicons
[[ -e  $GLOBFILE  ]] || GLOBFILE=/root/Choices/ROX-Filer/globicons   # if file doesn't exist, check default version
[[ -e  $GLOBFILE  ]] || exec gxmessage -c "No globicons file found!" # if this fails too, give up

GLOBLINKS=$(sed -rn "/match/ =  ;s/^.*match=\"(.*)\".*$/@\1/p"       "$GLOBFILE")
GLOBICONS=$(sed -rn "/<icon>/ = ;s/^.*<icon>(.*)<\/icon>.*$/@\1/p"   "$GLOBFILE")
GLOBLINKS=${GLOBLINKS//$NL@/$TAB}
GLOBICONS=${GLOBICONS//$NL@/$TAB}

for LINE in $GLOBLINKS;do
[[ ! -e ${LINE#*$TAB} ]] && DEADLINKS=${DEADLINKS}${LINE}${NL}
done

for LINE in $GLOBICONS;do
[[ ! -e ${LINE#*$TAB} ]] && DEADICONS=${DEADICONS}${LINE}${NL}
done

if [[  ${DEADLINKS}${DEADICONS} ]];then
gxmessage -title "$GLOBFILE" "
+++++++ Dead app  links +++++++${NL}Row${TAB}File${NL}${DEADLINKS}
+++++++ Dead icon links +++++++${NL}Row${TAB}File${NL}${DEADICONS}" 
else
gxmessage -title "$GLOBFILE"  "OK, no dead application or icon links"
fi
Attachments
globicons_junk_info.png
(214.58 KiB) Downloaded 183 times

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#16 Post by greengeek »

MochiMoppel wrote:I made a small script to find all dead links in the globicons file. Based on the list the user might decide if to keep or delete the junk.
Excellent. Thanks.
I had no idea i was carrying so many extra kilos. Time for a purge.

AmiMurozi
Posts: 7
Joined: Wed 04 Jul 2012, 05:43

#17 Post by AmiMurozi »

Hi greengeek.

I've just been having a look inside your new repet PET for re-packaging expanded PET directories here. I like your method for applying an icon to a right-click menu entry that is based on a script. Here's another way I do it sometimes that produces much the same result:

(I will use your repet PET of MochiMoppel's script as an illustration here.)
  • 1. Create a new directory in /usr/local/apps/ and call it repet.
    2. Put MochiMoppel's script inside it and call that AppRun.
    3. Right-click your newly created repet directory and select Set Icon...
    4. Drag a suitable icon to the window (in your case /usr/local/lib/X11/pixmaps/refresh24.png) making sure that the option Copy image into directory is selected. This will copy the icon into the repet directory with the title .DirIcon.
The entire repet directory will now assume both the functionality of the script, and the appearance of the icon, that are inside it.
  • 5. Right click any directory, select Customise Menu, and then drag repet to the window and create a link.
That will create a right-click menu entry for repet in /root/.config/rox.sourceforge.net/SendTo/.inode_directory/, complete with an icon.
One advantage of doing it this way is that you do not need to edit /root/.config/rox.sourceforge.net/ROX-Filer/globicons.

Ami.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#18 Post by greengeek »

Hi AmiMurozi - thank you very much. I will be making good use of this technique. Understanding "RoxApps" has been on my radar for a while but I have never got around to it. Every so often I put together a script that allows me to add some function or other and it would be nice to be able to dress it up with an icon and make it more professional and functional.
cheers!

EDIT :
5. Right click any directory, select Customise Menu, and then drag repet to the window and create a link.
If my script was related to playing a music file could I use the same technique to activate the rightclick menu by rightclicking a music file, selecting "customise" then dragging my script and linking? (obviously populating a different functionality than the inode_directory folder).

AmiMurozi
Posts: 7
Joined: Wed 04 Jul 2012, 05:43

#19 Post by AmiMurozi »

Hi greengeek.
greengeek wrote:If my script was related to playing a music file could I use the same technique to activate the rightclick menu by rightclicking a music file, selecting "customise" then dragging my script and linking?
That certainly sounds plausible. When it comes to these sorts of things, I've always been a big fan of the Try it and see what happens method. If it doesn't work entirely as expected, then you start having a look around to find out why it didn't. One of the many great things about Puppy Linux is that if you are running totally in RAM (that is, without a Save File) you can try out virtually any idea that enters your head in the knowledge that you will not hurt your operating system. (Well, within reasonable limits, anyway.) It's quite a good way to learn what works, what doesn't, and why.

Post Reply