Script to create custom puppypins and change from terminal

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
stemsee

Script to create custom puppypins and change from terminal

#1 Post by stemsee »

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: Select all

#!/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, 10:18, edited 1 time in total.

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

#2 Post by RSH »

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.
[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]

stemsee

#3 Post by stemsee »

ok will do!

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#4 Post by puppyluvr »

:D Hello,
Look at:
case
*
*
esac
Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!

Puppy since 2.15CE...

stemsee

#5 Post by stemsee »

@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.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#6 Post by technosaurus »

/tmp/res.txt

Code: Select all

a=1366
b=1440
c=1650
d=1920
e=2560
res=$a
set_res

Code: Select all

#!/bin/sh
sed -i "s/res=.*/res=\$$1/g" /tmp/res.txt
Then use something like this to change the pinboard

Code: Select all

[ -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"
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#7 Post by puppyluvr »

:D Hello,
+1 technosaurus!
Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!

Puppy since 2.15CE...

stemsee

#8 Post by stemsee »

@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: Select all

#!/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!

stemsee

#9 Post by stemsee »

technosaurus wrote:/tmp/res.txt

Code: Select all

a=1366
b=1440
c=1650
d=1920
e=2560
res=$a
set_res

Code: Select all

#!/bin/sh
sed -i "s/res=.*/res=\$$1/g" /tmp/res.txt
Then use something like this to change the pinboard

Code: Select all

[ -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.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#10 Post by technosaurus »

double post
Last edited by technosaurus on Sat 02 Aug 2014, 09:39, edited 1 time in total.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#11 Post by technosaurus »

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: Select all

#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"
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

stemsee

#12 Post by stemsee »

ok thanks!

stemsee

#13 Post by stemsee »

Set using command line variables $0 $1 $2

Code: Select all

# set_res.sh 1366
#res 1366

stemsee

#14 Post by stemsee »

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.

Post Reply