You are not logged in.

#41 2024-12-16 05:24:01

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:
johnraff wrote:

3) Choose image, instead of pressing image in popup, mistakenly press "Confirm" in main dialogue - app freezes. I don't know how this should be fixed.

This issue still exists. After choosing an image, click anywhere on the main window and the app freezes completely. Xorg or Wayland.

Right now having trouble reproducing this on Wayland. It was definitely present before.

On Xorg, still present, just after the first popup. The second confirmation popup is OK.

Last edited by johnraff (2024-12-16 05:31:08)


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

#42 2024-12-16 05:58:07

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

Re: Wallpaper setter for Carbon - X11 and Wayland

bit of quoting

To get wallpaper files with spaces in the names to be handled properly I had to do some quoting of variables to avoid word splitting (and possible globbing with *).

In sub_gui() the two (Xorg & Wayland) ACTION= lines #276 and #281, $1 had to be surrounded by escaped single quotes \'$1\' like this:

ACTION='<action>echo -e " -o $OUT -m $MODE '$CCOL' \\ \n\t -i '\'$1\'' \\" >> '$TEMP/$SS'</action>'
ACTION='<action>if [[ "$MODE" == "stretch" || "$MODE" == "fit" ]];then MODE=fill;fi; echo -e " --bg-$MODE '${XCOL}' \\ \n\t'\'$1\'' \\" >> '$TEMP/$SS'</action>'

And at the end of _output() line #499, sub_gui's argument needs to be quoted:

sub_gui "$FBG"

With those three edits filenames with spaces are processed OK. cool

Unrelated, but shellcheck pointed out that the regex passed to grep in button_gui on line #263 needed to be quoted to avoid the shell trying to glob onto that *:

for j in $(ls "$TEMP" | grep 'buttonsx[0-9]*')

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

#43 2024-12-16 06:32:44

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

2) On X the wallpaper setting is not persistent. By comparing with Wayland, seems there's a line missing to save the command to CONFDIR. Adding this after ~#440 seems to fix it:

		. "$TEMP"/cmd
		cat "$TEMP"/cmd > "$CONFDIR"/cmd # add this line

This still needs fixing on Xorg to enable the set wallpaper to be stored for restoring later.
Just after line #518:

cat $TEMP/cmd > $CONFDIR/cmd # you can put this in your startup file

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

#44 2024-12-16 06:48:07

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

Got home a little early today so had time to refactor.

  • the main gui is no longer static in that it is closed every time sub_gui is run. This solves the issue of a stale GUI (and I could reproduce in wayland) at the expense of the program being a little 'clunky' - but I'll take it as it's more stable. The alternative is to approach like 'azote' does and put all outputs at bottom of main gui - a big refactor that may happen - eventually.

  • added enhancements for quoting as posted above

  • The main gui is cached in between runs for multi monitor setups. To increase speed of course.

  • took away choice of monitors in sub_gui, was buggy anyway so now just loop through them; and a user with a multimon setup will (should yikes) know how they are oriented

  • most things work as before

I'm thinking about calling it xwwall now (yes has a double w).

#!/bin/bash

export V=0.1.0
export GTK3DIALOG
[[ -z "$GTK3DIALOG" ]] && GTK3DIALOG=gtk3dialog
export BGDIR="${BGDIR:-$HOME/Pictures/wallpapers/bunsen/default}"
export PROG=${0##*\/}
#export TEMP=/tmp/$PROG
export TEMP=$HOME/tmp/$PROG # for testing
mkdir -p "$TEMP"
export CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}/$PROG"
mkdir -p "$CONFDIR"
export CONF="$CONFDIR/$PROG.conf"
if [[ ! -f "$CONF" ]];then
	echo "BGDIR=$BGDIR" > "$CONF"
fi
. "$CONF"

case "$1" in
	--restore)
	if [[ -f "$CONFDIR/cmd" ]]; then
	. "$CONFDIR/cmd" && exit 0
	else
		exit 1
	fi
	;;
	-*v|-*version)
	echo -e "\t$PROG $V\n\t\tGPL-2.0+ licence\n"
	exit 0
	;;
	-*h|-*help)
	echo -e "\t$PROG -h|--help\n\t\tshow this help and exit.\n"
	echo -e "\t$PROG -v|--version\n\t\tprint version and exit.\n"
	echo -e "\t$PROG --restore\n\t\trestore backgrounds at session start.\n"
	echo -e "\ttry \"man $PROG\" for more information."
	exit 0
	;;
esac

# sort out the monitors and positions
if [[ -n "$WAYLAND_DISPLAY" ]]; then
	b=0
	c=1
	MON=''
	pos=''
	while read -r l m n o p q
	do
		case "${l:0:3}" in
			Pos|Mak|Mod|Ser|Phy|Ena|Tra|Sca|Ada)
			if [[ "${l:0:3}" == 'Pos' ]];then
				export pos
				pos=${m%,*};  echo POS=$pos >> "$TEMP/Wmonitor-$((c-1))"
			else
				continue
			fi
			;;
			[a-zA-Z][a-zA-Z][a-zA-Z0-9])MON=$l;;
		esac
		case "$q" in
			current*)res=$l;;
			*)continue;;
		esac
		resX=${res%x*}
		resY=${res#*x}
		echo OUTPUT=$MON >> "$TEMP/Wmonitor-$c"
		echo X=$resX >> "$TEMP/Wmonitor-$c"
		echo Y=$resY >> "$TEMP/Wmonitor-$c"
		c=$((c+1))
		b=$((b+1))
		echo $b > $TEMP/number
	done <<<$(wlr-randr)
	export POPT='edge="top" dist="100"'
	export SOPT='layer="top"'
	export CONFILE="$CONFDIR/Wconf"
else
	k=0
	n=1
	MON=''
	while read -r a b c d z
	do
		echo $a
		[[ "${a}" == 'Monitors:' ]] && continue
		MON=$d
		resX=${c/\/[0-9]*/}
		resY=${c#*x}
		resY=${resY/\/[0-9]*/}
		pos=${c#*+}
		pos=${pos/+/ }
		[[ "${pos%\ *}" == '0' ]] && n=0 # 'xx' position
		pos=${pos%\ *}
		echo  Xmonitor-$n
		echo $MON
		echo $resX
		echo $resY
		echo $pos
		echo OUTPUT=$MON >> "$TEMP/Xmonitor-$n"
		echo X=$resX >> "$TEMP/Xmonitor-$n"
		echo Y=$resY >> "$TEMP/Xmonitor-$n"
		echo POS=$pos >> "$TEMP/Xmonitor-$n"
		n=$((n+1))
		k=$((k+1))
		echo $k > $TEMP/number
	done <<<$(xrandr --listmonitors)
	export POPT='decorated="false"'
	export SOPT=$POPT
	export CONFILE="$CONFDIR/Xconf"
fi

#CSS
echo 'window#splash {
	background: rgba(0,0,0,0.0);
}
#splash {
	background: #5E003E;
	color: #ffffff;
	border-radius: 10px;
	padding: 2px;
}
' > "$TEMP/win.css"



# get the primary output
e=0
if [[ -n "$WAYLAND_DISPLAY" ]]; then
	for i in $TEMP/Wmonitor*
	do
		#echo "$i is being sourced"
		. "$i"
		[[ "$POS" == '0' ]] && echo "$OUTPUT = primary" && cp $i $TEMP/ww0
		[[ "$POS" == "$X" ]] && echo "$OUTPUT = secondary" && cp $i $TEMP/ww1
		[[ $POS -gt $X ]] && echo "$OUTPUT = extra" && cp $i $TEMP/ww2$e && e=$((e+1))
	done
	rm $TEMP/Wmonitor* # finished with these
	read -r NUM < "$TEMP/number"
	export NUM
	echo $NUM outputs
	. $TEMP/ww0
	export W=$((X / 9))
	export H=$((Y / 10))
	export MW=$((X / 2))
	export MH=$((Y * 2 / 3))
else
	for f in $TEMP/Xmonitor*
	do
		#echo "$f is being sourced"
		. "$f"
		[[ "$POS" == '0' ]] && echo "$OUTPUT = primary" && cp $f $TEMP/xx0
		[[ "$POS" == "$X" ]] && echo "$OUTPUT = secondary" && cp $f $TEMP/xx1
		[[ $POS -gt $X ]] && echo "$OUTPUT = extra" && cp $i $TEMP/xx2$e && e=$((e+1))
	done
	rm $TEMP/Xmonitor* # finished with these
	export NUM
	read NUM < $TEMP/number
	echo $NUM outputs
	. $TEMP/xx0
	export W=$((X / 9))
	export H=$((Y / 10))
	export MW=$((X / 2))
	export MH=$((Y * 2 / 3))
fi

########################    functions     ##############################

# splash window
_splash() {
	[[ -z "$1" ]] && return
	case $2 in
		0)[[ "$SPLASH" == 'false' ]] && return
		DIS='
			<button tooltip-text="Do not show again">
				<input file icon="window-close"></input>
				<label>Dismiss</label>
				<action>if grep -q "SPLASH" '$CONF'; then sed -i "s/^SPLASH.*$/SPLASH=false/" '$CONF';else echo SPLASH=false >> '$CONF'; fi</action>
				<action>exit:DISMISS</action>
			</button>'
			;;
		2);;
		3)ACT='<action>main_gui &</action><action>exit:OK</action>';;
		4)ACT='<action>confirm_gui &</action><action>exit:OK</action>';;
		5)ACT='<action>kill '$PID'</action><action>exit:OK</action>';;
		*)ACT='<action>exit:OK</action>';;
	esac
	IVAL=6
	re='^[0-9]'
	[[ $3 =~ $re ]] && IVAL=$3
	echo '<window '$POPT' name="splash" width-request="360">
	<vbox name="splash">
		<hbox name="splash">
		<hbox space-expand="false" space-fill="false">
		  <pixmap name="splash"><width>42</width><input file icon="gtk-info"></input></pixmap>
		  <timer interval="'$IVAL'" visible="false"><action>exit:SPLASH</action><action>exit:BYE</action></timer>
	    </hbox>
	    <hbox space-expand="true" space-fill="true">
	      <text name="splash">
			<label>'"$1"'</label>
		  </text>
		</hbox>
		</hbox>
		<hbox name="splash">
			'$DIS'
			<button>
			  <label>OK</label>
			  <input file icon="gtk-ok"></input>
			  '$ACT'
			</button>
		</hbox>
	</vbox>
</window>' | $GTK3DIALOG -s --styles=$TEMP/win.css
	[[ "$2" == '1' ]] && exit $2
}; export -f _splash

# sort selections
_selections() {
	echo '<hbox>' > $TEMP/ret
	cat $TEMP/selected | while read -r sel
	do
		echo '    <pixmap>
		  <height>120</height>
		  <input file>'$sel'</input>
		</pixmap>' >> $TEMP/ret
	done
	echo '</hbox>' >> $TEMP/ret
}; export -f _selections

# set each background
confirm_gui() {
	_selections
	PIX=$(cat $TEMP/ret)
	export CON='<window icon-name="background" title="Confirm selection">
	<vbox>
    <hbox space-expand="true" space-fill="true">
	    <text><label>Please confirm that the image below is correct.</label></text>
	  </hbox>
	  <hbox space-expand="true" space-fill="true">
		'$PIX'
	  </hbox>
	  <hbox>
	    <button yes></button><button no></button>
	  </hbox>
	</vbox>
</window>'

	eval "$($GTK3DIALOG -p CON -c --styles=$TEMP/win.css)"
	case $EXIT in
		Yes)_build_command;;
		*)return 1;;
	esac
}; export -f confirm_gui

# populate the main GUI
button_gui() {
	# populate main gui
	c=0
	shopt -s globstar
	for WALL in "$BGDIR"/*{,/**}
	do
		file -b --mime-type "$WALL" | grep -q 'image' || continue # test mime
		# we take advantage of bash math here
		# for a nicish GUI width *must* be consistent
		i=$((c/4))
		echo '  <button image-position="top" tooltip-text="Set '"${WALL##*/}"'">
	        <variable>BG'$c'</variable>
	        <input file>'"\"$WALL\""'</input>
			<height>'$W'</height>
			<width>'$W'</width>
			<!--action>echo '"\"$WALL\""' > '$TEMP/choice'</action-->
			<action>_output '"\"$WALL\""' &</action>
			<action>exit:BG'$c'</action>
	      </button>' >> $TEMP/buttonsx$i
	      c=$((c+1))
	done
	shopt -u globstar
	for j in $(ls "$TEMP" | grep 'buttonsx[0-9]*')
	do echo "		<hbox>
		$(cat "$TEMP/$j")
		</hbox>" >> $TEMP/buttons
	done
}

# sub GUI
sub_gui() {
	[[ -z "$COLOR" ]] && COLOR=999999
	if [[ -n "$WAYLAND_DISPLAY" ]]; then
		CCOL="-c $COLOR"
		SS='Wset'
		ACTION='<action>echo -e " -o $OUT -m $MODE '$CCOL' \\ \n\t -i '\'$1\'' \\" >> '$TEMP/$SS'</action>'
	else
		# feh modes: --bg-scale, --bg-center[ --image-bg=$color], --bg-fill, --bg-max[ --image-bg=$color], --bg-tile
		XCOL=" --image-bg=#${COLOR}"
		SS='Xwset'
		ACTION='<action>if [[ "$MODE" == "stretch" || "$MODE" == "fit" ]];then MODE=fill;fi; echo -e " --bg-$MODE '${XCOL}' \\ \n\t'\'$1\'' \\" >> '$TEMP/$SS'</action>'
	fi
	[[ $NUM -gt 1 ]] && XTRA='Choose output display and '
	[[ -r "$TEMP/increment" ]] || echo -n 1 > $TEMP/increment
	INC=$(cat $TEMP/increment)
	# set default for entry
	case $INC in
		1)DEFAULT=$(sed '1s/item/default/g' < $TEMP/OP | sed -n 1p) ;;
		2)DEFAULT=$(sed '2s/item/default/g' < $TEMP/OP | sed -n 2p) ;;
		3)DEFAULT=$(sed '3s/item/default/g' < $TEMP/OP | sed -n 3p) ;;
		4)DEFAULT=$(sed '4s/item/default/g' < $TEMP/OP | sed -n 4p) ;;
		5)DEFAULT=$(sed '5s/item/default/g' < $TEMP/OP | sed -n 5p) ;;
		6)DEFAULT=$(sed '6s/item/default/g' < $TEMP/OP | sed -n 6p) ;;
	esac
	if [[ $INC -gt $NUM ]]; then
		_splash "You are at your monitor limit. Confirm?" 4
	else
	export SUBGUI='<window icon-name="background" title="Selection">
	<vbox>
    <hbox space-expand="true" space-fill="true">
	    <text><label>'$XTRA'Press image</label></text>
	  </hbox>
    <hbox space-expand="true" space-fill="false">
      <text use-markup="true"><label>"<big>Mode:</big>"</label></text>
      <comboboxtext>
        <variable>MODE</variable>
        <item>stretch</item>
        <item>center</item>
        <item>tile</item>
        <item>fit</item>
      </comboboxtext>
    </hbox>
	 <hbox space-expand="true" space-fill="false">
      <text use-markup="true"><label>"<big>Output:</big>"</label></text>
      <entry>
        <variable>OUT</variable>
        '$DEFAULT'
      </entry>
    </hbox>
	  <hbox space-expand="true" space-fill="true">
		<button tooltip-text="Press image to confirm or No to reject and confinue.">
		  <variable>CBG</variable>
	      <input file>'$1'</input>
	  	  <width>320</width>
		  <!--action>if [[ '$INC' -gt '$NUM' ]];then exit:SPLASH;fi</action-->
		  <action>echo -n '$((INC+1))' > $TEMP/increment</action> 
		  <action>if grep -q $OUT '$TEMP'/'$SS' >/dev/null 2>&1; then _splash "Only 1 wall per monitor. Maybe you have reached the monitor limit?." 3;fi;</action>
		  <action>echo '$1' >> '$TEMP'/selected</action>
		  '$ACTION'
		  <action>sed -i "s% $%%g" '$TEMP/$SS'</action>
		  <action>main_gui &</action>
	      <action>exit:CBG</action>
		</button>
	  </hbox>
	  <hbox>
	    <text label="Output: '$INC'"></text>
	    <button>
	      <label>No</label>
	      <input file icon="gtk-no"></input>
	      <action>main_gui &</action>
	      <action>exit:NO</action>
	    </button>
	  </hbox>
	</vbox>
   </window>'
	$GTK3DIALOG -p SUBGUI -c --styles=$TEMP/win.css
	fi
}; export -f sub_gui
	
# populate the main GUI
main_gui() {
	[[ -r "$TEMP/main_gui.xml" ]] && _splash "Please wait ..." 2 2 &
	BUTTONS=$(cat $TEMP/buttons)
	export MAINGUI='<window icon-name="background" title="Background Choice - Output: '$INC'" width-request="'$MW'">
  <vbox>
    <hbox space-expand="true" space-fill="true">
      <text use-markup="true"><label>"<b>Select an image for your wallpaper by pressing the image.</b>"</label></text>
    </hbox>
    <hseparator space-expand="true" space-fill="true"></hseparator>
    <hbox>
      <vbox scrollable="true" height="'$MH'">
        '$BUTTONS'
      </vbox>
    </hbox>
    <hbox space-expand="true" space-fill="true">
    <hbox space-expand="false" space-fill="false">
      <button tooltip-text="Preferences"><width>16</width><input file icon="preferences-desktop-wallpaper"></input>
        <action>exit:PREFS</action>
      </button>
    </hbox>
	<hseparator space-expand="true" space-fill="true"></hseparator>
      <text label="Press Confirm when you are ready."></text>
    <hseparator space-expand="true" space-fill="true"></hseparator>
    <hbox space-expand="false" space-fill="false">  
      <button>
        <label>Cancel</label>
        <input file icon="gtk-cancel"></input>
        <action>kill '$PID'</action>
        <action>exit:abort</action>
      </button>
      <button>
        <label>Confirm</label>
        <input file icon="gtk-help"></input>
        <action>confirm_gui &</action>
        <action>exit:CONFIRM</action>
      </button>
    </hbox>
    </hbox>
  </vbox>
</window>'
	[[ -r "$TEMP/main_gui.xml" ]] || printf "%s\n" "$MAINGUI" > $TEMP/main_gui.xml
	eval "$($GTK3DIALOG -f $TEMP/main_gui.xml -c --styles=$TEMP/win.css)"
	if [[ "$EXIT" == "PREFS" ]]; then
		_pref
	fi	
}; export -f main_gui

# preferences
_pref() {
	. $CONF
	[[ "$SPLASH" == 'false' ]] && CDEF=false || CDEF=true
	[[ -n "$COLOR" ]] && DEFCOL=#${COLOR} ||  DEFCOL=#cccccc
	echo $DEFCOL
	export PGUI='<window icon-name="gtk-preferences" title="Preferences" width-request="400">
  <vbox>
    <hbox space-expand="true" space-fill="true">
      <text use-markup="true"><label>"<b>Select your preferences.</b>"</label></text>
    </hbox>
    <hseparator space-expand="true" space-fill="true"></hseparator>
    <hbox space-expand="true" space-fill="true">  
      <text><label>"Press Save and '$PROG' will restart when you are ready."</label></text>
    </hbox>
    <hbox space-expand="true" space-fill="true">  
      <text><label>"Just choose any image file in your chosen directory."</label></text>
    </hbox>
    <hbox space-expand="true" space-fill="true">  
      <hbox space-expand="true" space-fill="true">  
      <entry>
        <default>'$BGDIR'</default>
        <variable>BACKGROUNDS</variable>
      </entry>
      </hbox>
      <hbox space-expand="false" space-fill="false">
      <button>
        <input file icon="directory-open"></input>
        <action function="fileselect">BACKGROUNDS</action>
      </button>
      </hbox>
    </hbox>
    <hseparator space-expand="true" space-fill="true"></hseparator>
    <hbox space-expand="true" space-fill="true">  
      <hbox space-expand="true" space-fill="true">  
        <checkbox>
          <label>enable initial splash screen.</label>
          <variable>SPL</variable>
          <default>'$CDEF'</default>
        </checkbox>
      </hbox>
    </hbox>
    <hseparator space-expand="true" space-fill="true"></hseparator>
    <hbox space-expand="true" space-fill="true">  
      <hbox space-expand="true" space-fill="true">  
      <entry editable="false">
        <default>Choose a background color</default>
      </entry>
      </hbox>
      <hbox space-expand="false" space-fill="false">
      <colorbutton>
        <default>'$DEFCOL'</default>
        <variable>CLB0</variable>
      </colorbutton>
      </hbox>
    </hbox>
    <hseparator space-expand="true" space-fill="true"></hseparator>
    <hbox space-expand="false" space-fill="false">  
      <button>
        <label>Cancel</label>
        <input file icon="gtk-cancel"></input>
        <action>kill '$PID'</action>
        <action>exit:abort</action>
      </button>
      <button>
        <label>Save</label>
        <input file icon="gtk-save"></input>
        <action>exit:SAVE</action>
      </button>
    </hbox>
  </vbox>
</window>'
	eval "$($GTK3DIALOG -p PGUI -c --styles=$TEMP/win.css)"
	echo $SPL
	if [[ ! -d "$BACKGROUNDS" ]]; then
		BACKGROUNDS="${BACKGROUNDS%\/*}"
		sed -i "s%^BGDIR.*$%BGDIR=\"$BACKGROUNDS\"%" $CONF
	fi
	if grep -q 'SPLASH' $CONF; then
		sed -i "s/^SPLASH.*$/SPLASH=$SPL/" $CONF
	else
		echo "SPLASH=$SPL" >> $CONF
	fi
	if grep -q 'COLOR' $CONF; then
		sed -i "s/^COLOR.*$/COLOR=${CLB0:1:6}/" $CONF
	else
		echo "COLOR=${CLB0:1:6}" >> $CONF
	fi
	if [[ "$EXIT" == 'SAVE' ]]; then
		exec $0
	fi	
}; export -f _pref

# build options for output
_output() {
	[[ -n "$WAYLAND_DISPLAY" ]] && fff=ww || fff=xx
	
	rm -f $TEMP/OP 
	for output in $TEMP/${fff}*
	do
		. $output
		export OUTPUT
		export FBG="$1"
		echo "<item>$OUTPUT</item>" >> $TEMP/OP
	done
	. $CONF
	sub_gui "$FBG"
}; export -f _output

_build_command() {
	if [[ -n "$WAYLAND_DISPLAY" ]]; then	
		echo 'killall swaybg >/dev/null 2>&1' > $TEMP/cmd
		echo 'swaybg \' >> $TEMP/cmd
		cat $TEMP/Wset >> $TEMP/cmd
		echo '>/dev/null 2>&1 &' >> $TEMP/cmd
		# run it
		. "$TEMP/cmd"
		cat $TEMP/cmd > $CONFDIR/cmd # you can put this in your startup file
	else
		# this builds ~/.fehbg with the command below.
		echo 'killall feh >/dev/null 2>&1' > $TEMP/cmd
		echo 'feh \' >> $TEMP/cmd
		cat $TEMP/Xwset >> $TEMP/cmd
		echo '>/dev/null 2>&1 &' >> $TEMP/cmd
		# run it
		. "$TEMP/cmd"
	fi
}; export -f _build_command

trap_exit() {
	trap "rm -rf $TEMP" EXIT
}; export -f trap_exit


########################      main        ##############################
trap_exit
export PID=$$

if [[ -n "$WAYLAND_DISPLAY" ]]; then
	case "$XDG_CURRENT_DESKTOP" in
		wlroots|labwc|sway*|river|niri|hyprland)echo "$XDG_CURRENT_DESKTOP";; # this can be expanded later
		*)_splash "Unfortunately your desktop $XDG_CURRENT_DESKTOP is unsupported" 5 ;;
	esac
fi

if [[ ! -d "$BGDIR" ]]; then
	_splash "Please set a background directory" 3
	_pref
fi

if [[ "$NUM" != '1' ]]; then
	_splash "You have $NUM monitors connected. Carefully choose an image for each of them." 0 &
fi
echo ================
button_gui
main_gui

#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

#45 2024-12-16 06:56:07

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:
johnraff wrote:

2) On X the wallpaper setting is not persistent. By comparing with Wayland, seems there's a line missing to save the command to CONFDIR. Adding this after ~#440 seems to fix it:

		. "$TEMP"/cmd
		cat "$TEMP"/cmd > "$CONFDIR"/cmd # add this line

This still needs fixing on Xorg to enable the set wallpaper to be stored for restoring later.
Just after line #518:

cat $TEMP/cmd > $CONFDIR/cmd # you can put this in your startup file

feh generates the ~/.fehbg script. That's why the omission is intentional.

This is mine.

#!/bin/sh
feh --no-fehbg --bg-center --image-bg '#93906b' '/home/mick/Pictures/wallpapers/extra/pawel-czerwinsk-barkbrksm.png' '/home/mick/Pictures/wallpapers/sm.svg' 

I have this in my openbox/autostart

## Set a wallpaper
~/.fehbg &

#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

#46 2024-12-16 07:09:09

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

BTW, latest script line 8 should be uncommented and line 9 commented like below yikes

export TEMP=/tmp/$PROG
#export TEMP=$HOME/tmp/$PROG # for testing

#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

#47 2024-12-16 07:30:42

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

Re: Wallpaper setter for Carbon - X11 and Wayland

micko01 wrote:
johnraff wrote:
johnraff wrote:

2) On X the wallpaper setting is not persistent.

Just after line #518:

cat $TEMP/cmd > $CONFDIR/cmd # you can put this in your startup file

feh generates the ~/.fehbg script. That's why the omission is intentional.
...
I have this in my openbox/autostart

## Set a wallpaper
~/.fehbg &

Totally missed that! Sorry for the noise.

EDIT: I wonder if xwwall could invoke feh from 'xwwall --restore' just to keep the user instructions simple - same entry in both X and W startup files? (No harm if feh also writes its own ~/.fehbg of course.)

Now about to play with the new version...

EDIT It looks as if any future comments I might have will be more about GUI and user workflow, so a bit more personal-preferences. I'll leave it to settle a day or two.

Last edited by johnraff (2024-12-16 08:01:30)


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

#48 2024-12-16 07:46:26

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

Re: Wallpaper setter for Carbon - X11 and Wayland

To take advantage of the recursive directory scanning the default BGDIR needs bringing down to:

export BGDIR="${BGDIR:-$HOME/Pictures/wallpapers}"

I think this is important because it allows the user to add wallpapers in their $HOME and have them picked up by xwwall (tested).


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

#49 2024-12-16 08:09:48

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

To take advantage of the recursive directory scanning the default BGDIR needs bringing down to:

export BGDIR="${BGDIR:-$HOME/Pictures/wallpapers}"

I think this is important because it allows the user to add wallpapers in their $HOME and have them picked up by xwwall (tested).

But, it isn't following symlinks for me.

What I intend to do is support multiple paths, eg:

BGDIR="$HOME/Pictures/Wallpapers:/usr/share/images"

and support that in Preferences.


#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

#50 2024-12-16 09:46:35

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

Re: Wallpaper setter for Carbon - X11 and Wayland

micko01 wrote:
johnraff wrote:

To take advantage of the recursive directory scanning the default BGDIR needs bringing down to:

export BGDIR="${BGDIR:-$HOME/Pictures/wallpapers}"

I think this is important because it allows the user to add wallpapers in their $HOME and have them picked up by xwwall (tested).

But, it isn't following symlinks for me.

That's really weird. It works fine for me. And it's supposed to work, according to the docs.
It's true that the ** glob doesn't follow symlinks of directories, which is why I had to use that code:

"$BGDIR"/*{,/**}

/* picks up the contents of the current directory
/*/** does a recursive scan of all the subdirectories, including the symlinks picked up in the current directory

EDIT it's true that the ** glob will ignore directory symlinks in further subdirectories. The wallpapers/bunsen symlink works because it's caught by the regular * glob. So other symlinks will be ignored, but in a standard BL directory tree wallpapers/bunsen is the only one.

Anyway, it's definitely working on BL here. Can you do some testing of the glob in a terminal with a few files and directories?

john@trixie-tester:~$ shopt -s globstar
john@trixie-tester:~$ for i in ./Pictures/wallpapers/*{,/**}; do echo "$i"; done
./Pictures/wallpapers/bunsen
./Pictures/wallpapers/pawel bark.png
./Pictures/wallpapers/Ruby flame 1440x900.png
./Pictures/wallpapers/bunsen
./Pictures/wallpapers/bunsen/default
./Pictures/wallpapers/bunsen/default/Boron-Emerald-logo-1280x1024.png
./Pictures/wallpapers/bunsen/default/Boron-Emerald-logo-1440x900.png
./Pictures/wallpapers/bunsen/default/Boron-Emerald-logo-1920x1080.png
./Pictures/wallpapers/bunsen/default/Boron-Emerald-plain-1280x1024.png
./Pictures/wallpapers/bunsen/default/Boron-Emerald-plain-1440x900.png
./Pictures/wallpapers/bunsen/default/Boron-Emerald-plain-1920x1080.png
./Pictures/wallpapers/bunsen/default/default
./Pictures/wallpapers/bunsen/default/pawel-czerwinsk-bark.png
./Pictures/wallpapers/bunsen/default/pawel-czerwinski-bark.png
./Pictures/wallpapers/bunsen/default/pawel-czerwinski-sage.png
./Pictures/wallpapers/bunsen/default/Ruby-flame-1280x1024.png
./Pictures/wallpapers/bunsen/default/Ruby-flame-1440x900.png
./Pictures/wallpapers/bunsen/default/Ruby-flame-1920x1080.png
./Pictures/wallpapers/bunsen/default/Ruby-plain-1280x1024.png
./Pictures/wallpapers/bunsen/default/Ruby-plain-1440x900.png
./Pictures/wallpapers/bunsen/default/Ruby-plain-1920x1080.png
./Pictures/wallpapers/bunsen/default/tile.png
john@trixie-tester:~$ shopt -u globstar

Multiple paths would work of course but getting everything recursively is more flexible and what users are currently used to.

EDIT2: On reflection, multiple paths, user configured, doesn't sound so awful at all. Ultimately gives users more freedom.

It would be nice to pin down that symlinks issue though.

Last edited by johnraff (2024-12-16 11:33: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

#51 2024-12-17 08:01:33

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

Re: Wallpaper setter for Carbon - X11 and Wayland

Picking up a loose end. This isn't only with xwwall though.

micko01 wrote:
johnraff wrote:

Fine on Xorg, except that the round corners have square edges.

Round corners work fine on X here (bare metal, compositor 'picom', may not work in VM)

See in the screenshot (qemu VM, Xorg with picom), tint2 and lxterminal's corners are nicely rounded, but both geany and xwwall have square black extensions of the round corners, only noticable against a light background:
4o1ZtvCl.png
I've no idea what's happening here. @Micko01 do you not see this on your bare metal system?


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

#52 2024-12-17 11:46:01

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

It would be nice to pin down that symlinks issue though.

No issue. PEBKAC at this end, sorry about that noise! Seems working fine, probably copy/paste error.

johnraff wrote:

I've no idea what's happening here. @Micko01 do you not see this on your bare metal system?

Not at all. Perplexing since all 3 apps are gtk3; lxterminal, geany, xwwall.

0WaPMN8.png


#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

#53 2024-12-17 14:47:38

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

Re: Wallpaper setter for Carbon - X11 and Wayland

Just a silly noob question here but won't nitrogen work in wayland?


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#54 2024-12-18 00:56:57

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

Re: Wallpaper setter for Carbon - X11 and Wayland

micko01 wrote:
johnraff wrote:

It would be nice to pin down that symlinks issue though.

No issue. PEBKAC at this end, sorry about that noise! Seems working fine, probably copy/paste error.

No sweat, happens all the time.

johnraff wrote:

I've no idea what's happening here. @Micko01 do you not see this on your bare metal system?

Not at all. Perplexing since all 3 apps are gtk3; lxterminal, geany, xwwall.
https://i.imgur.com/0WaPMN8.png

Looks beautiful!
Anyway, let's put this on the back burner for a little while - maybe something will turn up...


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

#55 2024-12-18 01:00:58

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

Re: Wallpaper setter for Carbon - X11 and Wayland

Sector11 wrote:

Just a silly noob question here but won't nitrogen work in wayland?

Unfortunately not. sad
Actually, this is one case where it's not just a question of getting the window to display OK - where xwayland might have helped - but goes deeper into how the actual background image is drawn on the desktop. That's different between X and Wayland.


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

#56 2024-12-18 07:06:06

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

Re: Wallpaper setter for Carbon - X11 and Wayland

@micko what backend do you have set in picom.conf, or /etc/bunsen/picom-startup?

The corners issue looks a lot like this:
https://www.reddit.com/r/i3wm/comments/ … the_round/
and I tried setting the backend to glx instead of the default xrender, as someone-on-the-internet suggested.

It fixed the corners beautifully, but completely broke the rest of the desktop. neutral
Had to open a new tty to kill picom and go back to xrender. Same in picom.conf or in the command line via picom-startup.

Have yet to try the rounded-corners-exclude fix suggested there...

BTW Picom has been - I hope temporarily - dropped from Trixie:
https://tracker.debian.org/news/1585028 … m-testing/

Last edited by johnraff (2024-12-18 07:16:35)


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

#57 2024-12-18 08:23:47

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

@micko what backend do you have set in picom.conf, or /etc/bunsen/picom-startup?

Bone stock Boron version IRRC, I'll post the config without most of the comments.

#shadow-radius = 35;
shadow-radius = 12;

# The opacity of shadows. (0.0 - 1.0,  defaults to 0.75)
#shadow-opacity = 0.30;
shadow-opacity = 0.45;

# The left offset for shadows, in pixels. (defaults to -15)
#shadow-offset-x = -32;
shadow-offset-x = -8;

# The top offset for shadows, in pixels. (defaults to -15)
#shadow-offset-y = -32;
shadow-offset-y = -8;

# shadow-exclude = []
shadow-exclude = [
    "! name~=''",
#    "name = 'jgmenu'",
    "name = 'Notification'",
    "name = 'wbar'",
    "name = 'Docky'",
    "name = 'Kupfer'",
#    "name = 'xfce4-notifyd'",
    "name *= 'VirtualBox'",
    "name *= 'VLC'",
    "name *= 'Chromium'",
    "name *= 'Chrome'",
    "class_g ?= 'plank'", # see wintypes
    "class_g ?= 'picom'",
    "class_g = 'Tint2'",
    "class_g ?= 'Conky'",
    "class_g = 'Kupfer'",
    "class_g = 'Synapse'",
    "class_g ?= 'Notify-osd'",
    "class_g ?= 'Cairo-dock'",
#    "class_g ?= 'Xfce4-notifyd'",
    "class_g ?= 'Xfce4-power-manager'",
    "window_type = 'desktop'",
    "_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'",
    "_NET_WM_STATE@:32a *= '_NET_WM_STATE_MAXIMIZED_VERT'",
    "_GTK_FRAME_EXTENTS@:c"
];

# fading = false
fading = true;

# fade-out-step = 0.03
fade-out-step = 1.0;

#  Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc.
no-fading-destroyed-argb = true;

# inactive-opacity = 1
inactive-opacity = 0.96;

# frame-opacity = 0.7;
frame-opacity = 1.0;

# inactive-opacity-override = true
inactive-opacity-override = false;

# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0)
active-opacity = 1.0;

# `transparent-clipping`.
corner-radius = 10;

# Exclude conditions for rounded corners.
# Also see: https://github.com/owl4ce/dotfiles/discussions/177
rounded-corners-exclude = [
    "! name~=''",    # exclude windows with no name
#    "class_g = 'tint2'",
    "class_g  = 'Conky'",
#   "window_type = 'menu'",
#   "window_type = 'dock'",
    "window_type = 'desktop'",
#   "window_type = 'dropdown_menu'",
#   "window_type = 'popup_menu'",
#   "window_type = 'tooltip'",
#   "window_type = 'utility'"
#   "class_g = 'Polybar'",
#   "class_g = 'Rofi'",
#   "class_g = 'Dunst'",
    "_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'",
#   "_NET_WM_STATE@:32a *= '_NET_WM_STATE_MAXIMIZED_VERT'",
    "_GTK_FRAME_EXTENTS@:c"
];


# mark-wmwin-focused = false
mark-wmwin-focused = true;

# detect-client-opacity = false
detect-client-opacity = true;

use-ewmh-active-win = true;

unredir-if-possible = true;

# detect-transient = false
detect-transient = true;

# detect-client-leader = false
detect-client-leader = true;


# no-use-damage = false
use-damage = true;

# log-level = "debug"
log-level = "warn";

wintypes:
{
  dock = { shadow = false; };
  tooltip = { fade = false; shadow = false; };
  menu = { fade = false; };
  dropdown_menu = { fade = false; opacity = 1.0; };
  popup_menu =  { fade = false; opacity = 1.0; };
};

#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

#58 2024-12-18 08:30:11

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

The following patch fixes '--restore' command in X and some other very minor stuff - only for that latest posted.

I'll get more time this weekend then I'll be AFK for a week or so. Like many one would hope!

4496.gif

--- xwwall-orig	2024-12-16 20:25:25.088241081 +1000
+++ xwwall	2024-12-16 20:19:42.061775510 +1000
@@ -5,8 +5,8 @@
 [[ -z "$GTK3DIALOG" ]] && GTK3DIALOG=gtk3dialog
 export BGDIR="${BGDIR:-$HOME/Pictures/wallpapers/bunsen/default}"
 export PROG=${0##*\/}
-#export TEMP=/tmp/$PROG
-export TEMP=$HOME/tmp/$PROG # for testing
+export TEMP=/tmp/$PROG
+#export TEMP=$HOME/tmp/$PROG # for testing
 mkdir -p "$TEMP"
 export CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}/$PROG"
 mkdir -p "$CONFDIR"
@@ -18,8 +18,10 @@
 
 case "$1" in
 	--restore)
-	if [[ -f "$CONFDIR/cmd" ]]; then
-	. "$CONFDIR/cmd" && exit 0
+	if [[ -f "$CONFDIR/cmd" && -n "$WAYLAND_DISPLAY" ]]; then
+		. "$CONFDIR/cmd" && exit 0
+	elif [[ -x "$HOME/.fehbg" ]]; then
+		exec "$HOME/.fehbg"
 	else
 		exit 1
 	fi
@@ -291,7 +293,6 @@
 		SS='Xwset'
 		ACTION='<action>if [[ "$MODE" == "stretch" || "$MODE" == "fit" ]];then MODE=fill;fi; echo -e " --bg-$MODE '${XCOL}' \\ \n\t'\'$1\'' \\" >> '$TEMP/$SS'</action>'
 	fi
-	[[ $NUM -gt 1 ]] && XTRA='Choose output display and '
 	[[ -r "$TEMP/increment" ]] || echo -n 1 > $TEMP/increment
 	INC=$(cat $TEMP/increment)
 	# set default for entry
@@ -309,7 +310,7 @@
 	export SUBGUI='<window icon-name="background" title="Selection">
 	<vbox>
     <hbox space-expand="true" space-fill="true">
-	    <text><label>'$XTRA'Press image</label></text>
+	    <text><label>Choose Mode and press the image</label></text>
 	  </hbox>
     <hbox space-expand="true" space-fill="false">
       <text use-markup="true"><label>"<big>Mode:</big>"</label></text>

#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

#59 2024-12-19 01:44:30

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

Re: Wallpaper setter for Carbon - X11 and Wayland

(final comment on the off-topic picom corners issue)
https://github.com/yshui/picom/issues/808
It seems to be known, and fixed in ver 11+, so I expect when Debian's  11.2-0.1 gets unblocked in Testing it will be OK.
Meanwhile I'll try a backport from Sid, and if that doesn't fix the corners, well it'll be a new topic.


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

#60 2024-12-19 06:25:25

micko01
void main()
From: Queensland, Australia
Registered: 2024-04-07
Posts: 492
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

(final comment on the off-topic picom corners issue)
https://github.com/yshui/picom/issues/808
It seems to be known, and fixed in ver 11+, so I expect when Debian's  11.2-0.1 gets unblocked in Testing it will be OK.
Meanwhile I'll try a backport from Sid, and if that doesn't fix the corners, well it'll be a new topic.

Let's hope it works, and if so makes trixie!

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

Below is a <windowRule> for labwc such that all windows for xwwall are centred on screen. It goes into ~/.config/labwc/rc.xml. There may be some window rules already there.

 <windowRules>
    <windowRule identifier="background*" matchOnce="false">
      <action name="AutoPlace" policy="center"/>
    </windowRule>
    <windowRule identifier="gtk-preferences*" matchOnce="false">
      <action name="AutoPlace" policy="center"/>
    </windowRule>
 </windowRules>

I think a user would expect some consistency with the X11 variant. As far as the _splash goes in wayland, it's the only part where gtk-layer-shell is enabled. The rest uses natural windowing.

Last edited by micko01 (2024-12-19 06:36:44)


#!/bin/sh
echo '#include <stdio.h>\nvoid main() { printf("Hi, bunsenlabs\\n"); return; }' > bunsen.c
gcc bunsen.c -o bunsen
./bunsen

Offline

Board footer

Powered by FluxBB