You are not logged in.

#1 2015-10-11 08:37:09

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

Movable conkys

It came up a while ago that you can move any window, including conkies, with an Alt-drag, but the window (of course) comes back to its default position after a logout/in.

Since none of the Conkystadores chimed in with a fix, I assumed there wasn't one, but thinking suggests it might be possible to make a "fix_conkys" script which a user could run to read the new window positions and edit the config files accordingly.

There are some hurdles to be passed, but before I scratch my head over this any more (when I should have been doing more important things) I thought I'd throw some code in here in case anyone else can suggest stuff.

Get basic info on each conky with wmctrl. This while loop will probably hold the whole script:

#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)

With the X id we can use xprop to find out the launching command for a particular conky, and so pin down the config file - it's the next argument after '-c':

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

Knowing where the file is, we can put all the config values in an array:

parse_conkyfile()
{
    [[ -f $1 ]] || { echo "$1 is not a file." >&2;return 1;}
    unset config
    declare -Ag config
    local name value
    while read name value
    do
        [[ $name ]] || continue
        [[ $name = TEXT* ]] && break
        config["$name"]="$value"
    done < <(sed 's/\#.*$//' "$1")
}
parsecfg "$cfg"

Now we can do eg ${config[gap_x]} to read what's in the file.

Hurdle: if the conky is not launched from $HOME then we'll need the PWD to find the config file.
It's possible to get the working directory of a process, if you've got its PID:

readlink -e /proc/$PID/cwd

But going from X window ID to PID is very difficult with conky. (Anyone?)
For now, let's just skip that issue.

What remains is to compare eg $xoffset with ${config[gap_x]} to calculate if and by how much the x and y settings have changed (not hard) and write the new figures into the config file (likewise).

Last edited by johnraff (2015-10-17 08:51:23)


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

#2 2015-10-11 11:42:37

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

Re: Movable conkys

This was something I was going to get round to next, so thanks for getting the ball rolling 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

#3 2015-10-11 12:12:14

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

Re: Movable conkys

Well, this conkystador doesn't mix well with "scripts" I can tweak them a bit, but creating them isn't my thing.

But you may be onto something.  Conky has quite a few CLI switches - two of which are:

-x X_COORDINATE
    X position

-y Y_COORDINATE
    Y position 

Using the individual conky killer line, by Grouchy Gaijin, with the -x -y addition and commenting them out in the conky you have a way to start/stop individual conkys and of course I'm sure you can manipulate those lines.  It also gives you the ability to have the conkys anywhere - mine are on a different partition even:

 11 Oct 15 | 08:57:51 ~
    $ conky -q -x 10 -y 10 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin &
[1] 13736
 
 11 Oct 15 | 08:58:17 ~
    $ pkill -xf "conky -q -x 10 -y 10 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin" &
[2] 14069
[1]   Done                    conky -q -x 10 -y 10 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin
[2]+  Done                    pkill -xf "conky -q -x 10 -y 10 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin"
 
 11 Oct 15 | 08:58:32 ~
    $ conky -q -x 60 -y 60 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin &
[1] 14116
 
 11 Oct 15 | 08:58:53 ~
    $ pkill -xf "conky -q -x 60 -y 60 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin" &
[2] 14546
[1]   Done                    conky -q -x 60 -y 60 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin
[2]+  Done                    pkill -xf "conky -q -x 60 -y 60 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin"
 
 11 Oct 15 | 08:59:28 ~
    $ conky -q -x 100 -y 20 -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin &
[1] 14643
 
 11 Oct 15 | 09:00:14 ~
    $ 

Picture or it didn't happen:
2015_10_11_08_56_37_Scrot11.jpg

Check line #13 of every BL conky I did - the individual conky killer line is there.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#4 2015-10-11 12:19:08

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

Re: Movable conkys

Actually no need to comment out the x_gap & y_gap calls in the conky:

Options

Command line options override configurations defined in configuration file.

-v | -V | --version
    Prints version and exits

-q | --quiet
    Run Conky in 'quiet mode' (ie. no output)

-D | --debug
    Increase debugging output, ie. -DD for more debugging

-a | --alignment= ALIGNMENT
    Text alignment on screen, {top,bottom,middle}_{left,right,middle} or none. Can also be abbreviated with first chars of position, ie. tr for top_right.

-b | --double-buffer
    Use double buffering (eliminates "flicker")

-c | --config= FILE
    Config file to load instead of $HOME/.conkyrc

-C | --print-config
    Print builtin default config to stdout. See also the section EXAMPLES for more information.

-d | --daemonize
    Daemonize Conky, aka fork to background

-f | --font= FONT
    Font to use

-h | --help
    Prints command line help and exits

-o | --own-window
    Create own window to draw

-t | --text= TEXT
    Text to render, remember single quotes, like -t ' $uptime '

-p | --pause= SECONDS
    Time to pause before actually starting Conky

-u | --interval= SECONDS
    Update interval

-w | --window-id= WIN_ID
    Window id to draw

-X | --display= DISPLAY
    X11 display to use

-x X_COORDINATE
    X position

-y Y_COORDINATE
    Y position

-i COUNT
    Number of times to update Conky (and quit) 

Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#5 2015-10-11 23:50:39

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

Re: Movable conkys

@Sector11 you're suggesting to edit the command line that launches that particular conky, instead of editing the config file I guess? That would substitute the task of finding the file where the command lies for that of finding the config file. Have to look into it - whichever task turns out to be easier.

The goal is to have the change persist after logout or reboot.

@damo do you want to grab the ball now, or should I try and take it a bit further?


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

#6 2015-10-12 00:08:12

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

Re: Movable conkys

Not suggesting anything ... just showing that it is possible from a command in a terminal, therefore the two variables could be "tweaked" in a bash script.  How is way over my head.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#7 2015-10-12 00:19:53

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

Re: Movable conkys

Sector11 wrote:

the two variables could be "tweaked" in a bash script.

Yes, but when the script closed (on logout) the data would be lost. We need to preserve the new conky position somewhere. 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.


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

#8 2015-10-12 00:24:47

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

Re: Movable conkys

johnraff wrote:

....
@damo do you want to grab the ball now, or should I try and take it a bit further?

Not right away - it's next on the to-do list now. ("BLOB Configuration Manager" is nearly ready, but there are endless tweaks I keep having to do sad )


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

#9 2015-10-12 00:52:41

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

Re: Movable conkys

Sounds like me with my rss parser. I'm getting there with it though. I will work on it some more this week and post some updates as I have sorted a lot of the initial issues I was having. Just a few more such as ending bbcode tags breaking conky formatting. Once, I get the formatting part done, I will rebuild it to be a command-line tool, then look at the possibility of translating it to object-oriented code, in case someone wanted to inherit and extend it for use in something else. Funny how something that sounds so simple can end up like "Holy cow, there's a lot more to this than I thought."

Offline

#10 2015-10-12 01:04:55

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

Re: Movable conkys

@damo OK I'll turn down the gas a bit. Maybe post up a function if I make one...

Anyway, I'm thinking the flow (should have put this in the first post) would be:

For each running conky:

  • Find its current location.

  • Find its config file. (This might be the trickiest bit, at least to make robust, cope with non-standard paths etc.)

  • Compare its location with what's in the config file.

  • If it's different, calculate the necessary change to gap_x etc, and

  • Edit the config file.

One major difficulty is that, unlike most other apps but like tint2, conky does not report its PID to the window manager, so you can't get it from wmctrl, xprop etc. For most of the above work, though, the X window id is enough, and xprop can give us the command line with WM_COMMAND from which we can grab the argument after -c ( or --config= ) to get the config file location.

But... if someone had a script which cd'd into a directory of config files and executed conky from there, then the command would be 'conky ./filename' and we'd have no idea where the directory was. It's possible to find the working directory of a process only if you have the PID. neutral

The only workaround I've thought of to date would be to use 'pgrep -a conky' to get all the PIDs and command lines, then compare those command lines with what xprop had given us to try to match PIDs with X id's. That would still fail, though, if two conkys had config files with the same names but launched from different directories.

With a default BL setup that wouldn't be the case, but it would still be nice for it to be solid and failsafe if possible...

tknomanzr wrote:

Funny how something that sounds so simple can end up like "Holy cow, there's a lot more to this than I thought."

...sigh...


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

#11 2015-10-12 01:14:58

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

Re: Movable conkys

Of course, you could always pass it back to the user and let them supply the path to the conky via cli.  ]:D I guess you were hoping for more automation than that though.

Offline

#12 2015-10-12 01:19:52

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

Re: Movable conkys

^Well, yes. Just a "pin conkys" item in the conky submenu to make Alt-drags persistent.

Still, if we didn't try to cope with non-bunsen-standard setups it wouldn't be so hard.


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

#13 2015-10-12 01:44:45

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

Re: Movable conkys

FWIW, I have voluntarily accepted BL's conky standards as they just make sense and provide benefits, such as them being accessible to conky chooser, etc. Not trying to suggest you make it specific to BL and I certainly understand wanting scripts to be a bit more universally applicable. HOwever, I like it when stuff makes sense big_smile

Offline

#14 2015-10-12 02:06:12

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

Re: Movable conkys

but you can get conkys PID:

 11 Oct 15 | 23:03:06 ~
    $ ps ax | grep conky
11682 ?        Sl     0:01 conky -q -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin
13432 pts/2    S+     0:00 grep conky
31131 ?        S      0:03 conky -q -c /media/5/Conky/S12/S12_time_L.conky
31132 ?        Sl     1:27 conky -q -c /media/5/Conky/S12/S12_time_tm.conky
31133 ?        S      0:03 conky -q -c /media/5/Conky/S12/S12_time_R.conky
31361 ?        Sl     0:55 conky -q -c /media/5/Conky/S11_Rem_Cal.conky
31480 ?        Sl     0:48 conky -q -c /media/5/Conky/S11_Dates.conky
31711 ?        Sl     0:16 conky -q -c /media/5/Conky/S11_MD_Cal-br.conky
31713 ?        Sl     0:38 conky -q -c /media/5/Conky/S11_thin_r_side.conky
32043 ?        S      0:15 conky -q -c /media/5/Conky/S11_Email_01.conky
32055 ?        S      0:03 conky -q -c /media/5/Conky/Eagle.conky
32190 ?        S      0:38 conky -q -c /media/5/Conky/S12/S12_L_n_B.conky
 
 11 Oct 15 | 23:03:35 ~
    $ ps ax | grep /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin
11682 ?        Sl     0:01 conky -q -c /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin
13511 pts/2    S+     0:00 grep /media/5/Conky/1b2_accuweather_conkyweather_font/conkyrc_1b2_int_s11_thin
 
 11 Oct 15 | 23:04:05 ~
    $ ps ax | grep /media/5/Conky/S12/S12_time_L.conky
13576 pts/2    S+     0:00 grep /media/5/Conky/S12/S12_time_L.conky
31131 ?        S      0:03 conky -q -c /media/5/Conky/S12/S12_time_L.conky
 
 11 Oct 15 | 23:04:21 ~
    $ ps ax | grep /media/5/Conky/S12/S12_L_n_B.conky
13626 pts/2    S+     0:00 grep /media/5/Conky/S12/S12_L_n_B.conky
32190 ?        S      0:38 conky -q -c /media/5/Conky/S12/S12_L_n_B.conky
 
 11 Oct 15 | 23:04:43 ~
    $ 

Or am I missing something?


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#15 2015-10-12 02:20:02

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

Re: Movable conkys

Nice:

tknomanzr@wtfbox-bl:~/bin$ ps ax | grep conky
 9100 ?        Sl    21:55 conky -c /home/tknomanzr/.config/conky/wtfbox-rss.conkyrc
 9104 ?        Sl    23:28 conky -c /home/tknomanzr/.config/conky/wtfbox_conky.conkyrc
 9117 ?        Sl    30:25 conky -c /home/tknomanzr/.config/conky/wtfbox_processes.conkyrc
12514 pts/0    S+     0:00 grep conky

the three conky's I have running atm.

Offline

#16 2015-10-12 03:23:57

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

Re: Movable conkys

You can get the PIDs of running conkys with ps or pgrep, but to get the X window information (x-offset etc) you need the X id which is different. 'wmctrl -l' will list all the open windows, with the info and the X id's so that bit's good. What is very difficult is tying a certain PID to a certain X id.


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

#17 2015-10-12 03:44:45

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

Re: Movable conkys

In conky 1.10 at least, it is possible to set a window_id when you start the conky:

-w | --window-id= WIN_ID
              Window id to draw

which still doesn''t solve your problem. It looks like all of the matching arguments will fail because we don't usually set own_window_class to be anything but conky, nor do we set it's title, id, etc. I am beginning to think it might be wise for me to rethink those particular arguments, because it would certainly make isolating one conky out of several running easier.

Offline

#18 2015-10-12 04:55:17

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

Re: Movable conkys

The problem with conky (and tint2) is that it doesn't report its PID to the window manager, so none of those x-window type tools are able to get it. Most other apps set _NET_WM_PID.

Still, if we just assume that the conky is launched from $HOME, and/or the absolute path to the config file appears in the command line, then we can manage without the PID.

Last edited by johnraff (2015-10-12 04:58:52)


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

#19 2015-10-12 05:23:27

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

Re: Movable conkys

Ok. That actually makes sense as you dont want the WM picking it up and attempting to decorate it, etc. The only two ways I can think of to run a conky are from $HOME with a single default conky or using a -c config. I definitely would not consider running it from a root directory to be a good idea.

Offline

#20 2015-10-12 05:59:20

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

Re: Movable conkys

1) Get conky command which was used, from...

ps aux | grep [c]conky

2) Extract the `own_window_title` from the conkyrc - eg "Bunsen Labs Left Conky"

3)

xwininfo -name "Bunsen Labs Left Conky"

...and get the window positions


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

Board footer

Powered by FluxBB