You are not logged in.

#1 2021-06-03 07:20:45

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Launching conky on a specific desktop.

At the moment, the usual (ie what I've seen in BL scripts) way to launch a non-sticky conky on a certain desktop is to use wmctrl to move to that desktop, launch the conky there, wait a bit to make sure it's properly up, then return to the original desktop:

wmctrl -s "$newdesktop"
conky -c "$filepath" &
sleep 1s # or shorter time?
wmctrl -s "$originaldesktop"

That works, but I feel a bit uncomfortable about doing this in scripts, especially with multiple conkys being forked off into the background in subshells. What exactly happens if you try to change desktop inside a subshell??

But, both wmctrl and xdotool have commands to move a certain window to another desktop, without having to change the desktop you're currently on. This seems cleaner to me, but the snag is that you have to know the X window ID of the conky you want to move:

wmctrl -i -r "$windowid" -t "$desktop"
# or
xdotool set_desktop_for_window "$windowid" "$desktop"

Getting that id is not as simple as it might look.

Conky helpfully outputs some handy info to STDERR when you start it up, like:

conky: desktop window (10e) is root window
conky: window type - normal
conky: drawing to created window (0x2000001)
conky: drawing to double buffer
conky: forked to background, pid is 5476

That contains the window id, but how to get it into a variable so you can use it? This doesn't work:

data=$(conky -c ~/.config/conky/BL-Button-conky.conf 2>&1 & ); echo "$data"

It just hangs, presumably waiting for conky to close before writing $data, and if you stop it with Ctrl+C then $data is empty. There doesn't seem to be any way to capture the STDERR of a backgrounded process in a variable.

If anyone knows a trick, please post.

What does work, though, is to write the output to a temporary file instead:

conky -c "$path" >> "$datafile" 2>&1 &

This launches the conky and the window id is there in $datafile to be grepped out. Creating (and later deleting) temporary files feels awfully messy, but it does work and doesn't take much longer than the sleep that you'd be putting in anyway.

A second method is to make a list of all the running conkys just before the launch, then again after the launch. The difference should be the new conky, with its window id. That depends on no other conkys being surrepticiously launched immediately after the one we're interested in, during that sleep time. The sleep is necessary to make sure the new conky is up and running before making the second list. But in real life, maybe unlikely to be a problem. Both these lists work:

wmctrl -lx | grep -i conky
xdotool search --class conky

But the xdotool version excludes things like Geany or Firefox with "Conky" in the title. Again, unlikely that one of those will suddenly appear during that 0.2s sleep time.

So, three test scripts, just to compare the code. Pass the path to the config file as $1 and the number of the desktop you want to put it on as $2. The tempfile and wmctrl versions take about the same time to run; the xdotool one is ~100ms slower, but it's no big deal really. My current favourite is the tempfile, because the window id it gets seems a bit more reliable, but they all work OK on this machine.

tempfile

#!/usr/bin/bash

path=$1
desktop=$2

datafile=$(mktemp)
conky -c "$path" >> "$datafile" 2>&1 &
sleep 0.2 # on fast machine less sleep is OK, even 0.05
conkydata=$(<"$datafile" )
regexp='drawing to created window \((0x[0-9]+)\)'
[[ $conkydata =~ $regexp ]] && id=${BASH_REMATCH[1]} # no need to check data line by line
rm "$datafile"
[[ -n $id ]] && wmctrl -i -r "$id" -t "$desktop"

2 lists, wmctrl

#!/usr/bin/bash

path=$1
desktop=$2

list1=$(wmctrl -lx | grep -i conky)
conky -c "$path" &
sleep 0.2
list2=$(wmctrl -lx | grep -i conky)
new=$(comm -13 <(sort <<< $list1) <(sort <<< $list2))
id=${new%% *}
wmctrl -i -r "$id" -t "$desktop"

2 lists, xdotool

#!/usr/bin/bash

path=$1
desktop=$2

list1=$(xdotool search --class conky)
conky -c "$path" &
sleep 0.2
list2=$(xdotool search --class conky)
new=$(comm -13 <(sort <<< $list1) <(sort <<< $list2))
id=${new%% *}
xdotool set_desktop_for_window "$id" "$2"

Something to play with... smile


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#2 2021-06-03 13:36:51

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,667

Re: Launching conky on a specific desktop.

I have 4 desktops. At startup:

killall conky
wmctrl -s 3 &
start a conky &
sleep 1

wmctrl -s 1 &
start a conky &
start a conky &
sleep 1

wmctrl -s 0 &
start a conky &
start a conky &
start a conky &
start a conky &
start a conky &
start a conky &
sleep 5 && a conky &

exit

That format with a slight tweak has worked for me since #! days.

If it ain't broke don't fix it.
Just saying, it's clean, it's simple and leaves me on Desktop 0 (1)


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.
_______________________________
Debian 10 Buster = SharpBang ♯!

Offline

#3 2021-06-03 21:43:43

JCN-9000
Member
From: Turin, Italy
Registered: 2016-04-22
Posts: 17

Re: Launching conky on a specific desktop.

Conky window can have a name ( own_window_title ) and both wmctrl and xdotool can list / search and maybe work on windows using their name.

Offline

#4 2021-06-04 00:25:59

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

^This is true, and makes the job much simpler, but I was trying to find a way that would work regardless of what was in the conky config.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#5 2021-06-04 05:38:55

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

@Sector11 I see what you're saying, and for a user's startup file the way you do it is absolutely fine.
But, as I posted:

That works, but I feel a bit uncomfortable about doing this in scripts, especially with multiple conkys being forked off into the background in subshells. What exactly happens if you try to change desktop inside a subshell??

I was hoping to find a way that could be used by scripts like BLOB or bl-conky-manager - which run during the session not at startup - to reliably and predictably send a conky to a certain desktop, while leaving the user at their current desktop the whole time. And would also work well, regardless of which desktop the user was on.

I'm hopeful that this might work OK.

And, maybe by re-using the config parser functions from bl-conkymove, we could discover whether a conky was sticky or not, and not waste time looking at desktops for sticky conkys, which are on all desktops anyway.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#6 2021-06-04 09:10:35

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

This so-called 'stickiness' does not have to be done by a script. It would be sufficient in all involved Conky's - sticky - to remove from the line.

    own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',  --,sticky

Since I become more and more forgetful  sad  , I have (also with the help of a Script of the Master Sector11) a data Conky tinkered, which does me the wedding day, important birthdays in the family and other often needed data indicate.  wink
I switch this on and off with the help of a starter from the jgmenu.
The insertion of wmctrl starts the conky on the respective desktop. However, the desktop changes to 1 --> 2.
e.g. BL with 2 desktop

if
	pgrep -f "conky -q -c /home/unklar/.config/conky/s11dateutil_conkyrc10"

then
	pkill -xf "conky -q -c /home/unklar/.config/conky/s11dateutil_conkyrc10"

else
	wmctrl -s 1 && conky -q -c "/home/unklar/.config/conky/s11dateutil_conkyrc10"

A conky manager does nothing else in principle. So, all involved Conky get a corresponding entry in the CM.

Offline

#7 2021-06-04 13:23:47

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,667

Re: Launching conky on a specific desktop.

johnraff wrote:

{snip} while leaving the user at their current desktop the whole time. And would also work well, regardless of which desktop the user was on.

{snip}

Sorry missed that part.  Good luck.

===

For the three seconds my script takes to get back to desktop 1 where I am 95% of the time I have simply gotten use to it over the years.  My last conky takes longer due to the way it gets the data needed form my Nivida card.  And I rarely have a need to start "all" conkys anyway.

This type of line is at the top of all my conkys:

## pkill -xf "conky -c /media/5/Conky/S11.clock.conky" &

Copy to a terminal

 04 Jun 21 @ 10:16:24 ~
   $ pkill -xf "conky -c /media/5/Conky/S11.clock.conky" &
[1] 12698
 
 04 Jun 21 @ 10:16:36 ~
   $ conky -c /media/5/Conky/S11.clock.conky &
[2] 12921
[1]   Done                    pkill -xf "conky -c /media/5/Conky/S11.clock.conky"
 
 04 Jun 21 @ 10:17:04 ~
   $ Conky: desktop window (296) is root window
Conky: window type - normal
Conky: drawing to created window (0x4c00002)
Conky: drawing to double buffer

 
 04 Jun 21 @ 10:17:09 ~
   $ 

Again Good luck ...


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.
_______________________________
Debian 10 Buster = SharpBang ♯!

Offline

#8 2021-06-04 15:15:37

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,413

Re: Launching conky on a specific desktop.

johnraff wrote:

find a way that would work regardless of what was in the conky config.

Using the conky config options works to your advantage (see unklar's post about removing "sticky").

johnraff wrote:

I was hoping to find a way that could be used by scripts like BLOB or bl-conky-manager - which run during the session not at startup - to reliably and predictably send a conky to a certain desktop, while leaving the user at their current desktop the whole time. And would also work well, regardless of which desktop the user was on.

If you use the conky config settings to define the conky window; for example:

own_window = true,
own_window_colour = '#141414',
own_window_transparent = true,
own_window_type = 'normal' ,
own_window_hints = 'below,skip_taskbar,skip_pager',
own_window_class = 'Conkytzdata',
own_window_title = 'Conkytzdata',

The you can use the defined own_window_class and own_window_title in the openbox per app settings to have openbox place the conky window on the preferred desktop. Then it's just a matter of setting up a key binding or menu entry to launch the conky. No need to invoke wmctrl or xdotool.

I know this method works for openbox and fluxbox; it should work for any window manager that allows for per-application settings (i3, bspwm, awesome - most of the popular window managers).

Probably get the viewpoint to change when the conky is opened if you want.

Defining the window title and class is also useful for yad scripts; then again, you can use the built-in capabilities of your window manager to place the window.


You must unlearn what you have learned.
    -- yoda

Offline

#9 2021-06-04 16:16:24

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,667

Re: Launching conky on a specific desktop.

@ PackRat

Excellent stuff.

But 2000 conky would make for a HUGE file  smile

Even for the 10 I run daily it would be BIG.

But with two or three.  GREAT!
TY


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.
_______________________________
Debian 10 Buster = SharpBang ♯!

Offline

#10 2021-06-04 16:53:22

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,413

Re: Launching conky on a specific desktop.

sector11 wrote:

But 2000 conky would make for a HUGE file

Something tells me you actually have that many big_smile

But you only need to do it once then diligently back up the rc.xml,  monkey

Just pick a rainy day and limber up those typing fingers.


You must unlearn what you have learned.
    -- yoda

Offline

#11 2021-06-04 20:35:41

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,667

Re: Launching conky on a specific desktop.

PackRat wrote:
sector11 wrote:

But 2000 conky would make for a HUGE file

Something tells me you actually have that many big_smile

Let's do a look-see:
~/.config/conky
- sub folders are support folders for 51 conkys in there

~/.Conky  - OMG  Only 1 conky there

~/accuweather_rss
- has 2 conkys

And of course the famous:
~/.conkyrc
~/.conkyrc2

Another partition:

/media/5/Conky/
- 89 folders in that
- - this is not counting the conkys in the sub-folders of those 89 folders
- 416 conkys

/media/5/conky/
- 199 sub folders
- - a few that I looked at have sub-sub-sub-folders
- 775 conkys

At one time I has over 4000 but lost a lot because of an OOPS! on my part!

But you only need to do it once then diligently back up the rc.xml,  monkey

Just pick a rainy day and limber up those typing fingers.

But they change.  smile

This is one of the sub folders:
/media/5/Conky/PackRat/PackRat.Tao.conky
/media/5/Conky/PackRat/PackRat.Tao_1.9.conky
/media/5/Conky/PackRat/tao.txt

I'm sure you recognize it.

BUT back to johnraff's idea  (Sorry for the derail John)


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.
_______________________________
Debian 10 Buster = SharpBang ♯!

Offline

#12 2021-06-05 04:51:52

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

Hi @unklar @PackRat and @Sector11
thanks for your suggestions.

The thing is, I think we're talking about two different situations here.

Editing conky configs to set stickiness, class or title, possibly editing rc.xml, looks like the clean way to set up a bunch of conkys for a single user.

What I'm trying to do, though, is to improve the BL utilities that we ship, and which should work for all users. That means tweaking conky.conf is not an option - it's something 100% under the control of the user.

These three scripts:
bl-conky-session - starts up a bunch of conkys at login, using a conkysession file
bl-conky-manager - lets the user choose some conkys to run, from the config files he/she has
BLOB - stores the conky (and lots of other things) situation, and reproduces it on demand

@damo has already put support for conky-on-a-desktop in BLOB, using the switch-to-desktop, launch-conky, sleep, return-to-original-desktop method. I'm planning for bl-conky-session and bl-conky-manager to support desktop setting too, also to simplify the conkysession file - instead of storing the whole command like this (for example):

wmctrl -s 1 && conky -c /home/john/.config/conky/BL-Button-conky.conf & sleep 1

it could use an entry like this:

D[1] /home/john/.config/conky/BL-Button-conky.conf

So just the path and desktop are stored, leaving the task of launching the conky to the script.
The D[<number>] bit could be anything, just some characters that would be very unlikely to come at the start of a config file path, could also be desktop%<number>% or whatever...

Trial version of bl-conky-session seems to be working OK.
Want a look?

#!/bin/bash
#
#    bl-conky-session: read saved BunsenLabs Conky session file(s) and start the conkys
#    Copyright (C) 2015 damo    <damo@bunsenlabs.org>
#                  2021 John Crawley <john@bunsenlabs.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#   To start the default conky session at login, add the following line
#   to config/openbox/autostart:
#
#      bl-conky-session &
#
########################################################################
CONKYPATH="$HOME/.config/conky"
BLDEFAULT="$CONKYPATH/BL-Default-conky.conf"
DEFAULTSESSFILE="$CONKYPATH/conky-sessionfile"
STARTSESSION="$CONKYPATH/conky-startup-session" # symlink to chosen startup session (DEFAULTSESSFILE by default)
BKP_SFX=".$(date +"%Y%m%d-%H%M%S").conkysess~"
USAGE='bl-conky-session is a script to parse saved BunsenLabs Conky session file(s)
and start the conkys

Usage: bl-conky-session [OPTION(S)]...FILES

With no command argument, the script uses the default "$CONKYPATH/conky-sessionfile" sessionfile.

If not absolute, sessionfile paths are assumed to be relative to ~/.config/conky/

Options:
        --default       : specify default sessionfile
        sessionfile1  sessionfile2 etc

Examples:
    Run specified sessionfile at login:

            "bl-conky-session /path/to/sessionfile"

    Run default sessionfile:

            "bl-conky-session"

    Run several conky sessionfiles, including default:

            "bl-conky-session sessionfile1 --default sessionfile2 etc"
'

### DIALOG VARIABLES
DLG="yad --center --undecorated --borders=20 "
TITLE="BunsenLabs Conky Session"
WINICON="--window-icon=distributor-logo-bunsenlabs"
OK="--button=OK:0"
CANCEL="--button=gtk-cancel:1"

########################################################################

if [[ ! -f $DEFAULTSESSFILE ]] ; then
    echo "$0: Failed to locate ${DEFAULTSESSFILE}, generating default..." >&2
    if [[ -f $BLDEFAULT ]]; then
        echo "conky -c $BLDEFAULT & sleep 1s" > "$DEFAULTSESSFILE"
    elif [[ -f $CONKYPATH/conky.conf ]];then
        echo "$0: $BLDEFAULT not found, using $CONKYPATH/conky.conf in session file." >&2
        echo "conky -c $CONKYPATH/conky.conf & sleep 1s" > "$DEFAULTSESSFILE"
    else
        echo "$0: unable to determine conky config file for this session." >&2
        exit 1
    fi
fi

if [[ ! -f $STARTSESSION ]]; then
    echo "$0: generating missing symlink $STARTSESSION to $DEFAULTSESSFILE"
    ln -s "$DEFAULTSESSFILE" "$STARTSESSION" || echo "$0: WARNING: failed to create symlink $STARTSESSION"
fi

killConkys(){
    if pidof conky &>/dev/null; then
        MSG="Kill running conkys first?"
        $DLG $WINICON --title="$TITLE" --text="$MSG" "$CANCEL" --button="Don't kill":2 "$OK"
        case $? in            # kill all conkys
        0)
            killall conky && sleep 0.2s || return 1
            ;;
        1)
            return 1
            ;;
        2)
            return 0
            ;;
        esac
    fi
}

# takes path to conky sessionfile
#loadSession(){
#    source "$1"
#}

loadSession(){
    local file CPATH_REGEX WMC_REGEX WINID_REGEX needRewrite conkys c path desktop datafile target
    file=$1
    CPATH_REGEX="-c '(.*(conky.*\.conf|conky|conkyrc))'([[:blank:]]+|$)"
    WMC_REGEX='wmctrl -s ([0-9]{1,2})[[:blank:]]+'
    WINID_REGEX='drawing to created window \((0[xX][0-9a-fA-F]+)\)'
    needRewrite=false
    mapfile -t conkys < "$file"
    for i in "${!conkys[@]}"; do
        c=${conkys[i]}
        if [[ ${c%% *} = conky ]]; then # old style: first word is 'conky'
            if [[ $c =~ $CPATH_REGEX ]]; then
                conkys[i]=${BASH_REMATCH[1]} # rewrite with filepath only
            else
                echo "$0: WARNING: failed to parse line $c in $file" >&2
                conkys[i]='' # discard line
            fi
            needRewrite=true
        elif [[ ${c%% *} = wmctrl ]]; then # old style, on specific desktop
            if [[ $c =~ ${WMC_REGEX}.*${CPATH_REGEX} ]]; then
                conkys[i]="D[${BASH_REMATCH[1]}] ${BASH_REMATCH[2]}" # 'D[<desktop>] <path>'
            else
                echo "$0: WARNING: failed to parse line $c in $file" >&2
                conkys[i]='' # discard line
            fi
            needRewrite=true
        else
            continue # assume line (in fact, whole file probably) is in new style
        fi
    done
    set -m # enable job control so forked conkys are immune to signals (although unnecessary when conky is forked to background in config)
    for path in "${conkys[@]}"; do
        case ${path%% *} in # first word
        D\[*\]) # D[1]... is assumed to be a sufficiently unlikely beginning of a conky filepath
            desktop=${path%%]*}
            desktop=${desktop#*[}
            path=${path#* }
            datafile=$(mktemp)
            conky -c "$path" >> "$datafile" 2>&1 &
            disown
            sleep 0.5
            [[ $(<"$datafile") =~ $WINID_REGEX ]] && id=${BASH_REMATCH[1]} # no need to check file line by line
            [[ -n $id ]] && wmctrl -i -r "$id" -t "$desktop"
            rm "$datafile"
            ;;
        *) # assume line is a clean filepath
            conky -c "$path" &
            disown
            sleep 0.5
            ;;
        esac
    done
    set +m
    if [[ $needRewrite = true ]]; then # should only happen once
        target=$(readlink -f "$file") # in case $file is a symlink
        cp "$target" "${target}${BKP_SFX}" # make backup
        echo "$0: reformatting $file"
        :> "$file"
        for path in "${conkys[@]}"; do
            echo "$path" >> "$file"
        done
    fi
}


########################################################################

unset sessions
declare -A sessions # keys hold all session files passed, without duplicates
for arg in "$@"
do
    case $arg in
    '-h'|'--help')
        echo -e "$USAGE"
        exit 0
        ;;
    '--autostart') # this argument now ignored
        :
        ;;
    '--default')
        [[ -f $STARTSESSION ]]
        sessions["$STARTSESSION"]=1
        ;;
    *)
        [[ $arg = /* ]] || arg="$CONKYPATH/$arg" # relative path
        if [[ -f "$arg" ]]; then
            sessions["$arg"]=1
        else
            echo "$0: WARNING: session file $arg does not exist." >&2
        fi
        ;;
    esac
done

killConkys || exit

if (( ${#sessions[@]} > 0 )); then
    for SESSION in "${!sessions[@]}";do # run the conkys in the sessionfiles
        loadSession "$SESSION"
    done
else    # no sessionfiles passed to bl-conky-manager
    loadSession "$STARTSESSION"   # use whichever file symlink conky-startup-session points to (conky-sessionfile by default)
fi

Yes it's a bit long, but in the usual situation should run quite quickly. Anyway the conky sleep times account for most of it. The desktop stuff is only done (in the loadSession() function) if the sessionfile calls for it.

EDIT: fixed CPATH_REGEX for cases where there are no single quotes round the conky filepath.
EDIT: reject lines that couldn't be parsed with that regex. (A backup conky-sessionfile is made anyway.)

Last edited by johnraff (2021-06-11 06:53:18)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#13 2021-06-06 07:43:22

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

Thanks @john for your explanations.

I fell for the "many" autostart in BL last night and am not sure,
if I am applying the right thing now.  wink

Specifically:
[beryllium]
~/.config/autostart/
~/.config/bunsen/autostart
~/.config/openbox/autostart

So I created the script in ~/.config/openbox/autostart, only to realize that I am using ~/.config/bunsen/autostart. Also, I assume that takes precedence over /usr/bin/bl-conky-session --autostart.

So far there was no bl-conky-session script in $HOME.
Since I actually only use my own conky's, I had created the conky-sessionfile myself after installing [beryllium]. It was deleted unasked during the attempts.  hmm

Now the script bl-conky-session and the conky-sessionfile are in ~/.config/conky/
I didn't change anything, the default settings of the script are working.
It is not clear to me, where the user should make this "D [1] - setting in the script, in order to let the Conky appear on a certain desktop.

In this context also the hint: The default setting in the configuration of each Conky is always 'normal' (as I always understood it, it doesn't need to be there extra).
Example from @PackRat:

own_window = true,
own_window_colour = '#141414',
own_window_transparent = true,
own_window_type = 'normal' ,    <----
own_window_hints = 'below,skip_taskbar,skip_pager',
own_window_class = 'Conkytzdata',
own_window_title = 'Conkytzdata'

But as soon as 'desktop' or 'override' are used there, 'sticky' can be in there, commented out - it has no influence anymore, the conky appears on EVERY desktop.   smile

Offline

#14 2021-06-09 03:30:46

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

Hi @unklar. I think I have muddied the waters too much, sorry.
The bl-something scripts shipped in BunsenLabs Beryllium at the moment are still pretty much the same as in Lithium.
This stuff I've been posting is still ideas for changes.

The bl-conky-session script I posted above, though, is supposed to be backward-compatible, ie it should work OK along with the other Lithium scripts. I'm using it right now in my regular BL Lithium system with no visible damage. roll

If you want to try it - of course user feedback and bug reports are great to have - then you can copy it into ~/bin, and make sure it's executable. 'which bl-conky-session' should return '/home/<you>/bin/bl-conky-session', indicating that the default /usr/bin/bl-conky-session has been overruled. (Putting the script in ~/.config/conky won't do anything at all.) Then your user startup script, ~/.config/bunsen/autostart should already be calling 'bl-conky-session --autostart' on around line 96. (The --autostart is not needed in the new version, and just gets ignored.)

To set a desktop for a certain conky, as you point out, first the conky needs not to be sticky, so own_window_type cannot be desktop or override. (I haven't researched the other window types beyond normal.. Maybe that's the only non-sticky window type.) Also own_window_hints must not contain sticky.

Then, if the conky's not sticky you can make it go to a certain desktop by adding that D[<number] thing at the start of the line in ~/.config/conky/conky-sessionfile. (The new bl-conky-manager should be able to do that too.)
But that might possibly change to desktop[<number>] so users will see what it's for, or possibly even desktop%<number>% or something else if anyone has any suggestions. Any pattern that has no spaces, is easy to recognize, and unlikely to be in a real conky config filepath, would be OK. But once it's decided we shouldn't change it.

---
~/.config/openbox/autostart is ignored in a BL session

~/.config/autostart/ is for user .desktop files to override those in /etc/xdg/autostart
BL puts xbindkeys.desktop there to disable the global autostart, so xbindkeys has to be started from ~/.config/bunsen/autostart. The idea of that is so people running some other session (eg xfce or another window manager) don't get xbindkeys if they don't want/need it.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#15 2021-06-09 14:57:29

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

^I had written this down for you so you know what system I'm trying on. smile

in the ~/.xsession-errors i get this error and my conky's don't start:

/home/unklar/bin/bl-conky-session: Zeile 112: Syntaxfehler beim unerwarteten Symbol »(«
/home/unklar/bin/bl-conky-session: Zeile 112: `    CPATH_REGEX="-c '(.*(conky.*\.conf|conky|\.conkyrc))'([[:blank:]]+|$)"'

line 112 syntax error on unexpected symbol

Offline

#16 2021-06-10 04:52:19

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

^This is very strange. I've just re-checked, and the code I posted above is exactly the same as what's in my ~/bin/bl-conky-session which runs on every login with no errors, starting my four conkys, one of which is non-sticky and sent to desktop 1 as a test.

My conky-sessionfile holds this:

/home/john/.config/conky/netmon.conkyrc
/home/john/.config/conky/netusers.conkyrc
/home/john/.config/conky/sysmon.conkyrc
D[1] /home/john/.config/conky/two words/BL-Button-conky.conf

The line 112 you posted above is identical to mine, and looks OK:

CPATH_REGEX="-c '(.*(conky.*\.conf|conky|\.conkyrc))'([[:blank:]]+|$)"

No unexpected  (  as far as I can see.
EDIT: but the single quotes round the filepath need to be '?:

CPATH_REGEX="-c '?(.*(conky.*\.conf|conky|\.conkyrc))'?([[:blank:]]+|$)"

Could you check your copied-in code again?
And maybe try running 'bash -x bl-conky-session' and post the output?
This is what I get:

john@lithium:~$ bash -x bl-conky-session
+ CONKYPATH=/home/john/.config/conky
+ BLDEFAULT=/home/john/.config/conky/BL-Default-conky.conf
+ DEFAULTSESSFILE=/home/john/.config/conky/conky-sessionfile
+ STARTSESSION=/home/john/.config/conky/conky-startup-session
++ date +%Y%m%d-%H%M%S
+ BKP_SFX=.20210610-134109.conkysess~
+ USAGE='bl-conky-session is a script to parse saved BunsenLabs Conky session file(s)
and start the conkys

Usage: bl-conky-session [OPTION(S)]...FILES

With no command argument, the script uses the default "$CONKYPATH/conky-sessionfile" sessionfile.

If not absolute, sessionfile paths are assumed to be relative to ~/.config/conky/

Options:
        --default       : specify default sessionfile
        sessionfile1  sessionfile2 etc

Examples:
    Run specified sessionfile at login:

            "bl-conky-session /path/to/sessionfile"

    Run default sessionfile:

            "bl-conky-session"

    Run several conky sessionfiles, including default:

            "bl-conky-session sessionfile1 --default sessionfile2 etc"
'
+ DLG='yad --center --undecorated --borders=20 '
+ TITLE='BunsenLabs Conky Session'
+ WINICON=--window-icon=distributor-logo-bunsenlabs
+ OK=--button=OK:0
+ CANCEL=--button=gtk-cancel:1
+ [[ ! -f /home/john/.config/conky/conky-sessionfile ]]
+ [[ ! -f /home/john/.config/conky/conky-startup-session ]]
+ unset sessions
+ declare -A sessions
+ killConkys
+ pidof conky
+ MSG='Kill running conkys first?'
+ yad --center --undecorated --borders=20 --window-icon=distributor-logo-bunsenlabs '--title=BunsenLabs Conky Session' '--text=Kill running conkys first?' --button=gtk-cancel:1 '--button=Don'\''t kill:2' --button=OK:0
+ case $? in
+ killall conky
+ sleep 0.2s
+ ((  0 > 0  ))
+ loadSession /home/john/.config/conky/conky-startup-session
+ local file CPATH_REGEX WMC_REGEX WINID_REGEX needRewrite conkys c path desktop datafile target
+ file=/home/john/.config/conky/conky-startup-session
+ CPATH_REGEX='-c '\''(.*(conky.*\.conf|conky|\.conkyrc))'\''([[:blank:]]+|$)'
+ WMC_REGEX='wmctrl -s ([0-9]{1,2})[[:blank:]]+'
+ WINID_REGEX='drawing to created window \((0[xX][0-9a-fA-F]+)\)'
+ needRewrite=false
+ mapfile -t conkys
+ for i in "${!conkys[@]}"
+ c=/home/john/.config/conky/netmon.conkyrc
+ [[ /home/john/.config/conky/netmon.conkyrc = conky ]]
+ [[ /home/john/.config/conky/netmon.conkyrc = wmctrl ]]
+ continue
+ for i in "${!conkys[@]}"
+ c=/home/john/.config/conky/netusers.conkyrc
+ [[ /home/john/.config/conky/netusers.conkyrc = conky ]]
+ [[ /home/john/.config/conky/netusers.conkyrc = wmctrl ]]
+ continue
+ for i in "${!conkys[@]}"
+ c=/home/john/.config/conky/sysmon.conkyrc
+ [[ /home/john/.config/conky/sysmon.conkyrc = conky ]]
+ [[ /home/john/.config/conky/sysmon.conkyrc = wmctrl ]]
+ continue
+ for i in "${!conkys[@]}"
+ c='D[1] /home/john/.config/conky/two words/BL-Button-conky.conf'
+ [[ D[1] = conky ]]
+ [[ D[1] = wmctrl ]]
+ continue
+ set -m
+ i=1
+ for path in "${conkys[@]}"
+ case ${path%% *} in
+ disown
+ conky -c /home/john/.config/conky/netmon.conkyrc
+ sleep 0.5
conky: desktop window (80039b) is subwindow of root window (10e)
conky: window type - normal
conky: drawing to created window (0x2000002)
conky: drawing to double buffer
conky: forked to background, pid is 8852

+ ((  i++  ))
+ for path in "${conkys[@]}"
+ case ${path%% *} in
+ disown
+ sleep 0.5
+ conky -c /home/john/.config/conky/netusers.conkyrc
conky: desktop window (80039b) is subwindow of root window (10e)
conky: window type - normal
conky: drawing to created window (0x2a00002)
conky: drawing to double buffer
conky: forked to background, pid is 8856

+ ((  i++  ))
+ for path in "${conkys[@]}"
+ case ${path%% *} in
+ disown
+ sleep 0.5
+ conky -c /home/john/.config/conky/sysmon.conkyrc
conky: desktop window (80039b) is subwindow of root window (10e)
conky: window type - normal
conky: drawing to created window (0x3200002)
conky: drawing to double buffer
conky: forked to background, pid is 8864

+ ((  i++  ))
+ for path in "${conkys[@]}"
+ case ${path%% *} in
+ desktop='D[1'
+ desktop=1
+ path='/home/john/.config/conky/two words/BL-Button-conky.conf'
++ mktemp
+ datafile=/tmp/tmp.5Sz1w4uNDR
+ disown
+ sleep 0.5
+ conky -c '/home/john/.config/conky/two words/BL-Button-conky.conf'
+ [[ conky: desktop window (80039b) is subwindow of root window (10e)
conky: window type - normal
conky: drawing to created window (0x3400001)
conky: drawing to double buffer
conky: forked to background, pid is 8870 =~ drawing to created window \((0[xX][0-9a-fA-F]+)\) ]]
+ id=0x3400001
+ [[ -n 0x3400001 ]]
+ wmctrl -i -r 0x3400001 -t 1
+ rm /tmp/tmp.5Sz1w4uNDR
+ ((  i++  ))
+ set +m
+ [[ false = true ]]

Last edited by johnraff (2021-06-11 06:11:46)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#17 2021-06-10 08:34:48

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

Thanks @john, for your effort.  :)

This is what I get:

$ which bl-conky-session
/home/unklar/bin/bl-conky-session
 bash -x bl-conky-session
+ CONKYPATH=/home/unklar/.config/conky
+ BLDEFAULT=/home/unklar/.config/conky/BL-Default-conky.conf
+ DEFAULTSESSFILE=/home/unklar/.config/conky/conky-sessionfile
+ STARTSESSION=/home/unklar/.config/conky/conky-startup-session
++ date +%Y%m%d-%H%M%S
+ BKP_SFX=.20210610-102258.conkysess~
/home/unklar/bin/bl-conky-session: bl-conky-session: Zeile 112: Syntaxfehler beim unerwarteten Symbol »(«
/home/unklar/bin/bl-conky-session: bl-conky-session: Zeile 112: `    CPATH_REGEX="-c '(.*(conky.*\.conf|conky|\.conkyrc))'([[:blank:]]+|$)"'

conky-sessionfile

#conky -c '/home/unklar/.config/conky/conky.conf' & sleep 1s
#sleep 5 && wmctrl -s 0 && conky -c /home/unklar/.conky/letzterVersuch/conkyrc10_rep &
#sleep 10 && wmctrl -s 0 && conky -c /home/unklar/.conky/letzterVersuch/2016_S11.conkyrc10 &
D[1] /home/unklar/WuPix/wu_pixconky_zwo &
#sleep 15 && wmctrl -s 1 && conky -c /home/unklar/S11_and_mobildiesel/bottom_conkyrc10 &
#sleep 15 && wmctrl -s 1 && conky -c /home/unklar/Moongiant_conky_script/.conkyrc_Moon_S11_V1 &
D[0] /home/unklar/.conky/data/data_conkyrc &
#sleep 20 && conky -c /home/unklar/S11/cmus_senk10 &

Could it be because my Conky's don't always go to 'conkyrc' end?   :/

edit:
Same result

D[1] /home/unklar/WuPix/wu_pixconky_zwo

D[0] /home/unklar/.conky/data/data_conkyrc

Last edited by unklar (2021-06-10 08:49:44)

Offline

#18 2021-06-10 08:59:38

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

^Did you remove part of the output? In mine, there's a chunk after
BKP_SFX=...
and before
CPATH_REGEX=...

It seems to me that the CPATH_REGEX error should not appear till after the function is called:
loadSession

One thing: there should not be a &  at the end of the filepaths in conky-sessionfile.
Try taking those out...

---
Oh yes, I now see your conky files don't match the CPATH_REGEX:
wu_pixconky_zwo
cmus_senk10

It's expecting the name to end with conkysomething.conf or conky or .conkyrc
But if there's no match it should echo:
"bl-conky-session: WARNING: failed to parse line $c in $file"
and then go on to try the other lines.

I'll test at this end with a conky-sessionfile with non-standard names...

EDIT: Never mind. The CPATH_REGEX is not even used when the line in conky-sessionfile does not start with 'conky ', so the conky should still get launched if the file exists.

So your error is still mysterious. vyJoYBP.gif

Last edited by johnraff (2021-06-10 09:08:36)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#19 2021-06-10 09:11:30

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

^^Yes, and the CONKYPATH is not correct either...

I will continue this later, have to go now  smile

Offline

#20 2021-06-10 15:49:45

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

@john, it's because of the incorrect path of my conky's.  wink
The script from @damo clearly assumes this:

CONKYPATH="$HOME/.config/conky"

This is how it looks now on Lithium, with correct CONKYPATH and a fresh conky-sessionfile:

$ bash -x bl-conky-session
+ CONKYPATH=/home/unklar/.config/conky
+ BLDEFAULT=/home/unklar/.config/conky/BL-Default-conky.conf
+ DEFAULTSESSFILE=/home/unklar/.config/conky/conky-sessionfile
+ STARTSESSION=/home/unklar/.config/conky/conky-startup-session
++ date +%Y%m%d-%H%M%S
+ BKP_SFX=.20210610-173500.conkysess~
+ USAGE='bl-conky-session is a script to parse saved BunsenLabs Conky session file(s)
and start the conkys

Usage: bl-conky-session [OPTION(S)]...FILES

With no command argument, the script uses the default "$CONKYPATH/conky-sessionfile" sessionfile.

If not absolute, sessionfile paths are assumed to be relative to ~/.config/conky/

Options:
        --default       : specify default sessionfile
        sessionfile1  sessionfile2 etc

Examples:
    Run specified sessionfile at login:

            "bl-conky-session /path/to/sessionfile"

    Run default sessionfile:

            "bl-conky-session"

    Run several conky sessionfiles, including default:

            "bl-conky-session sessionfile1 --default sessionfile2 etc"
'
+ DLG='yad --center --undecorated --borders=20 '
+ TITLE='BunsenLabs Conky Session'
+ WINICON=--window-icon=distributor-logo-bunsenlabs
+ OK=--button=OK:0
+ CANCEL=--button=gtk-cancel:1
+ [[ ! -f /home/unklar/.config/conky/conky-sessionfile ]]
+ [[ ! -f /home/unklar/.config/conky/conky-startup-session ]]
+ unset sessions
+ declare -A sessions
+ killConkys
+ pidof conky
+ ((  0 > 0  ))
+ loadSession /home/unklar/.config/conky/conky-startup-session
+ local file CPATH_REGEX WMC_REGEX WINID_REGEX needRewrite conkys c path desktop datafile target
+ file=/home/unklar/.config/conky/conky-startup-session
+ CPATH_REGEX='-c '\''(.*(conky.*\.conf|conky|\.conkyrc))'\''([[:blank:]]+|$)'
+ WMC_REGEX='wmctrl -s ([0-9]{1,2})[[:blank:]]+'
+ WINID_REGEX='drawing to created window \((0[xX][0-9a-fA-F]+)\)'
+ needRewrite=false
+ mapfile -t conkys
+ for i in "${!conkys[@]}"
+ c='D[0] /home/unklar/.config/conky/BL-Text.conkyrc'
+ [[ D[0] = conky ]]
+ [[ D[0] = wmctrl ]]
+ continue
+ for i in "${!conkys[@]}"
+ c='D[1] /home/unklar/.config/conky/s11dateutil_conkyrc10'
+ [[ D[1] = conky ]]
+ [[ D[1] = wmctrl ]]
+ continue
+ set -m
+ i=1
+ for path in "${conkys[@]}"
+ case ${path%% *} in
+ desktop='D[0'
+ desktop=0
+ path=/home/unklar/.config/conky/BL-Text.conkyrc
++ mktemp
+ datafile=/tmp/tmp.F5rMkM83Ya
+ disown
+ sleep 0.5
+ conky -c /home/unklar/.config/conky/BL-Text.conkyrc
+ [[ conky: desktop window (a0) is root window
conky: window type - normal
conky: drawing to created window (0x3800001)
conky: drawing to double buffer
conky: forked to background, pid is 18035 =~ drawing to created window \((0[xX][0-9a-fA-F]+)\) ]]
+ id=0x3800001
+ [[ -n 0x3800001 ]]
+ wmctrl -i -r 0x3800001 -t 0
+ rm /tmp/tmp.F5rMkM83Ya
+ ((  i++  ))
+ for path in "${conkys[@]}"
+ case ${path%% *} in
+ desktop='D[1'
+ desktop=1
+ path=/home/unklar/.config/conky/s11dateutil_conkyrc10
++ mktemp
+ datafile=/tmp/tmp.aV4YjvoYn6
+ disown
+ sleep 0.5
+ conky -c /home/unklar/.config/conky/s11dateutil_conkyrc10
+ [[ conky: desktop window (a0) is root window
conky: window type - normal
conky: drawing to created window (0x3a00001)
conky: drawing to double buffer =~ drawing to created window \((0[xX][0-9a-fA-F]+)\) ]]
+ id=0x3a00001
+ [[ -n 0x3a00001 ]]
+ wmctrl -i -r 0x3a00001 -t 1
+ rm /tmp/tmp.aV4YjvoYn6
+ ((  i++  ))
+ set +m
+ [[ false = true ]]

Sorry for confusing you.  big_smile  wink

Offline

#21 2021-06-10 17:09:06

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

Re: Launching conky on a specific desktop.

@unklar   IIRC it was decided to use the default conky path because of the difficulty in knowing where else a user might keep their conky configs.


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

#22 2021-06-10 17:56:08

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

^@damo, that is correct and is also fine. Thanks for your work. smile
My Conky's were just not in this standard path. big_smile

@john, in [beryllium] I have now cleaned the path and the configuration files. Still the mysterious syntax error remains, as shown above.
At the moment I don't know where else to look. I also replaced the conky -v1.11.6 with the predecessor 1.10.8. No success.

It works in lithium, not in [beryllium].  sad

Offline

#23 2021-06-11 05:03:15

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

@unklar thanks for the time you've put into this.
I've been doing most of my development and testing on Lithium - even though the scripts are meant for Beryllium. That syntax error... maybe Bash has changed in some subtle way on Bullseye? Definitely time for me to do some more testing on Beryllium.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#24 2021-06-11 06:14:50

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 8,034
Website

Re: Launching conky on a specific desktop.

OK I've found a couple of things:

1) The syntax error seems to be coming from incorrect escaping of single quotes. At least, you can reproduce it with grep, on Lithium or Beryllium:

grep -E -- '-c \'(.*(conky.*\.conf|conky|\.conkyrc))\'' ~/.config/conky/conky-sessionfile
bash: syntax error near unexpected token `('

The single quote needs to be escaped not like this

\'

but like this:

'\''

or else use double quotes outside the whole string:

grep -E -- "-c '(.*(conky.*\.conf|conky|\.conkyrc))'" ~/.config/conky/conky-sessionfile

But I still don't know @unklar why you get it when you run bl-conky-session on Beryllium. It runs OK for me (at least for the syntax thing).

2) Some BL scripts are writing conky-sessionfile with single quotes around the filepath, and some without. I'm not going to track it down right now because the new bl-conky-session won't need the quotes anyway (EDIT: think it's bl-conky-pipemenu), but CPATH_REGEX needs to cope with both cases in old-style files, so revised to:

CPATH_REGEX="-c '?(.*(conky.*\.conf|conky|\.conkyrc))'?([[:blank:]]+|$)"

The '? means the single quote is optional. The filepath part of the line is still well defined because it starts just after -c and space, and ends with one of those patterns with conky in: conkysomething.conf or conky or .conkyrc.

So I'll add those question marks to the regex above, but I still can't get the syntax error to appear when running bl-conky-session on Beryllium.

Last edited by johnraff (2021-06-11 06:48:50)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#25 2021-06-11 15:34:03

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 1,476

Re: Launching conky on a specific desktop.

@john,
both conky-sessionfile in lithium and beryllium have no single quotes in my case.
The only thing they have in common is that they were created by me by hand (with geany), not by a script.

Offline

Board footer

Powered by FluxBB