How to set an Icon for a Script using Bash?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

How to set an Icon for a Script using Bash?

#1 Post by RSH »

Hi,

usually i do a right-click on a script (desktop button also) and choose "change symbol" (or sim.)(Symbol ändern i.G.) to set a new symbol. I want to do this using a bash script.

How can i do this?

Thanks

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

stu90

#2 Post by stu90 »

Hi RSH
Looks like /root/.config/rox.sourceforge.net/ROX-Filer/globicons is responsible for icon control for individual files.

Code: Select all

#!/bin/sh

FILE="/root/somefile"
ICON="/usr/local/lib/X11/pixmaps/pupnews48.png"

head -n  -1 /root/.config/rox.sourceforge.net/ROX-Filer/globicons > /tmp/globicons

cat >> /tmp/globicons << EOF
  <rule match="$FILE">
  <icon>$ICON</icon>
  </rule>
</special-files>
EOF

rm -f /root/.config/rox.sourceforge.net/ROX-Filer/globicons 
cp -f /tmp/globicons /root/.config/rox.sourceforge.net/ROX-Filer/

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#3 Post by RSH »

stu90 wrote:Hi RSH
Looks like /root/.config/rox.sourceforge.net/ROX-Filer/globicons is responsible for icon control for individual files.

Code: Select all

#!/bin/sh

FILE="/root/somefile"
ICON="/usr/local/lib/X11/pixmaps/pupnews48.png"

head -n  -1 /root/.config/rox.sourceforge.net/ROX-Filer/globicons > /tmp/globicons

cat >> /tmp/globicons << EOF
  <rule match="$FILE">
  <icon>$ICON</icon>
  </rule>
</special-files>
EOF

rm -f /root/.config/rox.sourceforge.net/ROX-Filer/globicons 
cp -f /tmp/globicons /root/.config/rox.sourceforge.net/ROX-Filer/
I did test it using the following edition of your script:

Code: Select all

#!/bin/sh

FILE="/root/SFS-RunScripts/LP2_AudioStudio.sfs.Scripts/LP2_AudioStudio.sfs.audacity.run.sh"
ICON="/root/SFS-RunScripts/LP2_AudioStudio.sfs.Scripts/audacity.png"

head -n  -1 /root/.config/rox.sourceforge.net/ROX-Filer/globicons > /tmp/globicons

cat >> /tmp/globicons << EOF
  <rule match="$FILE">
  <icon>$ICON</icon>
  </rule>
</special-files>
EOF

rm -f /root/.config/rox.sourceforge.net/ROX-Filer/globicons
cp -f /tmp/globicons /root/.config/rox.sourceforge.net/ROX-Filer/
and it does work without any complain! :D

Thank you very much, stu90. This will help a lot, to make my actual work usable in a very comfortable way. Short Story: i did wrote an application, that creates run-scripts from programs inside sfs-files. If i do click a run-script, it runs the program - if the sfs is not loaded, it loads the sfs. If the sfs needs another sfs, it loads all needed sfs-files. If all needed sfs-files are loaded, it runs the program. Now i can set an icon automatically to the run-script and if i move it on the desktop, it shows me the related icon.

Wonderful, great, thank you very much again. :D
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#4 Post by seaside »

RSH,

You might find this useful-

Code: Select all

sed -i ' s|</special-files>||'  /root/.config/rox.sourceforge.net/ROX-Filer/globicons
	echo '  <rule match="/my/application/name">
	    <icon>/usr/local/lib/X11/pixmaps/icon-name.png</icon>
	  </rule>
	</special-files>' >>/root/.config/rox.sourceforge.net/ROX-Filer/globicons
Cheers,
s

Post Reply