You are not logged in.
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...
...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 )
Online
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)
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
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
^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), now on Bluesky, there's also some GitStuff )
Online
@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), now on Bluesky, there's also some GitStuff )
Online
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 , 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.
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
{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 ...
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
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").
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
@ PackRat
Excellent stuff.
But 2000 conky would make for a HUGE file
Even for the 10 I run daily it would be BIG.
But with two or three. GREAT!
TY
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
But 2000 conky would make for a HUGE file
Something tells me you actually have that many
But you only need to do it once then diligently back up the rc.xml, 8o
Just pick a rainy day and limber up those typing fingers.
You must unlearn what you have learned.
-- yoda
Offline
sector11 wrote:But 2000 conky would make for a HUGE file
Something tells me you actually have that many
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, 8o
Just pick a rainy day and limber up those typing fingers.
But they change.
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
BUT back to johnraff's idea (Sorry for the derail John)
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
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), now on Bluesky, there's also some GitStuff )
Online
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.
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.
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.
Offline
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.
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), now on Bluesky, there's also some GitStuff )
Online
^I had written this down for you so you know what system I'm trying on.
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
^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), now on Bluesky, there's also some GitStuff )
Online
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
^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.
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), now on Bluesky, there's also some GitStuff )
Online
^^Yes, and the CONKYPATH is not correct either...
I will continue this later, have to go now
Offline
@john, it's because of the incorrect path of my conky's.
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.
Offline