LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-17-2015, 11:46 PM   #1
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311
Blog Entries: 2

Rep: Reputation: 16
Question lxde: different icons on different desktops


Lxde: How to create different icons(shortcuts) on the different desktops?

I already have configured different background pictures for each (virtual) desktop. I am signed in as user 'a', thus ~ = /home/a. I like being organized, and naturally the next step is to configure different icons(shortcuts) on the different desktops in lubuntu 14.04LTS. Natually being that android has different icons on different desktops, users will want this feature more and more when on lubuntu. Unfortunately when I google, not only does it seem that there isn't anyway configuration to do this, some people even claim that lxde can't have different icons on different desktops.

I then follow a tutorial http://ubuntuforums.org/showthread.php?t=1651769 by ELRINDELL where each desktop has different icons. Due to Elrindell's desktop environment being quite different than lxde(1-gnome vs lxde; 2-avant-window-navigator has long been depreciated), I had to significantly modify some procedures/scripts, as shown below:
Code:
mkdir -p ~/Desktop1 ~/Desktop2 ~/.config/Desktop1 ~/.config/Desktop2;
cp /home/a/.config/pcmanfm/default/desktop-items-0.conf ~/.config/Desktop1;
cp /home/a/.config/pcmanfm/default/desktop-items-0.conf ~/.config/Desktop2;
gedit ~/bin/desktop1.sh ~/bin/desktop2.sh /home/a/.local/share/applications/Desktop1.desktop
 /home/a/.local/share/applications/Desktop2.desktop;
sudo chmod +x ~/bin/desktop1.sh ~/bin/desktop2.sh;
I then display ~/Desktop in pcmanfm, and
1) Move the icons you want into your ~/Desktop1 folder, and the others to ~/Desktop2 folder.
2) Edit the changes you made in 1) above in both files:
>~/.config/Desktop1/ desktop-items-0.conf
>~/.config/Desktop2/ desktop-items-0.conf:
. a. Adjust to the wallpaper you want for that
Code:
wallpaper0=/home/Wallpaper/trees-in-the-sea.jpg
. b. At the last section are the shortcuts/links. For me, I only want 4 shortcuts on my desktop: Codeblocks for a pm environment(cb_pm.desktop), a folder(Man files), another desktop file (timemgmt.desktop), and a link to a spreadsheet(command.xls).
Code:
[cb_pm.desktop]
x=860
y=55

[Man files]
x=860
y=145

[timemgmt.desktop]
x=860
y=235

[command.xls]
x=860
y=325
After I make some final adjustments to the x,y coordinates of each shortcut to get them perfectly lined up, I then make my script which is based on elrindell's tutorial, where I paste the below into ~/bin/desktop1.sh and ~/bin/desktop2.sh, making the appropriate modifications for ~/bin/desktop2.sh:

Code:
#!/bin/bash
#TURN OFF DESKTOP
pcmanfm --desktop-off
sleep 0.5

#SWITCH DESKTOP ITEMS
#Delete current Desktop's set icons
rm -rfv ~/Desktop/.xls
rm -rfv ~/Desktop/phonebook.desktop
rm -rfv ~/Desktop/*~

#Copy over new icons
cp -dpr ~/Desktop1/* ~/Desktop				#-d option to copy over link, not link's target file; -p     same as --preserve=mode,ownership,timestamps; 

#UPDATE DESKTOP CONF FILES
cp -p ~/.config/Desktop1/desktop-items-0.conf ~/.config/pcmanfm/default
cp -p ~/.config/Desktop1/desktop-items-0.conf ~/.config/pcmanfm/lubuntu

#RESTART DESKTOP
openbox --reconfigure
sleep 0.5
pcmanfm --desktop&
In order to add both *.sh applications to the Application launch bar within lxpanel for a 'click and go' GUI experience, I paste the following into the desktop files (Desktop1.desktop & Desktop2.desktop)

Code:
[Desktop Entry]
Type=Application
Name=Desktop1
Exec=/home/a/bin/desktop1.sh
Icon=/home/Icons/Desktop/Pencil_blue1.png
Categories=Graphics
Terminal=false

PROBLEMS:
The above really works quite well, except for the 2 following shortcomings:
1) Persistent shortcuts: Shortcuts added later, when not making the corresponding changes in Desktop1(or 2).sh and desktop-items-0.conf will keep appearing on both desktops. Having to change both of these files everytime you add a shortcut is rather onerous.

Attempt 01: At first I thought that the code above in desktop1.sh (and desktop2.sh, specifically first rm -rfv then cp -p) lacked flexibility, since when you add another file to the desktop, unless you make the corresponding changes in ~/.config/Desktop2/ desktop-items-0.conf, the later added in icons/folders/shortcuts/program launchers to the desktop will just be persistent shortcuts, and they will just remain on every desktop. Thus I thought to replace rm -rfv then cp -p with a move mv command(Idea #1).
Code:
mv ~/Desktop/* ~/Desktop2;				#Moves contents of the display Desktop to Desktop2
mv ~/Desktop1/*	~/Desktop;				#Moves contents of Desktop1 to the display Desktop
But in case the user inadvertently clicks on desktop1 two consecutive times, then the contents of desktop 2 are loaded into desktop1 while simultaneously the other desktop, which is empty (as of the completion of the program's first run) is loaded into the current desktop, producing an empty desktop.

Attempt 02: I then thought of another way of beating this 'persistent shortcuts' issue: Use rsync(Idea #2):

Code:
rsync -Savi -Eu -stat --delete ~/Desktop/* ~/Desktop1
rsync -Savi -Eu -stat --delete ~/.config/pcmanfm/default/desktop-items-0.conf ~/.config/Desktop1
Unfortunately the exact same problem happens again, as in idea #1 above. If you are currently in Desktop2, and you hit Desktop 2 again, then the 1st rsync command erases all the Desktop1's icons and then writes Desktop2's icons into the folder ~/Desktop1, which is supposed to backup Desktop1's icons.
And then the desktop-items-0.conf file for desktop2 will replace the *.conf file in .config/Desktop1!

2) The final problem is how the windows in lxpanel's Task Bar(Window List) don't change.
Does anyone have a better idea on how someone in lxde (specifically lubuntu) can have different icons on different desktops? Is there any way to solve the two shortcomings above?

Andrew

Last edited by andrew.comly; 05-18-2015 at 07:42 AM. Reason: clarity
 
Old 05-23-2015, 03:39 AM   #2
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262
Blog Entries: 2

Rep: Reputation: 49
I'm not sure I completely understand your solution, but it seems nifty.
Couldn't you use a symlink to the directories instead of moving the files? That might also give you correct behaviour when adding files/desktop icons.
 
1 members found this post helpful.
Old 05-25-2015, 05:26 AM   #3
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
I overcame the "lxpanel's Task Bar(Window List) not changing" problem by:
1) Write in the command 'wmctrl -s 1' under the second 'sleep 0.15' line in desktop2.sh and also 'wmctrl -s 0' under the second 'sleep 0.15' line in desktop1.sh.
2) Make sure in desktop-items-0.conf from ~/.config/Desktop1 that you put your desired wallpaper right after: 'wallpaper0=', and
desktop-items-0.conf from ~/.config/Desktop2 that you put your desired wallpaper right after: 'wallpaper1='

I'll try the symlink suggestion this weekend when I have some more time, thanks for your help Weapon S.

Last edited by andrew.comly; 05-25-2015 at 05:27 AM.
 
Old 02-19-2016, 10:33 AM   #4
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Wink Desktop switcher: 2016 Version

I have used functions, conditional statements and the wait command to improve my desktop switching program. Moreover, now I don't have to edit the files default/desktop-items-0.conf and lubuntu/desktop-items-0.conf everytime I want to 1) change the x,y coordinates of the icons; 2) add/delete desktop icons.

The content of each shellscript is the same, but due to the automatic process of obtaining the value for the variable TargetNum (the desktop # that you will be switching to) I have included both names below:

desktopA1.sh (& desktopA2.sh)
Code:
#!/bin/bash

####################  GPL: GENERAL PUBLIC LICENSE ###################
#																	#
# Copyright 2016 02 19					#
# 																	#
# This program is free software; you can redistribute it and/or 	#
# modify it under the terms of the GNU General Public License as 	#
# published by the Free Software Foundation; either version 2 of	#
# the License, or (at your option) any later version.				#
# 																	#
# This program is distributed in the hope that it will be useful,	#
# but WITHOUT ANY WARRANTY; without even the implied warranty of	#
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the		#
# GNU General Public License for more details.						#
# 																	#
# You should have received a copy of the GNU General Public License	#
# along with this program; if not, write to the Free Software		#
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,		#
# MA 02110-1301, USA.												#
#																	#
#####################################################################

#####################################################################
#																	#
#		AUTHOR														#
#		Andrew F. Comly					 							#
#		andrew.comly@gmail.com										#
#																	#
#		PURPOSE														#
#			1. Change from current Desktop to another desktop.		#
#																	#
#		PREREQUISITE												#
#			1. mkdir -p ~/.local/share/DesktopSwitch/{icons/Desktop{1,2},conf_${DIMENSIONS}/Desktop{1,2}/{default,lubuntu}}
#
#		PROCEDURE
#			1. Bkp currently running desktop
#				a) bkp first desktop's 
#					1) icons
#					2) config files (icon positions & wallpaper)
#
#			2. Clean up desktop
#
#			3. Update the icon positions & wallpaper
#				a) copy the target desktop's icons from reserve
#				folder to ~/Desktop
#				b) copy the target desktop's config (desktop-items-0.conf)
#
#			4. Restart Desktop
#				a) move to desktop 2 (wmctrl)
#
#####################################################################

#VARIABLES
	#INITIATE
		unset CONF CurDeskNum DESKSWITCH DIMENSIONS LOCALSHARE TargetNum
		TargetNum=0; CurDeskNum=0; DEBUG=1;
		
	#DEFINE
		#Static
			DIMENSIONS=$(echo $(xdpyinfo | grep 'dimensions' | awk '{print$2}'));
				#So far I have made this program for computers with screen sizes of 1024x600 and 1366x768.  With different screen sizes the x,y coordinates of the icons will naturally be different.
			LOCALSHARE=.local/share
			MYDESK=home/${USER}/Desktop
			PCMANFM=home/${USER}/.config/pcmanfm	

		#Desktop Numbers	
			let CurDeskNum=$(wmctrl -d | grep '*' | awk '{print$1}')+1		#Number of the desktop you want to switch from (are originally on).
			#Target Desk Number			=		Number of the desktop you want to switch to.
				Base=`basename $0`;				#Extracts the filename (gets rid of path) from the current file.
				NoExt=${Base/.sh/}				#Cuts away the filename's extension.
				TrgtDskNum=${NoExt/desktopA/}	#Extracts the desktop's number "X" from remaining string "desktopAX"
					#Nota Bene:  Due to the above procedure to obtain Target Number, the code for file desktopA2.sh is identical to the code of desktopA1.sh (and if you choose to have a more desktops: than the code for desktopA3.sh desktopA4.sh, ... desktopAn.sh will also be identical)

		#COMPOSITE
			DESKSWITCH=~/${LOCALSHARE}/DesktopSwitcher
			CONF=${DESKSWITCH}/conf_${DIMENSIONS}


#FUNCTIONS______________________________________________________________
	bkp()
	{
	  #DIRECTORY
		if [ -d /${1} ]
			then
			  #VERIFY PARENT DIRECTORY EXISTS
				if [ ! -d /${2} ]
					then
						mkdir -p /${2}
				fi
			  #COPY OVER DIRECTORY TO DESKTOP CACHE
				if [ ${DEBUG} -eq 0 ]
					then
						mv -f /${1}/* /${2}
				else
					rsync -a -E --delete -f "- *~" -f "- .~*" /${1}/ /${2}
						#Reason for excluding "*~" and ".~*" is that when libreoffice and Kingsoft WPS locks files, it can leave files ending with a "~" and/or beginning with a ".~" on the desktop
				fi
	  
	  #FILES
		elif [ -f /${1} ]
			then
				#VERIFY TARGET DIRECTORY EXISTS 
					if [ ! -d /${2} ]
						then
							mkdir -p /${2}
					fi
				rsync -a -E --delete /${1} /${2}
		fi
	}

	new()
	{
		if [ -d /${1} ]
			then
				if [ ${DEBUG} -eq 0 ]
					then
						mv -f /${1}/* /${2}
							#Even though this moves icons quicker, however using "mv" for desktop icons (while you still use rsync for the .conf files), will trigger a system response and end up crippling the correct placement of desktop icons.
				else
					rsync -a -E --delete /${1}/ /${2}
						#Notice the only difference here (elif) compared with if section above is the "/" on the end of the first argument above.
				fi
		elif [ -f /${1} ]
			then
				rsync -a -E --delete /${1} /${2}
		fi
			#Why no "-u" option for rsync?  
				#In the case of copying over *.conf file:
					#the file for the new desktop could be older than the conf file for the desktop we are switching from.  
				#In case of copying over a directory:
					#Since we have already put this WHOLE program within the if [ TargetNum -ne CurDeskNum ] conditional statement, using "-u" here is redundant.
	}

#__________________________________________________Ends Function Section


if [ ${CurDeskNum} -ne ${TrgtDskNum} ]
  then

	#1) BACKUP INTO CORRESPONDING DESKTOP'S CACHE
		  #DESKTOP ICONS 
			bkp ${MYDESK}/ ${DESKSWITCH}/icons/Desktop${CurDeskNum}
	
		  #SETTINGS  (wallpaper, coordinate config files) 
			bkp ${PCMANFM}/default/desktop-items-0.conf ${CONF}/Desktop${CurDeskNum}/default
			bkp ${PCMANFM}/lubuntu/desktop-items-0.conf ${CONF}/Desktop${CurDeskNum}/lubuntu
	
			
	#2) CLEAN
		wait
		rm -rf /${MYDESK}
		mkdir -p /${MYDESK}
		wait
			#Before I thought how two "wait" commands are too much, and that the rm -rfv Desktop along with the "mkdir -p /${MYDESK}" is redundant with the rsync --delete in the new function.  But in experimental trials when commenting out the first 3 lines above (wait, rm and then mkdir) then the icons positioning will be completely messed up after each switch.
			#When using "mv" instead of rsync in bkp and new above, rm -rf /${MYDESK} will leave /${MYDESK} completely empty. 
	
	
	#3) COPY NEW FILES FROM CACHE TO TARGET FOLDERS
		  #ICONS
			new ${DESKSWITCH}/icons/Desktop${TrgtDskNum} ${MYDESK}
			
		  #SETTINGS
			new ${CONF}/Desktop${TrgtDskNum}/default/desktop-items-0.conf ${PCMANFM}/default
			new ${CONF}/Desktop${TrgtDskNum}/lubuntu/desktop-items-0.conf ${PCMANFM}/lubuntu
			wait
			
		  #DISPLAY
			openbox --reconfigure;
	
		#NOTES
			#You might think that rsync --delete would end up deleting the conf settings files and icons in the previous calls to the functions.  But note well: Each call to the function rsyncs source files to a unique target folder.  Thus all source files end up in the target folders.
	
	
	#4) SWITCH TO TARGET DESKTOP
			wmctrl -s $((${TrgtDskNum}-1));

fi			#Ends the conditional clause: if [ CurNum -ne TarNum ]


########################################################################
#
#	Depreciated
#		1) TURN OFF DESKTOP
#			pcmanfm --desktop-off;
#
#		4) RESTART DESKTOP
#			wait;
#			pcmanfm --desktop;
#
#		Functions - bkp - files section:  Originally I thought that the file name could only be placed in Argument 2 (when calling the function) for the sake of checking if that file was already there.  But rsync can do that with option "-u", standing for update.  Thus no need to be that complicated and check whether the config file exists on the target and is newest.
#
# By following experiment, mv is quicker for the launcher, thus DEBUG=0 chosen
#	RSYNC TRIALS						
#											  COUNT		TTL		AVG
#	term	2.5	4.88	4.74	2.2		2.8		5		17.12	3.424
#	launcher 	5.36	3.28	4.79	2.1		4		15.53	3.8825
#									
#	mv trials								
#	term	5.4	5.04	3.85	3.3		1.87	5		19.46	3.892
#	launcher 	2.21	2.34	4.71	2.6		4		11.86	2.965
#
########################################################################

Last edited by andrew.comly; 02-21-2016 at 09:57 AM. Reason: clarity
 
Old 02-21-2016, 09:11 AM   #5
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Smile Lubuntu Users, please give me some feedback how this works!

Any Lubuntu Users out there, feel free to give me some feedback how my 2016 version performs! Not good enough for the official lubuntu OS, but worth trying out!
 
  


Reply

Tags
desktop effects, icons, lxde, scripting, shortcuts



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: LXDE and Xfce - the other desktops LXer Syndicated Linux News 1 12-19-2011 03:23 PM
lxde cant add icons on desktop InvRa Gentoo 1 01-17-2011 11:21 PM
LXer: PCLinuxOS Magazine: Gtk Lightweight Desktops: Xfce & LXDE Special Edition LXer Syndicated Linux News 0 11-19-2010 06:40 PM
Opinions on lightweight desktops: icewm, jwm, lxde, etc. walterbyrd Linux - Software 12 12-18-2009 06:41 PM
[SOLVED] Changin Icons in LXDE DetroitLibertyPenguin Linux - Newbie 3 07-14-2009 10:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 11:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration