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

#21 Post by der-schutzhund »

Hey SFR,

Code: Select all

# -G <width>x<height>+<X_position>+<Y_position>
gtkdialog -G 256x24+500+600 -p MAIN & WINDOW_PID=$!
How can i place the Window at X-center and for example 50 from max Y?

Greetings

Wolfgang

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

#22 Post by SFR »

Hey, usually I'm doing it this way:

Code: Select all

#! /bin/bash

# Determine current screen resolution
RES=$(xrandr | grep "current" | awk '{print$8"x"$10}' | tr -d ',')
[ "`echo "$RES" | tr -cd '[[:digit:]]'`" = "" ] && RES=$(xrandr | grep "*" | awk '{print$2"x"$4}')	# XVesa has different ouput IIRC(?)
MAXX=$(echo $RES | cut -f1 -d 'x')
MAXY=$(echo $RES | cut -f2 -d 'x')

WIDTH=200	# Window width
HEIGHT=40	# Window height

X=$(( ($MAXX/2) - ($WIDTH/2) ))		# Center horizontally
Y=$(( $MAXY-$HEIGHT-50 ))			# 50px above bottom of the screen

export MAIN='
<window>
  <text><label>Some text blah blah blah...</label></text>
</window>
'

gtkdialog -G "$WIDTH"x"$HEIGHT"+"$X"+"$Y" -p MAIN
BTW, the max. width and height of the screen can be also determined using xwininfo:

Code: Select all

MAXX=`xwininfo -root | grep Width | awk '{print $2}'`
MAXY=`xwininfo -root | grep Height | awk '{print $2}'`
Use what suits you better.

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

#23 Post by der-schutzhund »

Hey,

and what happens when you work with Xvesa and how an error can be avoided?

Greetings!

Wolfgang

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

#24 Post by SFR »

and what happens when you work with Xvesa and how an error can be avoided?
This line already doing it:

Code: Select all

[ "`echo "$RES" | tr -cd '[[:digit:]]'`" = "" ] && RES=$(xrandr | grep "*" | awk '{print$2"x"$4}')   # XVesa has different ouput IIRC(?)
(desc.: if the first readout, stripped of non-digits, is empty - use alternative method to read resolution)

I can't verify it at the moment, but the above code worked fine in Akita with XVesa.

But maybe actually it's better to use xwininfo; should be more resistant to such factors...

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

#25 Post by der-schutzhund »

ok!
Then I have two small questions:
1. When I run a script in the first erase routine to delete the last window and then the routine to create a new window, then nothing is displayed.

2. How can I use the text to be displayed variable?

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
.
.
my programcode
.
.
----------------------------------------------------------- 
RES=$(xrandr | grep "current" | awk '{print$8"x"$10}' | tr -d ',')
----------------------------------------------------------- 
[ "`echo "$RES" | tr -cd '[[:digit:]]'`" = "" ] && RES=$(xrandr | grep "*" | awk '{print$2"x"$4}')
----------------------------------------------------------- 
MAXX=$(echo $RES | cut -f1 -d 'x')
MAXY=$(echo $RES | cut -f2 -d 'x')
----------------------------------------------------------- 
WIDTH=300
HEIGHT=24
----------------------------------------------------------- 
X=$(( ($MAXX/2) - ($WIDTH/2) ))
Y=$(( $MAXY-$HEIGHT-130 ))
export MAIN='
<window decorated="false" skip_taskbar_hint="true">
   <text use-markup="true"><label>"<b><span color='"'black'"' size='"'large'"'><u>Some message...</u></span></b>"</label></text>
</window>
'
gtkdialog -G "$WIDTH"x"$HEIGHT"+"$X"+"$Y" -p MAIN & WINDOW_PID=$!
echo $WINDOW_PID > /tmp/temp_PID

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

#26 Post by SFR »

Since scripts have been merged again, everything ends at the first line because of 'exit' - simply, it cannot find /tmp/temp_PID file.

This one should be ok and additionally, if you'd like to have it that way, 'WITDH' is being (approximately) calculated from the text lenght.
But if you change font size, you have to adjust it again...

Usage:
script_name "Some text..."
script_name "Some different text..."
or
script_name
without arguments to close the window completely.

Code: Select all

#! /bin/bash 

TEMPFILE=/tmp/infowindow_temp_PID
[ -f $TEMPFILE ] && WINDOW_PID=`cat $TEMPFILE` && kill $WINDOW_PID && rm -f $TEMPFILE

#. 
#. 
#my programcode 
#. 
#.

MESSAGE="$1"	# first passed parameter is a message
[ "$MESSAGE" = "" ] && exit	# if no parameter - exit

#----------------------------------------------------------- 
RES=$(xrandr | grep "current" | awk '{print$8"x"$10}' | tr -d ',') 
#----------------------------------------------------------- 
[ "`echo "$RES" | tr -cd '[[:digit:]]'`" = "" ] && RES=$(xrandr | grep "*" | awk '{print$2"x"$4}') 
#----------------------------------------------------------- 
MAXX=$(echo $RES | cut -f1 -d 'x')
MAXY=$(echo $RES | cut -f2 -d 'x')
#----------------------------------------------------------- 
WIDTH=$(( (${#MESSAGE}+1) *12))		# WIDTH = ((lenght of text + 1) * 12)
HEIGHT=24
#----------------------------------------------------------- 
X=$(( ($MAXX/2) - ($WIDTH/2) )) 
Y=$(( $MAXY-$HEIGHT-130 )) 
export MAIN=' 
<window decorated="false" skip_taskbar_hint="true"> 
   <text use-markup="true"><label>"<b><span color='"'black'"' size='"'large'"'><u>'$MESSAGE'</u></span></b>"</label></text> 
</window> 
' 
gtkdialog -G "$WIDTH"x"$HEIGHT"+"$X"+"$Y" -p MAIN & WINDOW_PID=$! 
echo $WINDOW_PID > $TEMPFILE
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

#27 Post by der-schutzhund »

Hey SFR,

here you can see the result: http://murga-linux.com/puppy/viewtopic. ... 090#674090

My be you can use it.

Greetings!

Wolfgang

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

#28 Post by SFR »

Hey Wolfgang.

Although I was able to use v1.0 from command line and create/enable/disable different groups, but I tried to download a couple of times v1.1 and it seems that this is the same version - can't see any difference...
Could you check if variomen_1_1.pet contains new scripts for sure?

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

#29 Post by der-schutzhund »

Hey,

you are right! Sorry! Now you can download the 1.1!

Greetings!

Wolfgang

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

#30 Post by SFR »

Thanks, now it's fine!

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