You are not logged in.

#21 2015-10-12 12:32:05

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,030

Re: Movable conkys

AWESOME damo ... but what's the [c] for in:

ps aux | grep [c]conky

it doesn't work here.

Also for this to work, people will need to be informed of using a unique "own_window_title" for each conky.  A lot of people just don't bother with that.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#22 2015-10-12 13:02:17

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 1,057

Re: Movable conkys

Yeah, that's why I am reconsidering the importance of setting that stuff up. You could give the window a UUID or GUID title, for instance, and likely have a unique title per conky. The main problem would be that it is nearly impossible to guarantee uniqueness based on something requiring user input.

So here's another thought:
A script that iterates through the list of conkies it can find in some arbitrary directory path such as $HOME, opens the conkies one at a time, then sets own_window_title equal to some unique number.

I find it hard to envision how to set this up without massaging the data somehow since, as it stands atm, we do very little to guarantee the uniqueness of each conky. Without that guarantee, you could almost expect problems to crop up with the script in some use cases.

Last edited by tknomanzr (2015-10-12 13:02:34)

Offline

#23 2015-10-12 13:24:12

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,030

Re: Movable conkys

Regarding damos 1, 2, 3 list above if "own_window_title" matched the conky name to start the conky:

conky -q -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin
own_window_title conkyrc_1b2_int_s11_thin

Only one step required:

 12 Oct 15 | 10:03:20 ~
    $ xwininfo -name "conkyrc_1b2_int_s11_thin"

xwininfo: Window id: 0x3400002 "conkyrc_1b2_int_s11_thin"

  Absolute upper-left X:  3
  Absolute upper-left Y:  3
  Relative upper-left X:  0
  Relative upper-left Y:  0
 {snip}
    $ 

But there's an ???? because in "conkyrc_1b2_int_s11_thin" I have:

gap_x 10	# l|r
gap_y 10	# u|d

not 3 & 3


Also ... I set

gap_x 125	# l|r
gap_y 20	# u|d

and get:

  Absolute upper-left X:  118
  Absolute upper-left Y:  13

Now those setting are "7" off so I'm thinking border_margins - the first two (above) use:

border_inner_margin 5
border_outer_margin 0

Hmmmm not the "7" I wanted so I changed borders to this to:

border_inner_margin 25
border_outer_margin 15

... still using gap_x 125 & gap_y 20 ... now I get:

  Absolute upper-left X:  83
  Absolute upper-left Y:  -22

I guess this throws a curve ball out there.  sad

Or am I missing something?


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#24 2015-10-12 13:29:51

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Movable conkys

Sector11 wrote:

AWESOME damo ... but what's the [c] for in:

ps aux | grep [c]conky

It greps for conky, but excludes the grep process itself. You can see the difference by counting: here is a typical ConkyMod output...

[sector11@bl ~]$ ps aux | grep conky | wc -l
56

[sector11@bl ~]$ ps aux | grep [c]onky | wc -l
55

]:D

BTW the xprop/xwininfo geometry doesn't include window borders, which makes this whole process a PITA (thats is one of the bugs in cb-aerosnap BTW)

Last edited by damo (2015-10-12 13:32:25)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#25 2015-10-12 23:11:20

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Movable conkys

I've found 2 commands to get info about a conky:

[damo@cb1-laptop ~]$ ID=$(xdotool search --class "Conky")
[damo@cb1-laptop ~]$ xwininfo -int -id $ID

xwininfo: Window id: 41943041 "Conky (cb1-laptop)"

  Absolute upper-left X:  29
  Absolute upper-left Y:  11
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 211
  Height: 367
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +29+11  -1126+11  -1126-390  +29-390
  -geometry 211x367+29+11

Further exploration commences....


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#26 2015-10-13 01:59:06

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,666
Website

Re: Movable conkys

You all actually read the code I mosted in #1 right? Most of this work is already done! smile

'wmctrl -lG' gives all the info we need about all open windows (same as going xdotool > xwininfo I guess), so we just have to pick out the Conkys, again, like Damo, using the title - this time just searching for a generic 'conky':

johnraff wrote:
#get id and geometry of conky windows
while read id desktop xoffset yoffset width height client title
do
	[[ $title = Conky* ]] || continue 
	echo "id: $id
x-offset: $xoffset
y-offset: $yoffset
width: $width
height: $height" # in practice we'll do stuff with these variables
done < <(wmctrl -lG)

( '[[ $title = Conky* ]]' needs changing to ' [[ $title = *[Cc]onky* ]]' so that it picks up any title with conky in it, upper or lower case.)
The only thing missing here is the path to the config file. That is available from xprop. Now we've got the X id for each conky we can ask xprop for WM_COMMAND and use awk to extract the section which follows -c:

johnraff wrote:
cfg=$(xprop -id $id  WM_COMMAND | awk -F '"' '{for (i=1;i<=NF;i++)if($i=="-c"){i=i+2;print $i}}')

I've tested this. It still remains to cover cases where the user wrote --config or --config= but that shouldn't be hard. I also still have to make sure quoting works OK when eg folder names have quotes or spaces in them.

Damo's alternative idea to get the command line from ps & co, extract the custom title from the config file and use that to access the info is interesting, and it's certainly easier to get the command line that way than from xprop because of the funky way xprop formats the output:

WM_COMMAND(STRING) = { "conky", "-c", "/home/john/text/oddnames/\"new folder\"/conkyrc-caption" }

But as Sector11 pointed out using the title to get the info depends on the user co-operating.

New awk to cope with quotes in path:

~$wmctrl -l
...
0x02400002 -1 raffles4 Conky test
...
~$xprop -id 0x02400002  WM_COMMAND | awk -F '", "' '{for (i=1;i<=NF;i++)if($i=="-c"){i++;sub(/\" }$/,"",$i);gsub(/\\\"/,"\"",$i);print $i}}'
/home/john/text/oddnames/\"new folder\"/conkyrc-caption

We also need to weed out text editors which might be opening a conky file and have conky in their title, so want to know the initial command too:

 xprop -id 0x02400002  WM_COMMAND | awk -F '", "' '{cmd=$1;sub(/^.*{ "/,"",cmd);for (i=1;i<=NF;i++)if($i=="-c"){i++;sub(/\" }$/,"",$i);gsub(/\\\"/,"\"",$i);print cmd,$i;exit}}'
conky /home/john/text/oddnames/\"new folder\"/conkyrc-caption

Then the path to the config file can be checked if it's absolute or relative. It's only the relative paths which would mess us up, but people hardly ever use them in this case I'd say.

This was the major hurdle, but it really will only hit us in a tiny minority of cases. If ithe path to the config file turns out to be relative then we need to know the working directory (in order to get the absolute path of the config file). That requires the PID ('readlink -e /proc/$PID/cwd'). The only way I thought of to find this particular window's pid was to compare the config file path extracted from ps (Damo's method) with that from xprop (my method above). If the paths are the same then we can guess they're the same process. That still allows cases like './conkyrc' to cause false matches but they must be very few... surely? We'd have 99.9% covered this way, and since we're not talking about erasing system libraries or anything that might be good enough.

------------------------

Next step: calculating what needs to be written into the config file.
Sector11 has found a 7px difference between what the file sets and what the x apps report. I found 5px.

damo wrote:

BTW the xprop/xwininfo geometry doesn't include window borders

Do conky windows have borders?
Is there any way you've found to date to get the border width of a window?
OTOH are we going to have to read the border settings from the conky file and find a way to add them to the calculation?

Last edited by johnraff (2015-10-23 09:16:28)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#27 2015-10-13 02:42:22

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Movable conkys

johnraff wrote:

...big snip...

Next step: calculating what needs to be written into the config file.
Sector11 has found a 7px difference between what the file sets and what the x apps report. I found 5px.

damo wrote:

BTW the xprop/xwininfo geometry doesn't include window borders

Do conky windows have borders?
Is there any way you've found to date to get the border width of a window?
OTOH are we going to have to read the border settings from the conky file and find a way to add them to the calculation?

I have been experimenting, and can't quite get my head around what conky is doing. There is a discrepancy between the edge of the conky background and the outer edge of the border, of 1px:

gap_x 5
border_width 0  --->

Absolute upper-left X:    0
Width:     211

But adding a margin value of zero gives:

gap_x 5
border_width 0 
border_outer_margin 0  --->

Absolute upper-left X:    1
Width:     209

But adding an inner margin of zero confuses things even more..

gap_x 5
border_width 0 
border_outer_margin 0  
border_inner_margin 0 --->

Absolute upper-left X:    4
Width:     203

And with a border...

gap_x 5
border_width 10  --->

Absolute upper-left X:    -9
Width:     229

Regarding window borders, you can get the WM border values from _NET_FRAME_EXTENTS. So for example, an OB theme with 1px borders and a 24px titlebar (that depends on fontsize btw), has Frame Extents of 1,1,24,1. This needs to be added to the window geometry given by xprop/xwininfo to work out screen positioning (which is one reason cb-aerosnap is buggy)......but Conky doesn't provide that window information.

I think that for pinning conkys which have been manually positioned, a few px here or there won't make much difference generally. Maybe get the basic pinning working, and nail down the exact positioning later if we can't find an accurate way to do it now.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#28 2015-10-13 02:59:55

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,666
Website

Re: Movable conkys

^I was just going to throw in a +5px for conky's file till S11 reported 7px, and you got all this stuff with borders and margins.

Agreed, let's just put in a OFFSET=6px at the top of the script and think about it later.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#29 2015-10-13 06:46:00

pvsage
Internal Affairs
Registered: 2015-09-29
Posts: 1,433

Re: Movable conkys

damo wrote:

I've found 2 commands to get info about a conky:

[damo@cb1-laptop ~]$ ID=$(xdotool search --class "Conky")
[damo@cb1-laptop ~]$ xwininfo -int -id $ID

That can easily be folded into a single line:

xwininfo -int -id `xdotool search --class "Conky"`

(I don't like having to rely on $variables at the command line.  Within a script they're good, but I don't feel comfortable with them outside a script except for global variables like $PATH.)


Be excellent to each other, and...party on, dudes!
BunsenLabs Forum Rules
Tending and defending the Flame since 2009

Offline

#30 2015-10-13 13:50:21

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Movable conkys

^ It was just as a proof-of-concept!

In a script I would use a var, or

xwininfo -int -id $(xdotool search --class "Conky")

I've never really got to the bottom of why backticks are so often discouraged. Is the following any different in practice from the first one?

xwininfo -int -id `xdotool search --class "Conky"

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#31 2015-10-13 14:08:07

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Movable conkys

See this link

Offline

#32 2015-10-13 15:27:36

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Movable conkys

^ TY

That is the most readable and understandable link I've seen smile


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#33 2015-10-13 16:11:49

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,030

Re: Movable conkys

johnraff wrote:

I'm suggesting (for now) for the script to edit the config file itself. It would probably be best to keep the original entries though, commented-out.

Yea, that sounds like a workable option.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#34 2015-10-13 19:48:49

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Movable conkys

Simple command to extract the full conky command

xprop -id $ID  WM_COMMAND | grep -o '".*"' | sed 's/["|,]//g'

Get full commands used to start all running conkys with

wmctrl -l | grep Conky | while read line;do
        ID=${line%%" "*}
        CMD=$(xprop -id $ID  WM_COMMAND | grep -o '".*"' | sed 's/["|,]//g') 
        ---> Do stuff with $CMD
    done

I've put it here to remind myself, because it may be useful in other scenarios as well wink

---------------------

Even simpler command to get the conky command  8o

pgrep -a conky | cut -d ' ' -f2- 

Last edited by damo (2015-10-14 01:16:31)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#35 2015-10-13 20:21:17

pvsage
Internal Affairs
Registered: 2015-09-29
Posts: 1,433

Re: Movable conkys

@damo & @xaos52:  Thank you; I didn't realize backticks are considered obsolete.  Learned something new.

Back to movable conkys.


Be excellent to each other, and...party on, dudes!
BunsenLabs Forum Rules
Tending and defending the Flame since 2009

Offline

#36 2015-10-14 08:49:08

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,666
Website

Re: Movable conkys

damo wrote:

Simple command to extract the full conky command

xprop -id $ID  WM_COMMAND | grep -o '".*"' | sed 's/["|,]//g'

Nice and simple, but if the command line contains any double quotes they will be removed.
I still recommend the awk line (in this case, just to get the first word in the command, then the bit after -c )

xprop -id $ID WM_COMMAND | awk -F '", "' '{cmd=$1;sub(/^.*{ "/,"",cmd);for (i=1;i<=NF;i++)if($i=="-c"){i++;sub(/\" }$/,"",$i);gsub(/\\\"/,"\"",$i);print cmd,$i;exit}}'

This also saves the trouble of parsing out the file path as a separate operation, and is independent of its position in the line (ie if -q comes after).

Get full commands used to start all running conkys with

wmctrl -l | grep Conky | while read line;do
        ID=${line%%" "*}
        CMD=$(xprop -id $ID  WM_COMMAND | grep -o '".*"' | sed 's/["|,]//g') 
        ---> Do stuff with $CMD
    done

Save that grep call with this first line in the do loop

[[ $line = *Conky* ]] || continue

Another possibly useful tweak might be to avoid the subshell that the pipe (|) creates by sending the output of wmctrl by process substitution at the bottom, ie

while read line;do
        [[ $line = *Conky* ]] || continue
        ID=${line%% *}
        CMD=$(xprop -id $ID  WM_COMMAND | grep -o '".*"' | sed 's/["|,]//g') 
        ---> Do stuff with $CMD
    done < <(wmctrl -l)

The (possible) advantage of doing that is that any variables created inside the loop remain accessible afterwards. Of course you might not want that at all...

edit: don't need to quote the space in 'ID=${line%% *}'

Last edited by johnraff (2015-10-23 09:15:05)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#37 2015-10-14 08:55:01

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,666
Website

Re: Movable conkys

Thinking about all the trouble with margins, borders etc - one way out might be to use a differential approach, ie get all the x & y positions of the windows before moving them, and then see what's changed and apply that difference to the values in the conf file. This would mean having an extra item in the menu. The user clicks "record conky positions" or something, moves the windows they want, then clicks "pin conkys". Messier, but perhaps easier to implement?

Last edited by johnraff (2015-10-14 08:55:59)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#38 2015-10-14 18:08:49

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,030

Re: Movable conkys

"moveable conkys" have been around forever.  And I've been using them on my system almost as soon as I discovered I could move them.   It's nice that "maybe" they can be move and locked into place, but the idea is (for me) to have them moveable to match wallpapers as the walls change.

If someone only changes wallpapers once a week, it's just as easy to edit the conky and change the gap_x and gap_y values.
My wife and I have a 'change the wallpaper war' going on, so [Ctrl][Alt]+Lclick is the best option.  wink


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#39 2015-10-16 02:56:32

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,666
Website

Re: Movable conkys

[Alt]+click, no?

Of course if everyone's OK with editing their config files frequently, there's no need for any of the conky/tint2 automation...


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#40 2015-10-16 03:50:28

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,030

Re: Movable conkys

Yes, [Alt] my mistake.   :8

And [Alt]+Rclick to resize it too!


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

Board footer

Powered by FluxBB