Bash & GtkDialog

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

Bash & GtkDialog

#1 Post by RSH »

Hi.

I want to open a program (Bash/GtkDialog) at specific screen position. This position is different in different screen resolutions/sizes because it is depending on an icon in the fbpanel taskbar.

How can i get current screen size/resolution and how do i convert this into a gtkdialog position?

Thanks

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

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#2 Post by 01micko »

An example here
Puppy Linux Blog - contact me for access

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#3 Post by don570 »

Make sure you use <window resizable="false">
to avoid empty space

_______________________________________________


Zigbert wrote in his tutorial

Code: Select all

N.B. some properties are enumerated and can be replaced by integer values e.g in a window widget window-position=\"1\" means centre the window and window-position=\"2\" means follow cursor. A tip is when reading the documentation a tooltip indicates the property type 
Also note that widgets have hierarchy and inherit from them 
If you can read French here's some useful advice on windows

window_position="1" and window_position="2"
can be useful

Code: Select all

GtkWindow
Icône de la fenêtre :
<window icon-name="gtk-info">
Titre de la fenêtre :
<window title="Titre">
Fenêtre impossible à redimensionner :
<window resizable="false">
Retirer le contour de la fenêtre :
<window decorated="false">
Cacher la fenêtre de la barre des taches :
<window skip_taskbar_hint="true">
Position de la fenêtre :
<window window_position="XXX">
1 : placer la fenêtre au centre de l'écran;
2 : la fenêtre se placera automatiquement à la position actuelle de la souris;
3 : garder la fenêtre centrée même après redimensionnement.
Exemple final :
<window window_position="1" resizable="false" title="Joli titre" skip_taskbar_hint="true">
<text>
<label>
"Voici une fenêtre non modifiable,
avec un joli titre
qui apparaît au centre de l`écran
et qui n`apparait pas dans la barre des taches."
</label>
</text>
</window>
Retour au Sommaire
Fenêtre pop-up au survol de texte :
#! /bin/bash
#window_position="2"
export POPUP='<window window_position="2" decorated="false">
<vbox>
<text>
<input>cat /tmp/msgaafficher</input>
</text>
</vbox>
</window>'
export MAITRE='<window title="Test survol" icon-name="gtk-info">
<vbox>
<text>
<input>echo "Vouep bon c'\''est pas encore top\nmais bon...\navec 2 dans
window_position est mieux,\nmais a mon avis ogligé de passer par include file pour fonction qui masque
message...\n\na faire évoluer."</input>
</text>
<button>
<label>Essai de survol</label>
<action signal="enter-notify-event">echo "Texte à\nafficher" | tee
/tmp/msgaafficher && sleep 1 && gtkdialog --program=POPUP&</action>
<action signal="leave-notify-event">sleep 2 && kill $(ps ax | grep "gtkdialog
--program=POPUP" | awk '\''{print $1}'\'' | grep -v grep | xargs)&</action>
<action>kill $(ps ax | grep "gtkdialog --program=POPUP" | awk '\''{print $1}'\'' |
grep -v grep | xargs)</action>
<action type="exit">exit</action>
</button>
</vbox>
<action signal="show">echo "" | tee /tmp/msgaafficher</action>
<action signal="hide">echo "" | tee /tmp/msgaafficher</action>
</window>'
gtkdialog --program=MAITRE
exit 0

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

#4 Post by SFR »

Here's another example of determining current screen resolution (using xrandr) and adjusting position of the GtkDialog window.
http://www.murga-linux.com/puppy/viewto ... 172#602172

BTW, you said:
This position is different in different screen resolutions/sizes because it is depending on an icon in the fbpanel taskbar.
In this case you might consider the use of xdotool:

Code: Select all

xdotool getmouselocation
will return the current X/Y position, and thanks to this you'll be able to open a new window in exact cursor position, or (in other words) above the mentioned icon, when clicked.

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]

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

#5 Post by RSH »

don570 wrote:Zigbert wrote in his tutorial

Code: Select all

N.B. some properties are enumerated and can be replaced by integer values e.g in a window widget window-position="1" means centre the window and window-position="2" means follow cursor. A tip is when reading the documentation a tooltip indicates the property type 
Also note that widgets have hierarchy and inherit from them 
Currently this one seems to be the easiest way for me to do.
SFR wrote:BTW, you said:
This position is different in different screen resolutions/sizes because it is depending on an icon in the fbpanel taskbar.
In this case you might consider the use of xdotool:

Code: Select all

xdotool getmouselocation
will return the current X/Y position, and thanks to this you'll be able to open a new window in exact cursor position, or (in other words) above the mentioned icon, when clicked.
This might be useful also, because LazY Puppy has already built in the xdotool.

But: how do i get the results of xdotool in a $xpos and $ypos variable?

To set the result of xdotool as positions of a gtkdialog application i can not use the automatically generated console output of xdotool.
[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]

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

#6 Post by SFR »

RSH wrote:This might be useful also, because LazY Puppy has already built in the xdotool.

But: how do i get the results of xdotool in a $xpos and $ypos variable?

To set the result of xdotool as positions of a gtkdialog application i can not use the automatically generated console output of xdotool.
Like that, I suppose:

Code: Select all

#!/bin/bash

LOCATION=`xdotool getmouselocation`
Xpos=`echo $LOCATION | cut -f2 -d ':' | cut -f1 -d ' '`
Ypos=`echo $LOCATION | cut -f3 -d ':' | cut -f1 -d ' '`
echo $Xpos   # just for testing
echo $Ypos   # just for testing
BTW, It's cool that you have put xdotool in LazY; it should be out-of-the-box in every Puppy IMHO :D

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]

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

#7 Post by technosaurus »

gtkdialog can set geometry

Code: Select all

gtkdialog
-G, --geometry=[XxY][+W+H]      The placement and the size of the window.
to get a quick cursor position

Code: Select all

read X Y <<< $(getcurpos)
then do whatever magic calculations you want for $X and $Y (awk works well)
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].

Post Reply