ShowHideIcons-v1.8 30/11/2014

Window managers, icon programs, widgets, etc.
Message
Author
stemsee

ShowHideIcons-v1.8 30/11/2014

#1 Post by stemsee »

This is a simple app with one script in ~/my-applications/bin/nicons very simple but works a treat.

v1.8
Attachments
ShowHideIcons-v1.8.pet
(2.5 KiB) Downloaded 244 times
Last edited by stemsee on Mon 01 Dec 2014, 10:47, edited 7 times in total.

stemsee

#2 Post by stemsee »

Updated to v1.6
Now no puppypin0 in .pet, also added reset function, and choose function to select some/any icons from original puppypin to add to new puppypin, plus remove some/any icons. It iterates line by line or you can simply type in the name of the app/icon to add it and enter then type exit when finished.


see first post

to do:
Add any icon from /usr/share/applications/*.desktop These supply variables for Name Categories and Icon and Exec command which is all that's needed.
Last edited by stemsee on Fri 28 Nov 2014, 19:25, edited 1 time in total.

stemsee

#3 Post by stemsee »

Here is the pet v1.6

see first post
Last edited by stemsee on Fri 28 Nov 2014, 19:26, edited 1 time in total.

stemsee

#4 Post by stemsee »

jumped to version 1.4 with some additions.
Last edited by stemsee on Fri 28 Nov 2014, 19:26, edited 2 times in total.

Jasper

#5 Post by Jasper »

Hi stemsee,

You have seemingly been unable to replicate (or even comprehend) the major problem with drive icons that I have twice before reported to you.

If the problem is uniquely mine, it is of no importance to me as, in any event, the Swapicons pet works perfectly.

However I would, at least, be interested to know if this code produces a problem with drive icon display and usage for any other tester.

stemsee

#6 Post by stemsee »

Hi Jasper

Menu > Desktop > Desktop Drives Icon Manager

have a nice day!

stemsee

Jasper

#7 Post by Jasper »

Hi again,

Your reply
Menu > Desktop > Desktop Drives Icon Manager
exhibits your total lack of comprehension.

For a fast, tried and tested app users have the option of
http://murga-linux.com/puppy/viewtopic. ... 72&t=83991
from rhadon with contributions from LIBL and SFR.
Attachments
Swapicons.png
(21.45 KiB) Downloaded 402 times

stemsee

#8 Post by stemsee »

@jasper

Had I known this app before, I would not have bothered writing my own. But now that I have I can say mine has more options. Still I am going to give this one a try and maybe I can add its mechanism to my own full featured version as well as a gui! I have been tardy on learning to build GUIs.

However this app doesn't really manage icons generally, from the looks of things. But mine is beginning too.

regards

stemsee

Jasper

#9 Post by Jasper »

ShowHideIcons is a clear and simple title, but currently your code fails in that simple (if hard to achieve) objective.

I am in favour of diversification if, and only if, it works and I do not appreciate political evasion and economy.

stemsee

#10 Post by stemsee »

@Jasper

I use showhideicons often to show or hide icons, also to add and remove icons. Why on earth would you come to this thread and LIE? You are being absolutely ridiculous. Please change your previous post to reflect the truth. If you are not willing to do that then I will raise an issue with the forum adjudicators.

:(
stemsee

Jasper

#11 Post by Jasper »

I absolutely agree - Why would I lie? Have I not praised some of your recent work both publicly and with private support?

The truth is this did not work for me and I wrote that I would be interested to see the results of tests by other forum members.

By all means rewrite my post that offends you and include it below and if I find your words acceptable - I will adopt them.

All publicity may be good publicity and I look forward to a test report/comment from RSH and hopefully others.

stemsee

#12 Post by stemsee »

@jasper

I owe you an apology and thanks ... the script as it stands doesn't, indeed, install and hide icons. There is a loop created in the last update which copies both pins to each other so nothing changes! Removed and I will correct it.

But I only found it by booting a trusty tahr and installing from scratch, otherwise on EmSee a slightly older version it works fine. Tat was before I added 'nicons custom' and 'nicons nocustom'.

stemsee

stemsee

#13 Post by stemsee »

I think it is fixed now and simplified. reset pins, remove icons, add icons, switch iconless desktop/ iconified desktop.

command line usage

begin by creating switch flag and backup original PuppyPin

Code: Select all

nicons
to switch to iconless desktop PuppyPin0

Code: Select all

nicons
to switch back to iconified desktop PuppyPin

Code: Select all

nicons
to add icons from /us/share/applications renamed links (no .desktop suffix)

Code: Select all

nicons add
to remove icons from pressent iconified pin by typing part or all of name/s separated by one space.

Code: Select all

nicons remove
to remove all icons from both pins

Code: Select all

nicons removeall
to have two iconifiable pins

Code: Select all

nicons two
to exit 'nicons two' switching.

Code: Select all

nicons pip
to delete all pins created by script

Code: Select all

nicons reset

place script in path and name it 'nicons' make executable.

EDITED: 30/11/14 handles xonclock now

Code: Select all

##!/bin/bash
#copyright (c) 2014 M arcos Contant
#nicons # first use creates flag and backs-up puppypin, but no apparent change
#nicons # second use switches to iconless dektop
#nicons # third use switches to iconified desktop
#nicons reset # restores original desktop and deletes script created pins
#nicons remove # helps user remove icon/s from iconified desktop
#nicons removeall # removes all icons from iconified pin. Blank page for adding icons.
#nicons noicons # recreates pristine PuppyPin0 (iconless desktop) from script.
#nicons two #copies iconless pin to puppypin; giving two iconifiable desktop pins.
#nicons pip # resets nicons two.
#nicons add #for rox window of icons from applications dir without .desktop extension.
#(nicons add/remove is temporary for iconless desktop but persistent for iconified desktop, except with nicons two)
pp0 () {
echo '<?xml version="1.0"?>' > ~/Choices/ROX-Filer/PuppyPin0
echo "<pinboard>" >> ~/Choices/ROX-Filer/PuppyPin0
echo "	<backdrop style="Stretched">/usr/share/backgrounds/default.jpg</backdrop>" >> ~/Choices/ROX-Filer/PuppyPin0
echo \ >> ~/Choices/ROX-Filer/PuppyPin0
echo \ >> ~/Choices/ROX-Filer/PuppyPin0
echo "	</pinboard>" >> ~/Choices/ROX-Filer/PuppyPin0

}


if [ ! -e ~/Choices/ROX-Filer/PuppyPin-bak1 ]; then
cp ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/PuppyPin-bak
cp ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/PuppyPin-bak1
fi
if [ "$1" = pip ]; then
rm ~/Choices/ROX-Filer/pip
rm ~/Choices/ROX-Filer/ipp
pp0
fi

if [ -e ~/Choices/ROX-Filer/pip ]; then
pipipp () {
	mv ~/Choices/ROX-Filer/pip ~/Choices/ROX-Filer/ipp
	mv  ~/Choices/ROX-Filer/PuppyPin  /tmp/
	mv  ~/Choices/ROX-Filer/PuppyPin0 ~/Choices/ROX-Filer/PuppyPin
	DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin
gtkdialog-splash -placement top-left -bg blue -text "$(gettext 'Pin 1 of Two iconifiable pins switching.  
To remove type - nicons pip - then Enter')" &
	SPLASHPID=$!
	sleep 2
	kill $SPLASHPID 2> /dev/null
exit
}
pipipp
fi
if [ -e ~/Choices/ROX-Filer/ipp ]; then
ipppip () {
	mv ~/Choices/ROX-Filer/ipp ~/Choices/ROX-Filer/pip
	mv  ~/Choices/ROX-Filer/PuppyPin  ~/Choices/ROX-Filer/PuppyPin0
	cp  /tmp/PuppyPin ~/Choices/ROX-Filer/PuppyPin
	DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin
	gtkdialog-splash -placement top-left -bg blue -text "$(gettext 'Pin 2 of Two iconifiable pins switching.  
To remove type - nicons pip - then Enter')" &
	SPLASHPID=$!
	sleep 2
	kill $SPLASHPID 2> /dev/null
exit
}
ipppip
fi
#if [ "$1" = setup ]; then
set () {
	rm ~/Choices/ROX-Filer/PuppyPin-bak
	ppbak () {
	echo '<?xml version="1.0"?>' > ~/Choices/ROX-Filer/PuppyPin-bak
	echo "<pinboard>" >> ~/Choices/ROX-Filer/PuppyPin-bak
	echo "	<backdrop style="Stretched">/usr/share/backgrounds/default.jpg</backdrop>" >> ~/Choices/ROX-Filer/PuppyPin-bak
	echo \ >> ~/Choices/ROX-Filer/PuppyPin-bak
	echo \ >> ~/Choices/ROX-Filer/PuppyPin-bak
	echo "	</pinboard>" >> ~/Choices/ROX-Filer/PuppyPin-bak
	echo \ >> ~/Choices/ROX-Filer/PuppyPin-bak
}
	ppbak
	if [[ -d /usr/shared/renamed ]]; then
	rm -r /usr/shared/renamed/
	fi
	if [[ ! -d  /usr/shared/renamed ]]; then
	mkdir /usr/share/renamed/
	ln -fnv /usr/share/applications/* /usr/share/renamed/ 2> /dev/null
	cd /usr/share/renamed/
	echo $line | for i in *.desktop; do mv $i `basename $i .desktop`; done 2> /dev/null
	fi
	DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin-bak
	rox  /usr/share/renamed/ &
	gtkdialog-splash -placement top-left -bg blue -text "$(gettext 'Drag & arrange all icons to this desktop')" &
	SPLASHPID=$!
	sleep 4
	kill $SPLASHPID 2> /dev/null
	gtkdialog-splash -placement top-left -bg blue -text "$(gettext 'Press Enter when finished.')" &
	SPLASHPID=$!
	sleep 8
	kill $SPLASHPID 2> /dev/null
	read dummy
	nicons
	exit
}
#set
#fi


choice () {
	if [[ -d /usr/shared/renamed ]]; then
	rm -r /usr/shared/renamed/
	fi
	if [[ ! -d  /usr/shared/renamed ]]; then
	mkdir /usr/share/renamed/
	ln -fnv /usr/share/applications/* /usr/share/renamed/ 2> /dev/null
	cd /usr/share/renamed/
	echo $line | for i in *.desktop; do mv $i `basename $i .desktop`; done 2> /dev/null
	fi
	rox  /usr/share/renamed/ &
	gtkdialog-splash -placement top-left -bg blue -text "$(gettext 'Drag & arrange all icons to this desktop')" &
	SPLASHPID=$!
	sleep 4
	kill $SPLASHPID 2> /dev/null
rm /root/Choices/ROX-Filer/PuppyPin0
cp /root/Choices/ROX-Filer/PuppyPin /root/Choices/ROX-Filer/PuppyPin0
[ -x /root/Startup/xonclock* ] && /root/Startup/xonclock*
exit
}
if [ "$1" = add ]; then
choice && exit
fi
removeicons () {
rm  /tmp/rmvtxt
touch /tmp/rmvtxt
echo "Type space separated name of icon/s to remove and press enter"
	read rmv < /dev/tty
	echo $rmv | tr ' ' '\n' >> /tmp/rmvtxt
	while read line
	do
	sed -i "/$line/d" ~/Choices/ROX-Filer/PuppyPin
	done < /tmp/rmvtxt
	DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin
	rm /root/Choices/ROX-Filer/PuppyPin0
	cp /root/Choices/ROX-Filer/PuppyPin /root/Choices/ROX-Filer/PuppyPin0
	[ -x /root/Startup/xonclock* ] && /root/Startup/xonclock*
	exit
}
if [ "$1" = remove ]; then
removeicons && exit
fi
removeallicons () {
	rm ~/Choices/ROX-Filer/PuppyPin
	cp /root/Choices/ROX-Filer/PuppyPin0 /root/Choices/ROX-Filer/PuppyPin
	DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin 2> /dev/null
	[ -x /root/Startup/xonclock* ] && /root/Startup/xonclock*
	
	exit
}
if [ "$1" = removeall ]; then
removeallicons && exit
fi


resetpins () {
rm ~/Choices/ROX-Filer/pip
rm -r /usr/shared/renamed/
rm ~/Choices/ROX-Filer/PuppyPin-bak
rm ~/Choices/ROX-Filer/PuppyPin-orig
rm ~/Choices/ROX-Filer/PuppyPin-orig-bak	
rm ~/Choices/ROX-Filer/ppin 2> /dev/null
rm ~/Choices/ROX-Filer/nipp 2> /dev/null
rm ~/Choices/ROX-Filer/PuppyPin0 2> /dev/null
rm ~/Choices/ROX-Filer/PuppyPin 2> /dev/null
mv ~/Choices/ROX-Filer/PuppyPin-bak1 ~/Choices/ROX-Filer/PuppyPin 2> /dev/null
DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin 2> /dev/null
[ -x /root/Startup/xonclock* ] && /root/Startup/xonclock*

exit
}

if [ "$1" = reset ]; then
resetpins
fi
if [ -e ~/Choices/ROX-Filer/nipp ]; then
	mv ~/Choices/ROX-Filer/nipp ~/Choices/ROX-Filer/ppin
	bd=`grep -e '  <backdrop style' ~/Choices/ROX-Filer/PuppyPin0`
	sed -i 3i\ "$bd" ~/Choices/ROX-Filer/PuppyPin-orig 2> /dev/null
	sed -i 4\\ ~/Choices/ROX-Filer/PuppyPin-orig
	mv ~/Choices/ROX-Filer/PuppyPin-orig ~/Choices/ROX-Filer/PuppyPin
	DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin
elif [ -e ~/Choices/ROX-Filer/ppin ]; then
	mv ~/Choices/ROX-Filer/ppin ~/Choices/ROX-Filer/nipp
	bd=`grep -e '<backdrop style' ~/Choices/ROX-Filer/PuppyPin`
	pp0
		if [[ "$1" = noicons ]]; then
			pp0 && exit
		fi
		if [[ "$1" = two ]]; then
			rm ~/Choices/ROX-Filer/PuppyPin0
			cp ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/PuppyPin0
			rm ~/Choices/ROX-Filer/pip
			rm ~/Choices/ROX-Filer/ipp
			touch ~/Choices/ROX-Filer/pip
			exit
		fi
	sed -i 3i\ "$bd" ~/Choices/ROX-Filer/PuppyPin0 2> /dev/null
	sed -i 4\\ ~/Choices/ROX-Filer/PuppyPin0
	sed -i 4d ~/Choices/ROX-Filer/PuppyPin0 2> /dev/null
	mv ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/PuppyPin-orig
	mv ~/Choices/ROX-Filer/PuppyPin0 ~/Choices/ROX-Filer/PuppyPin
	DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/PuppyPin
	gtkdialog-splash -placement top-left -bg blue -text "$(gettext 'No Icons')" &
	SPLASHPID=$!
	sleep 2
	kill $SPLASHPID 2> /dev/null
elif [[ ! -e ~/Choices/ROX-Filer/nipp && ! -e ~/Choices/ROX-Filer/ppin ]]; then
touch ~/Choices/ROX-Filer/ppin
fi
[ -x /root/Startup/xonclock* ] && /root/Startup/xonclock*
if [[ ! -e ~/Choices/ROX-Filer/PuppyPin0 ]]; then
	cp ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/PuppyPin0
fi

Still a bit buggy. Some commands need to be invoked from iconified desktop others from iconless desktop.
Last edited by stemsee on Tue 02 Dec 2014, 22:34, edited 9 times in total.

stemsee

#14 Post by stemsee »

yet to do add option for choosing which DISPLAY to affect. Add icons as choice from all installed apps.

stemsee

#15 Post by stemsee »

Added mechanism for populating PuppyPin-bak with all links from /usr/share/applications which were linked to /usr/share/renamed and 'renamed' to remove .desktop suffix 'nicons add'. This is important for the repo of available icons when using 'nicons add' which iterates through PuppyPin-bak letting the user see line by line the icons/apps available to add simply by pressing 'y Enter' or Enter for 'n' not added. There is also a rox window opens with links from /usr/share/applications renamed and ready to drag to the desktop 'nicons add'.

Now I am trying to use array to make icons grid like android home screen. Any pointers welcome.

EDIT: disabled. Because rox behaves unpredictably at some point. Needs more testing in case laptop tool pan feature interferred.
Attachments
capture16486.jpg
(43.09 KiB) Downloaded 201 times
Last edited by stemsee on Tue 02 Dec 2014, 06:41, edited 4 times in total.

stemsee

#16 Post by stemsee »

Code: Select all

res=`xrandr | grep -w connected | cut -f3 -d ' ' | cut -f1 -d '+' | tr 'x' ' '`
maxx=`echo $res | cut -f1 -d ' '`
maxy=`echo $res | cut -f2 -d ' '`
lines=`ls -1 /usr/share/renamed | wc -l`
echo "$(((maxx) / 12))"
echo "$(((maxy) / 12))"
varx=1
vary=1
varx=$((varx + 70)) #incremental
vary=$((vary + 70))
y1 x[1-12]
y2 x[1-12]

y15 x[1-20] 
Something like this maybe

Code: Select all


BEGIN {
    varx=1;
	varx=$((varx + 70));
    OFS = "\"";
    split("2", Fields);
    split("$varx", Replacements);

}
{
	while (count++<20)
    for (i in Fields) {
        for (j in Replacements) {
            Replace = Replacements[j];
            sub(Replace Replace, $Fields[i]);
        }
    }
    print;
}
BEGIN {
        vary=1;
	vary=$((vary + 70));
    OFS = "\"";
    split("4", Fields);
    split("$vary", Replacements);

}
{
	while (count++<15)
    for (i in Fields) {
        for (j in Replacements) {
            Replace = Replacements[j];
            sub(Replace Replace, $Fields[i]);
        }
    }
    print;
}
?? How to lay the 300 icons evenly spaced on a grid by XY alignment per screen resolution?? Automatically!
Last edited by stemsee on Mon 01 Dec 2014, 07:26, edited 8 times in total.

stemsee

#17 Post by stemsee »

This wont work as wanted unless all of the icons are 48 x 48. Otherwise the writing wont line up. Short icons will be higher because top left corner of icon is used to position them, not bottom right. But it works to a certain degree.... better than nothing I suppose!

stemsee

#18 Post by stemsee »

Code: Select all

#!/bin/bash
rm ~/Choices/ROX-Filer/PuppyPin-formatted
rm /tmp/files
touch /tmp/files
sed -n '3,16p;16q' ~/Choices/ROX-Filer/PuppyPin-bak >> /tmp/files
touch ~/Choices/ROX-Filer/PuppyPin-formatted
varx=10
vary=10
indexx=2
indexy=4

while read line 
do
	sed -l '/4/d'
	varx=$(($varx + 90))
	echo $line | awk -F\" -v OFS=\" '{$'$indexx'='$varx'; print }' | awk -F\" -v OFS=\" '{$'$indexy'='$vary'; print }' >> ~/Choices/ROX-Filer/PuppyPin-formatted
done < /tmp/files

stemsee

#19 Post by stemsee »

Nicons add = renamed links from /usr/share/applications
Attachments
capture8647.jpg
(31.28 KiB) Downloaded 213 times

stemsee

#20 Post by stemsee »

ok ... I need hellp with these nested loops! I can't think clearly. How to assign 12 increments of x for one increment of y whilst iterating through a list of 300 entries 10 lines at a time. I have spent hours and hours on this ... This code generates 35000 lines. It should be 300. For each y it is generating 335 lines. The problem really is how to feed only twelve lines at a time from the 300 line xml puppypin (this is the icon repo).

Code: Select all

#!/bin/bash
# nested-loop.sh: Nested "for" loops.
rm ~/Choices/ROX-Filer/PuppyPin-formatted
touch ~/Choices/ROX-Filer/PuppyPin-formatted
rm /tmp/files
touch /tmp/files
cat ~/Choices/ROX-Filer/PuppyPin >> /tmp/files
sed -i '1,3d' /tmp/files
sed -i '$d' /tmp/files 
#echo $file | head -10 >> /tmp/files
varx=0
vary=0
indexx=2
indexy=4

  outer=1             # Set outer loop counter.

for vary in 0 90 170 250 330 410 490 570
do
vary=$(($vary + 1))
  inner=1           # Reset inner loop counter.

  
  # Beginning of inner loop.
  for varx in 0 90 170 250 330 410 490 570 650 730 810 890 970
  do
varx=$(($varx + 1))
	cat /tmp/files | awk -F\" -v OFS=\" '{$'$indexx'='$varx'; print }' | awk -F\" -v OFS=\" '{$'$indexy'='$vary'; print }'  >> ~/Choices/ROX-Filer/PuppyPin-formatted
    echo "Pass $inner in inner loop."
    let "inner+=1"  # Increment inner loop counter.
 
 
  # End of inner loop.

  let "outer+=1"    # Increment outer loop counter. 
  echo              # Space between output blocks in pass of outer loop.
  unset varx
done
 done  
 exit 0
Last edited by stemsee on Wed 03 Dec 2014, 20:03, edited 1 time in total.

Post Reply