Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 31 Jul 2015, 05:38
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Script to create custom puppypins and change from terminal
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [14 Posts]  
Author Message
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Fri 04 Jul 2014, 17:01    Post subject:  Script to create custom puppypins and change from terminal
Subject description: SOLVED how to make one script
 

I am new to scripting. I have written a few simple yet effective and robust scripts. I have alo succssfully edited quite a number of other scripts to do what I needed. Now I have written a script which 'sources' a file 'res.txt' and imports its variable 'res=a' '$res' res can be a charachter a - e, each characer corresponds to a custom PuppyPin by screen resolution. The script determines the value of the variable 'a-e' and backs up the current PuppyPin to the corresponding custom PuppyPin called one of these '1366,1440,1650,1920,2560' . Then the script, which is called from the terminal by typing your horizontal screen resolution eg 1366 or 1920, copies the relevant custom PuppyPin to PuppyPin, then writes the corresponding string to res.txt eg res=b so that next res change will not lose any user changes of desktop icons and position for each of the custom puppypins, and restarts windowmanager.

I have five resolution presets puppypins, and five corresponding scripts named 1366, 1440, 1650, 1920 and 2560. My question is how to put this into one script? Here is script for 1366, the other four scripts exactly the same exxcept for last cp and echo commands which change to the relevant resolution (custom puppypin) and corresponding string to be written to res.txt All help appreciated! But in fact this works fine for screen 0!

Code:
#!/bin/sh
source ~/Choices/ROX-Filer/res.txt
#rm ~/Choices/ROX-Filer/res.txt
if [ $res = a ]; then
   cp -f ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/1366
if [ $res = b ]; then
   cp -f ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/1440
if [ $res = c ]; then
   cp -f ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/1650
if [ $res = d ]; then
   cp -f ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/1920
if [ $res = e ]; then
   cp -f ~/Choices/ROX-Filer/PuppyPin ~/Choices/ROX-Filer/2560
fi
fi
fi
fi
fi
cp -f ~/Choices/ROX-Filer/1366 ~/Choices/ROX-Filer/PuppyPin
echo "res=a" > ~/Choices/ROX-Filer/res.txt
restartwm
#the end##

Last edited by stemsee on Sat 12 Jul 2014, 06:18; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
RSH


Joined: 05 Sep 2011
Posts: 2420
Location: Germany

PostPosted: Fri 04 Jul 2014, 17:35    Post subject:  

Just have a look at the VarioMenu in L.A.S.S.I.E. or LazY Puppy.

In /usr/local/variomen you shoud find lots of useful code, to create custom puppypins and change them without to use the terminal and without to restart the window manager.

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Fri 04 Jul 2014, 17:39    Post subject:  

ok will do!
Back to top
View user's profile Send private message MSN Messenger 
puppyluvr


Joined: 06 Jan 2008
Posts: 3272
Location: Chickasha Oklahoma

PostPosted: Fri 04 Jul 2014, 17:41    Post subject:  

Very Happy Hello,
Look at:
case
*
*
esac

_________________
Close the Windows, and open your eyes, to a whole new world
http://puppylinuxstuff.meownplanet.net/puppyluvr/
Puppy Linux Users Group on Facebook

Puppy since 2.15CE...
Back to top
View user's profile Send private message Visit poster's website 
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Sat 05 Jul 2014, 02:43    Post subject:  

@puppyluvr
case.....esac will be suitable for an automatic version, which sources 'xrandr > res.txt' locates he 'current' resolution and matches the correct case. This is difficult to implement when using dual monitors with different resolutions, but is easy with my manual selection.
Back to top
View user's profile Send private message MSN Messenger 
technosaurus


Joined: 18 May 2008
Posts: 4527

PostPosted: Mon 07 Jul 2014, 19:33    Post subject:  

/tmp/res.txt
Code:
a=1366
b=1440
c=1650
d=1920
e=2560
res=$a

set_res
Code:
#!/bin/sh
sed -i "s/res=.*/res=\$$1/g" /tmp/res.txt


Then use something like this to change the pinboard
Code:
[ -f "/tmp/res.txt" ] && . "/tmp/res.txt" || echo problem
[ -f "$HOME/Choices/ROX-Filer/$res" ] cp -f "$HOME/Choices/ROX-Filer/$res" "$HOME/Choices/ROX-Filer/PuppyPin"

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
puppyluvr


Joined: 06 Jan 2008
Posts: 3272
Location: Chickasha Oklahoma

PostPosted: Mon 07 Jul 2014, 20:26    Post subject:  

Very Happy Hello,
+1 technosaurus!

_________________
Close the Windows, and open your eyes, to a whole new world
http://puppylinuxstuff.meownplanet.net/puppyluvr/
Puppy Linux Users Group on Facebook

Puppy since 2.15CE...
Back to top
View user's profile Send private message Visit poster's website 
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Tue 08 Jul 2014, 08:47    Post subject:  

@technosaurus

Thanks! I will study your code in order to understand it fully!

until then I will replace scripts 1-5 with this + appropriate res(1366 or 1440 etc) respectively.
Code:
#!/bin/sh
DISPLAY=:0.0 rox --pinboard ~/Choices/ROX-Filer/1366


It works fine without wm restart and saves changes per res, and I can understand it!

But it doesn't work per display on dual monitors (DISPLAY=:0.1! Maybe need to setup xorg.conf second screen entry first!
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Fri 01 Aug 2014, 07:43    Post subject:  

technosaurus wrote:
/tmp/res.txt
Code:
a=1366
b=1440
c=1650
d=1920
e=2560
res=$a

set_res
Code:
#!/bin/sh
sed -i "s/res=.*/res=\$$1/g" /tmp/res.txt


Then use something like this to change the pinboard
Code:
[ -f "/tmp/res.txt" ] && . "/tmp/res.txt" || echo problem
[ -f "$HOME/Choices/ROX-Filer/$res" ] cp -f "$HOME/Choices/ROX-Filer/$res" "$HOME/Choices/ROX-Filer/PuppyPin"


I wondered if you would offer a step by step explanation ... ? I am forming a fuzzy idea of how it works! But where does the input come to change res? Only the text file res.txt? How to import actual res from system and make automatic for display :0.0 as gtk2 has trouble with DISPLAY=:0.1 as far as I know.

Thanks for any furtherance.
Back to top
View user's profile Send private message MSN Messenger 
technosaurus


Joined: 18 May 2008
Posts: 4527

PostPosted: Sat 02 Aug 2014, 05:38    Post subject:  

double post
_________________
Web Programming - Pet Packaging 100 & 101

Last edited by technosaurus on Sat 02 Aug 2014, 05:39; edited 1 time in total
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4527

PostPosted: Sat 02 Aug 2014, 05:38    Post subject:  

stemsee wrote:
I wondered if you would offer a step by step explanation ... ? I am forming a fuzzy idea of how it works! But where does the input come to change res? Only the text file res.txt? How to import actual res from system and make automatic for display :0.0 as gtk2 has trouble with DISPLAY=:0.1 as far as I know.

Thanks for any furtherance.
Rox can't do that. If you want different backgrounds per desktop, use jwm. How you get res.txt is up to you - xrandr will give you a slew of different supported resolutions, but I have no idea what you will want. Then just add these 2 lines to your .xinitrc somewhere before it calls rox
Code:

#check if exists and load it or indicate problem
[ -f "/tmp/res.txt" ] && . "/tmp/res.txt" && \
[ -f "$HOME/Choices/ROX-Filer/$res" ] && cp -f "$HOME/Choices/ROX-Filer/$res" "$HOME/Choices/ROX-Filer/PuppyPin"

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Sat 02 Aug 2014, 07:02    Post subject:  

ok thanks!
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Sun 10 Aug 2014, 02:02    Post subject:  

Set using command line variables $0 $1 $2
Code:
# set_res.sh 1366
#res 1366
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 1250
Location: In The Way

PostPosted: Fri 15 Aug 2014, 06:57    Post subject:  

I also noticed fixPuppyPin (B.Kauler), which seems to be mathematical operation to fixposition of icons relative to screen mid point and right edge. Needs updating I think.
Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 1 of 1 [14 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0885s ][ Queries: 11 (0.0073s) ][ GZIP on ]