move icon by a script

Window managers, icon programs, widgets, etc.
Message
Author
der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

move icon by a script

#1 Post by der-schutzhund »

Hi all,

i need a script to move a icon on the Desktop to a new position (x,y).
can someone help me?

Wolfgang


P.S. Am really looking forward to your answers!

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

#2 Post by puppyluvr »

:D Hello,
Icon locations are controlled here:
/root/Choices/ROX-Filer/PuppyPin

But you have to restart Rox to change them, so doing so with a script would be difficult.
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...

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#3 Post by der-schutzhund »

puppyluvr wrote::D Hello,
Icon locations are controlled here:
/root/Choices/ROX-Filer/PuppyPin

But you have to restart Rox to change them, so doing so with a script would be difficult.
Hi puppyluvr!

A restart should not be!
The icons you can move with the mouse and you need not a restart.

I would love to develop a whole new user interface only with icons!

Wolfgang

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#4 Post by SFR »

Hey Der-schutzhund

This little script should do the job; just make backup of your PuppyPin first, because I haven't tested it extensively:

Code: Select all

#!/bin/bash

MYNAME="$(basename $0)"

[ "$#" -ne 3 ] && echo -e "Usage:\n$MYNAME <icon_name> <new_X> <new_Y>" && exit 1 

x="`echo $2 | tr -cd [:digit:]`"
y="`echo $3 | tr -cd [:digit:]`"
[ "$x" = "" ] || [ "$y" = "" ] && echo "<new_X> & <new_Y> must be numerical values..." && exit 1

PINDIR="$HOME/Choices/ROX-Filer"

TEMP=`grep -n -w -m1 "label=\"$1\"" "$PINDIR/PuppyPin"`
[ ! "$TEMP" ] && echo "Can't find such icon..." && exit 1

LINE_NUM=`echo ${TEMP%:*}`
NEW="<icon x=\"$x\" y=\"$y\" ""`echo "$TEMP" | cut -f6- -d ' '`"

touch "$PINDIR/PuppyPin_new"

awk 'NR>=1&&NR<='$(($LINE_NUM-1))'' "$PINDIR/PuppyPin" > "$PINDIR/PuppyPin_new"
echo "  $NEW" >> "$PINDIR/PuppyPin_new"
awk 'NR>='$(($LINE_NUM+1))'' "$PINDIR/PuppyPin" >> "$PINDIR/PuppyPin_new"

mv "$PINDIR/PuppyPin_new" "$PINDIR/PuppyPin"

rox --pinboard=/root/Choices/ROX-Filer/PuppyPin
Usage example:
script_name calc 200 500

But it's not perfect:
- If there are two or more icons with the same names, only the first (according to order in /root/Choices/ROX-Filer/PuppyPin) will be moved.
- Refreshing the pinboard causes that Conky disappears (if one have it).

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#5 Post by der-schutzhund »

Hey sfr,

nice but the screen is for a moment dark, because of the refresh!

This is my idea:
All icons are assigned to groups.
For example, office, programming, system, as in the text menu.
For this first level, there are major icons or using wbar.
If you click on the icon for the Office then Office icons are moved to their positions.
If you then click on the mainicon system the following happens:
- The current positions of office icons are stored in a list.
- The office icons are all pushed to the position 10,10.
- The positions of the system icons are read from a list.
- The system icons are pushed to their old positions

With this simple procedure could be used to enable a clear view, graphical menu system. All commands are accessible in two clicks. No text menus longer needed.

What do you think?

Greetings!

Wolfgang

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#6 Post by SFR »

Sounds good and should be absolutely possible to implement, especially that there's a much better way to control Pinboard icons (no blinking).

First script from this post sets new icon at desired coordinates:
http://www.murga-linux.com/puppy/viewto ... 752#344752

It's also possible to remove an icon with <PinboardRemove> tag, details here:
http://rox.sourceforge.net/Manual/Manua ... .html#soap

EDIT: I haven't noticed before - in the first post of the above thread there's already working script for adding, removing and changing desktop icons.

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#7 Post by der-schutzhund »

SFR wrote:Sounds good and should be absolutely possible to implement, especially that there's a much better way to control Pinboard icons (no blinking).

First script from this post sets new icon at desired coordinates:
http://www.murga-linux.com/puppy/viewto ... 752#344752

It's also possible to remove an icon with <PinboardRemove> tag, details here:
http://rox.sourceforge.net/Manual/Manua ... .html#soap

EDIT: I haven't noticed before - in the first post of the above thread there's already working script for adding, removing and changing desktop icons.

Greetings!
Hey SFR,

it works! :D

But .... if i add for example 20 icons it will take ca. 2 sec. :(

Greetings!

Wolfgang

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#8 Post by der-schutzhund »

Code: Select all

#!/bin/bash

 echo "<?xml version=\"1.0\"?>
<env:Envelope xmlns:env=\"http://www.w3.org/2001/12/soap-envelope\">
 <env:Body xmlns=\"http://rox.sourceforge.net/SOAP/ROX-Filer\">
  <PinboardAdd>
   <Path>$1</Path>
   <X>$2</X>
   <Y>$3</Y>
   <Label>$4</Label>
   <Args>$5</Args>
  </PinboardAdd>
 </env:Body>
</env:Envelope>"  | rox -R 
Is it possibly to make the script faster?

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#9 Post by SFR »

Hmm, I just tried and ROX's SOAP RPC mechanism accepts multiple <Pinboard...> tags at once.
Check out display time of the following one. ;)

Code: Select all

#! /bin/bash

echo "<?xml version=\"1.0\"?>
<env:Envelope xmlns:env=\"http://www.w3.org/2001/12/soap-envelope\">
 <env:Body xmlns=\"http://rox.sourceforge.net/SOAP/ROX-Filer\">
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*1))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*2))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*3))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*4))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*5))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*6))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*7))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*8))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*9))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*10))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
</env:Body></env:Envelope>" | rox -R
EDIT: In this (and the one below) script I've hardcoded <Y>600</Y> values, so you may need to change it if you have less tall screen.

Greetings!
Last edited by SFR on Mon 24 Dec 2012, 02:41, edited 1 time in total.
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#10 Post by SFR »

I've been playing with this and couldn't resist. :lol:

Just for fun:

Code: Select all

#! /bin/bash

# ==================
# BOUNCING RXVT ICON
# ==================

# For best results make sure that 'ROX Options -> Pinboard -> Icon grid step' is set to 'Fine'

[ ! -f /usr/bin/rxvt ] && exit 1

# Create sinus table
PI=`echo "4*a(1)" | bc -l`
for i in {0..31}; do
  RAD=`echo "$i*($PI/32)" | bc -l`
  VAL=`echo "s($RAD) * 150 + 32" | bc -l`
  SIN[$i]=${VAL/.*}
  echo ${SIN[$i]}
done

# Bounce 3 times and exit
for j in {1..3}; do

for i in `seq 0 2 31`; do
  
echo "<?xml version=\"1.0\"?>
<env:Envelope xmlns:env=\"http://www.w3.org/2001/12/soap-envelope\">
 <env:Body xmlns=\"http://rox.sourceforge.net/SOAP/ROX-Filer\">
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>${SIN[$i]}</X><Y>600</Y>
    <Label> </Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardRemove><Path>/usr/bin/rxvt</Path>
    <Label>  </Label>
  </PinboardRemove>
</env:Body></env:Envelope>" | rox -R
  
echo "<?xml version=\"1.0\"?>
<env:Envelope xmlns:env=\"http://www.w3.org/2001/12/soap-envelope\">
 <env:Body xmlns=\"http://rox.sourceforge.net/SOAP/ROX-Filer\">
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>${SIN[$(($i+1))]}</X><Y>600</Y>
    <Label>  </Label>
  </PinboardAdd>
  <PinboardRemove><Path>/usr/bin/rxvt</Path>
    <Label> </Label>
  </PinboardRemove>
</env:Body></env:Envelope>" | rox -R

done

done
PS. And it's still clickable! :wink:

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#11 Post by der-schutzhund »

SFR wrote:Hmm, I just tried and ROX's SOAP RPC mechanism accepts multiple <Pinboard...> tags at once.
Check out display time of the following one. ;)

Code: Select all

#! /bin/bash

echo "<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*1))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*2))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*3))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*4))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*5))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*6))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*7))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*8))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*9))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
  <PinboardAdd><Path>/usr/bin/rxvt</Path><X>$((64*10))</X><Y>600</Y>
    <Label>RXVT</Label><Args>+sb</Args>
  </PinboardAdd>
</env:Body></env:Envelope>" | rox -R
EDIT: In this (and the one below) script I've hardcoded <Y>600</Y> values, so you may need to change it if you have less tall screen.

Greetings!
Hey SFR,

i have not tested yet but that this approach i would have also tried next!
Did you get your Christmas gifts yet? :)

EDIT: absolutely awesome! The scripts are great!

Greetings!

Wolfgang

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#12 Post by SFR »

I'm glad it works fine for you. :)

Merry X-mas &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#13 Post by der-schutzhund »

SFR wrote:I'm glad it works fine for you. :)

Merry X-mas &
Greetings!
Hey SFR,

the new graphical menu system is ready and works fine!

What I now missing is a small info window that displays a text.
The window should not contain any buttons.
It should be able to be generated by a script, and cleared again.
In this window, I will show you the active program group.
I have already experimented with xdialog.
Since bothers me but the title and I can not delete can also by a script.
Do you have an idea?

Greetings!

Wolfgang

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#14 Post by SFR »

Hey Wolfgang

You mean something like this, to display undecorated window with text?

Code: Select all

#! /bin/bash

# decorated="false" - no window decorations
# skip_taskbar_hint="true" - no script name on the taskbar (thanks to Puppylvr ;)
export MAIN='
<window decorated="false" skip_taskbar_hint="true">
  <text use-markup="true"><label>"<b><span color='"'blue'"' size='"'xx-large'"'><u>Some message...</u></span></b>"</label></text>
</window>
'

# -G <width>x<height>+<X_position>+<Y_position>
gtkdialog -G 256x48+400+400 -p MAIN & WINDOW_PID=$!

sleep 5

kill $WINDOW_PID	# kill window
BTW, did you see Zigbert's modified gtkdialog-splash?
http://www.murga-linux.com/puppy/viewto ... 564#626564
You could customize it to your needs, too.

Also, urxvt gives a lot of possibilities; here's example. :wink:

Code: Select all

#!/bin/bash 
tail -n +4 $0  > /tmp/scroller_temp.txt 
exec urxvt -foreground 7 -transparent -borderLess +sb -g 40x1+0+0 -fn 'xft:DejaVu Sans Mono-18:bold:dpi=76' -e bash /tmp/scroller_temp.txt 
# -g <width>x<height>+<X_position>+<Y_position>

MESSAGE="Hello Wolfgang!" 
MESSAGE="                                        "$MESSAGE

LEN=${#MESSAGE} 
POS=0 

# Main scroll function 

echo -ne "\033[?25l" # disable cursor

for i in `seq 0 $LEN`; do
  TEXT=${MESSAGE:$POS:40}
  ((POS++))
  [ $POS = $LEN ] && POS=0
  echo
  echo -n "$TEXT"
  sleep 0.2
done
Good luck &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#15 Post by der-schutzhund »

Hey SFR,

the problem is not the making of the info window but later delete!
The info window is created when a new program group appears as "office." Then you work with open office, etc. At some point changes as you for image processing and then erased in the first window.
Then a new info window will be taken "imaging" and so on.
The window must have a unique address such as a button!

Greetings.

Wolfgang

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#16 Post by SFR »

Not sure if I understand...

To destroy a window you can use the technique from my previous post:
gtkdialog -G 256x48+400+400 -p MAIN & WINDOW_PID=$!
sleep 5
kill $WINDOW_PID # kill window
Of course instead of 'sleep 5' you need to put a condition, like:

Code: Select all

if [ something ]; then
  kill $WINDOW_PID
fi
But if this info window is supposed to be placed on fixed position, it's better to only change its contents, like in this:

Code: Select all

#! /bin/bash

touch /tmp/temp_text.txt
echo "initial msg" > /tmp/temp_text.txt

export MAIN='
<window width-request="300">
  <text><variable>MESSAGE</variable><input file>/tmp/temp_text.txt</input></text>
  <timer interval="1" visible="false">
    <action>refresh:MESSAGE</action>
  </timer>
</window>
'

gtkdialog -p MAIN
(When you run this script, just modify contents of /tmp/temp_text.txt file and the change in the window will be visible after max. 1 second.)

But like I said, I'm not sure if I fully understand your design plan. ;)

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#17 Post by der-schutzhund »

Hey,

i have made 2 scripts like:
This script to make the Infowindow:

Code: Select all

#! /bin/bash

# decorated="false" - no window decorations
# skip_taskbar_hint="true" - no script name on the taskbar (thanks to Puppylvr ;)
export MAIN='
<window decorated="false" skip_taskbar_hint="true">
  <text use-markup="true"><label>"<b><span color='"'blue'"' size='"'xx-large'"'><u>Some message...</u></span></b>"</label></text>
</window>
'

# -G <width>x<height>+<X_position>+<Y_position>
gtkdialog -G 256x48+400+400 -p MAIN & WINDOW_PID=$!
And a script to clear the Infowindow:

Code: Select all

#! /bin/bash

kill $WINDOW_PID   # kill window
Then I have used the first script that generates info window, and later with the second script tries again to delete.
Sometimes I could not delete the window anymore.
That's the problem!

Greetings!

Wolfgang

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#18 Post by SFR »

The problem is that the second script can't read the real $WINDOW_PID value, as it is complete different process that has no access to another processes' data.

But the workaround is simple, it's enough to use a temporary file.

First script:

Code: Select all

#! /bin/bash 

# decorated="false" - no window decorations 
# skip_taskbar_hint="true" - no script name on the taskbar (thanks to Puppylvr ;) 
export MAIN=' 
<window decorated="false" skip_taskbar_hint="true"> 
   <text use-markup="true"><label>"<b><span color='"'blue'"' size='"'xx-large'"'><u>Some message...</u></span></b>"</label></text>
</window> 
 ' 

# -G <width>x<height>+<X_position>+<Y_position> 
gtkdialog -G 256x48+400+400 -p MAIN & WINDOW_PID=$!
echo $WINDOW_PID > /tmp/temp_PID
Second script:

Code: Select all

#! /bin/bash 
[ -f /tmp/temp_PID ] && WINDOW_PID=`cat /tmp/temp_PID` || exit
rm -f /tmp/temp_PID # remove temp file, if already used
kill $WINDOW_PID   # kill window
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

der-schutzhund
Posts: 1045
Joined: Mon 26 Nov 2007, 22:07
Location: Blomberg / Germany

#19 Post by der-schutzhund »

Absolutely brilliant!
Thank you so much!
Where do you live and what you do professionally?

Greetings!

Wolfgang

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#20 Post by SFR »

der-schutzhund wrote:Absolutely brilliant!
Thank you so much!
Where do you live and what you do professionally?

Greetings!

Wolfgang
You're welcome. :)
We're neighbours actually - the next country eastward.
Currently I'm happily unemployed yet (I truly hated my last job), that's why I have some more time to tinker with Puppy, but have no profession as such; general high school.
Everything (useful) that I know, I've learned by myself...

Cheers from PL &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

Post Reply