Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

labwc test #2563

Closed
01micko opened this issue Oct 5, 2021 · 45 comments
Closed

labwc test #2563

01micko opened this issue Oct 5, 2021 · 45 comments

Comments

@01micko
Copy link
Contributor

01micko commented Oct 5, 2021

Since we have been having fun with wayland I thought I'd try labwc

Took 10 minutes to build after I figured out the root patch - same as cage.

diff -rupN labwc-orig/src/server.c labwc-1/src/server.c
--- labwc-orig/src/server.c	2021-10-05 19:14:43.483144516 +1000
+++ labwc-1/src/server.c	2021-10-05 19:50:14.253104906 +1000
@@ -64,6 +64,8 @@ handle_sigterm(int signal, void *data)
 static void
 drop_permissions(void)
 {
+	return;
+
 	if (getuid() != geteuid() || getgid() != getegid()) {
 		if (setgid(getgid())) {
 			wlr_log(WLR_ERROR, "unable to drop root group");

Runs straight from urxvt when the desktop is under cage because all the environment is set up. To run from console I'd have to hack start xwayland I suppose.

Anyway - a video!

labwc video

I now need a terminal emulator - havoc looks good.

@dimkr
Copy link
Contributor

dimkr commented Oct 5, 2021

If wlroots and labwc are built with Xwayland support, urxvt should work just fine, but then, you'd have to run labwc from a VT, without going through startxwayland.

@01micko
Copy link
Contributor Author

01micko commented Oct 5, 2021

I left off Xwayland support, on purpose - just for the exercise.

@dimkr
Copy link
Contributor

dimkr commented Oct 5, 2021

So you'll see #2560 a lot :)

I want to dedicate next week to an attempt to make Cage more similar to labwc: implement floating windows, but with JWM-like borders. When that is done, I want to get swaybg and some GTK+ 3 based panel+menu combo to work.

@dimkr
Copy link
Contributor

dimkr commented Oct 5, 2021

Does #2534 reproduce under labwc? Maybe Cage's lack of support for the pointer constraints protocol is responsible for this.

@01micko
Copy link
Contributor Author

01micko commented Oct 8, 2021

So you'll see #2560 a lot :)

I want to dedicate next week to an attempt to make Cage more similar to labwc: implement floating windows, but with JWM-like borders. When that is done, I want to get swaybg and some GTK+ 3 based panel+menu combo to work.

Running now with hacked startxwayland even though I'm running under pure wayland.

Yes that bug #2560 is persistent, apparent in geany and l3afpad. Tried the work-arounds but no go.

Does #2534 reproduce under labwc? Maybe Cage's lack of support for the pointer constraints protocol is responsible for this.

Not much of a gamer 😨 here, but I can probably test it this weekend.

@01micko
Copy link
Contributor Author

01micko commented Oct 9, 2021

Just leaving this wallpaper setter here - uses gtkdialog, wlr-randr and swaybg

Updated in below post.

20211009_21h18m19s_grim

@dimkr
Copy link
Contributor

dimkr commented Oct 9, 2021

labwc is great as reference code!

My compositor draws JWM-like borders (with pixman for gradients) and Alt-Tab works. The next step is to make the title buttons work 👍🏿

photo5985759237852215475

@dimkr
Copy link
Contributor

dimkr commented Oct 9, 2021

Close, maximize and minimize buttons work now :)

Here's Xwayland running as a window under the yet-to-be-named compositor, with JWM under Xwayland:

photo5985759237852215487

@01micko
Copy link
Contributor Author

01micko commented Oct 9, 2021

labwc is great as reference code!

Great job!

I like labwc, quite well organised IMO.

I've found a work-around, albeit very clumsy, for #2560

It involves dconf-editor which tells me that dconf doesn't know about our ptheme changes. Perhaps we can fix that programmatically instead of stumbling through the dconf-editor GUI.

20211010_08h13m28s_grim

side-note: swaybg seems awfully hungry 🤔

Also ditched havoc (buggy) and using foot. I like it 😄

@01micko
Copy link
Contributor Author

01micko commented Oct 9, 2021

I'll put this here too, syntax for moving multi monitors with wlr-randr

 wlr-randr --output DVI-D-1 --preferred --pos 0,0 --output VGA-1 --preferred --pos 1920,0

Doesn't work in my autostart config (part of labwc), too early I think so I'll make another script for that.
EDIT: I think labwc autostart only works with one command so both the swaybg call and the screen fix in a script and calling that from autostart does work.

EDIT
Might even patch labwc with a similar patch to the cage patch.

@01micko
Copy link
Contributor Author

01micko commented Oct 13, 2021

Some wayland friendly gtkdialog apps:


wwals - wayland compositor wallpaper setter

New code in post below
- supports multi monitors with separate images
- shebang now #!/bin/bash  - contains bashisms
- refactor and clean up code
- main guis  moved to functions

imgview - image viewer (part of woof and still works in X)

#!/bin/bash
# a simple image viewer using gtkdialog and bash
# (c) Mick Amadio. 01micko@gmail.com, 2019-2021, GPLv2 (/usr/share/doc/legal)

set -e
###### initiate some vars
VER=0.1
TMR=${TMR:-3000} # slideshow interval
SLIDE=${SLIDE:-false}
SCALE=${SCALE:-2} # half screen x * y .. see XTRA var
DECO=true
HINT=
export PROG="$0"
export TMP=`mktemp -d /tmp/imgXXXXXX`
if [ -d "$1" ];then
	CWD="$1"
elif [ -f "$1" ];then
	if [ "`pwd`" != "$HOME" ];then
		CWD="`pwd`"
	else
		echo "$1" | grep -q '^/' && CWD="${1%/*}"
	fi
elif [ -z "$1" ];then
	CWD="`pwd`"
fi
CONF="$HOME/.imgview.cfg"
export CWD TMR SCALE CONF SLIDE VER

MANUAL=true
[ "$SLIDE" == 'true' ] && MANUAL=false

cd "$CWD"
if [ "$XDG_SESSION_TYPE" = 'wayland' ]; then
	a=`wlr-randr | grep -m1 'preferred' | grep -o '[0-9].*px' | sed 's/ px//'`
	SCRX=${a%x*}
	SCRY=${a#*x}
else
	read DIMS SCRX SCRY ROOTVERT << EOF
	`xwininfo -root | grep ' \-geometry ' | cut -f 1 -d '+' | tr 'x' ' '`
EOF
fi

if [ $SCRX -gt $(($SCRY * 3)) ];then # pretty safe to assume dual monitors
	SCRX=$(($SCRX / 2))
fi
[ -f "$CONF" ] && . $CONF
if [ $SCALE -ge 4 ];then
	XTRA="- 125" # used if pseudo fullscreen
	DECO=false
	HINT=
	GEO="-G +1+1"
fi
VBOXX=$(($SCALE * $SCRX / 4))
VBOXY=$(($SCALE * $SCRY / 4 $XTRA))
PIXX=$(($VBOXX - 20))
PIXY=$(($VBOXY - 20))

###### functions
trap_exit() { # cleanup on exit or abort
	rm -rf "$TMP"
	cd - 2>&1 >/dev/null
}

splash() {
	echo "<window title=\"Image Viewer\">
		<vbox>
		<frame>
			<text use-markup=\"true\">
				<label>\"<span fgcolor='darkgreen'><big><big><b>$1</b></big></big></span>\"</label>
			</text>
		</frame>
		<hbox>
		<button><label>Ok</label><input file stock=\"gtk-ok\"></input></button>
		</hbox>
		</vbox>
	</window>" | gtkdialog -c -s
}
export -f splash

_help() {
	HELP="$(gettext "Invoke imgview from the commandline inside a directory
with images, or set as your default application for image viewing.
Press Forward or Back to cycle through images.
Press Play to start a slide show or Stop to stop the slide show.
When there are many images in a directory start up may be slow.
Slide show speed and window size can be set in File > Preferences")"
	gtkdialog-splash -bg "#FFD7D7" -icon gtk-help -close box -text "$HELP"
}
export -f _help

_prefs() {
	export CFG="<window title=\"Image Viewer - preferences\" icon-name=\"gtk-preferences\">
		<vbox><hbox>
			<text use-markup=\"true\">
				<label>\"<span fgcolor='darkblue'><big><big><b>Preferences for 'imgview'</b></big></big></span>\"</label>
			</text>
			</hbox>
			<hbox space-expand=\"true\" space-fill=\"false\">
			<vbox>
				<text><label>Image Scale</label></text>
				<spinbutton space-expand=\"true\" space-fill=\"false\" range-min=\"1\" range-max=\"4\" range-step=\"1\" xalign=\"1\" primary-icon-name=\"gtk-fullscreen\"
				tooltip-text=\"'2' is the default, about half-screen size. '4' is pseudo fullscreen and 1 is small\">
					<variable>scaling</variable>
					<default>$SCALE</default>
				</spinbutton>
				<text><label>Slide Show Speed</label></text>
				<spinbutton space-expand=\"true\" space-fill=\"false\" range-min=\"1000\" range-max=\"5000\" range-step=\"500\" xalign=\"1\" primary-icon-name=\"gtk-refresh\">
					<variable>speed</variable>
					<default>$TMR</default>
				</spinbutton>
				<checkbox tooltip-text=\"Start out with the Slide Show\">
					<label>Start with Slide Show</label>
					<variable>slideshow</variable>
					<default>$SLIDE</default>
				</checkbox>
			</vbox>
			</hbox>
			<hbox>
				<button><input file stock=\"gtk-cancel\"></input></button>
				<button tooltip-text=\"$(gettext 'Save configuration')\">
					<input file stock=\"gtk-save\"></input>
					<action>exit:config</action>
				</button>
			</hbox>
		</vbox>
	</window>" 
	eval $(gtkdialog -c -p CFG)
	if [ "$EXIT" = 'config' ];then
		echo SCALE=$scaling > $CONF
		echo TMR=$speed >> $CONF
		echo SLIDE=$slideshow >> $CONF
		splash "$(gettext 'The program will restart when you press OK for settings to take effect')"
		GUIPID=$(while read a;do [ "${a##* }" = 'IMGGUI' ] && echo ${a%% *};done <<<$(ps|grep IMGGUI))
		kill -9 $GUIPID 2>&1 >/dev/null && exec ${PROG##*/}
	fi
}
export -f _prefs

copy_image() { # hacky way to support webp
	OUT=$TMP/img
	IN="$1"
	case "$IN" in
		*.webp|*.WEBP|*.WebP)
			if ! which ffmpeg 2>&1 >/dev/null ;then
				echo -n "${IN##*/}" > $TMP/current.txt && return 1
			fi
			ffmpeg -hide_banner -loglevel panic -i "$IN" $TMP/img.jpg
			mv -f $TMP/img.jpg $OUT ;;
		*.svgz)zcat -c "$IN" > $OUT ;; #compressed svg
		*)
			cp "$IN" $OUT ;;
	esac
	echo -n "${IN##*/}" > $TMP/current.txt
	return 0
}
export -f copy_image

image_next() { # next image in queue, can be reversed
	x=$1
	y=1
	while true;do
		CUR=`cat $TMP/current.txt`
		CUR=${CUR##*/}
		z=0
		NUM=$(while read -r c;do z=$(($z+1));[ "$CUR" = "$c" ] && echo $z && break;done < $TMP/list.txt)
		case $x in
			0)NUM=$(($NUM - 1));;
			1)NUM=$(($NUM + 1));;
		esac
		if [ $NUM -le 0 ];then NUM=$TOT
		elif [ $NUM -gt $TOT ];then NUM=1
		fi
		NEW=`head -${NUM} $TMP/list.txt|tail -1`
		TYPE=`file -b "${CWD}/$NEW"`
		case $TYPE in
			*image*|*bitmap*)copy_image "$CWD/$NEW" || y=$(($y + 1)) # no ffmpeg
			break;;
			symbolic*)
			if file -b $(readlink "${CWD}/$NEW") | grep -qE 'image|bitmap' ;then
				copy_image "$CWD/$NEW" || y=$(($y + 1)) # no ffmpeg
				break
			fi;;
			*)case "$NEW" in 
				*.svgz)copy_image "$CWD/$NEW" || y=$(($y + 1)) # compressed svg
				break;;
			  esac
			y=$(($y + 1))
			echo -n "$NEW" > $TMP/current.txt
			if [ $y -ge 300 ];then
				splash "$(gettext "No supported file types found in a timely manner. Press OK to exit.")"
				exit
			else
				continue
			fi;;
		esac
	done
}
export -f image_next

edit_image() {
	if type gimp >/dev/null 2>&1 ; then
		gimp $CWD/`cat $TMP/current.txt` &
	else
		defaultimageeditor $CWD/`cat $TMP/current.txt` &
	fi
}
export -f edit_image

###### set up some stuff
trap trap_exit EXIT

for i in *;do [ ! -d "$i" ] && echo "$i" >> $TMP/list.txt;done
sed -i 's/^ //g' $TMP/list.txt #leading space?
cat $TMP/list.txt | wc -l > $TMP/total.txt
read TOT <$TMP/total.txt
export TOT

if [ -z "$1" -o -d "$1" ];then
	IMG0=`head -1 $TMP/list.txt`
else
	IMG0="${1##*/}"
fi
echo -n "$IMG0" > $TMP/current.txt
if [ -h "$IMG0" ];then
	file -b `readlink "$IMG0"` | grep -qE 'image|bitmap' || image_next 1
	copy_image "$IMG0"
elif file -b "$IMG0" | grep -qE 'image|bitmap';then
	copy_image "$IMG0"
elif echo "$IMG0" | grep -q '\.svgz$';then
	copy_image "$IMG0"
else
	image_next 1
fi

###### main dialog
export IMGGUI='<window title="Image Viewer" icon-name="imageview" decorated="'$DECO'" type-hint="'$HINT'">
	<vbox>
		<menubar>
			<menu>
				<menuitem stock-id="gtk-preferences">
					<action>_prefs</action>
				</menuitem>
				<menuitem auto-refresh="true" stock-id="gtk-edit">
					<action>edit_image &</action>
				</menuitem>
				<menuitem stock-id="gtk-quit">
					<action>exit:Quit</action>
				</menuitem>
				<label>'$(gettext "File")'</label>
			</menu>    
			<menu>
				<menuitem stock-id="gtk-help">
					<action>_help &</action>
				</menuitem>
				<menuitem label="_Legal" use-underline="true" icon="gtk-file">
					<action>defaultbrowser /usr/share/doc/legal/gpl-2.0.txt &</action>
				</menuitem>
				<label>'$(gettext "Help")'</label>
			</menu>    
		</menubar> 
		<vbox height-request="'$VBOXY'" width-request="'$VBOXX'">
			<pixmap>
				<height>'$PIXY'</height>
				<width>'$PIXX'</width>
				<variable>PIXMAP</variable>
				<input file>'$TMP'/img</input>
			</pixmap>
		</vbox>
		<hbox homogeneous="true">
			<text auto-refresh="true" tooltip-text="filename"><input file>'$TMP'/current.txt</input></text>
		</hbox>
		<hbox homogeneous="true">
			<hbox>
				<button tooltip-text="back or Back key on keyboard">
					<input file stock="gtk-go-back"></input>
					<variable>back</variable>
					<action>image_next 0</action>
					<action>refresh:PIXMAP</action>
					<sensitive>'$MANUAL'</sensitive>
				</button>
				<button tooltip-text="forward or Forward key on keyboard">
					<input file stock="gtk-go-forward"></input>
					<variable>forward</variable>
					<action>image_next 1</action>
					<action>refresh:PIXMAP</action>
					<sensitive>'$MANUAL'</sensitive>
				</button>
				<timer milliseconds="true" interval="'$TMR'" visible="false">
					<variable>tmr</variable>
					<action>image_next 1</action>
					<action>refresh:PIXMAP</action>
					<sensitive>'$SLIDE'</sensitive>
				</timer>
				<button tooltip-text="start slideshow or P key on keyboard">
					<input file stock="gtk-media-play"></input>
					<action>enable:tmr</action>
					<action>disable:back</action>
					<action>disable:forward</action>
				</button>
				<button tooltip-text="stop slideshow or S key on keyboard">
					<input file stock="gtk-media-stop"></input>
					<action>disable:tmr</action>
					<action>enable:back</action>
					<action>enable:forward</action>
				</button>
				<button><label>Cancel</label><input file stock="gtk-cancel"></input></button>
			</hbox>
		</hbox>
	</vbox>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Left ] && echo true)">image_next 0</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Left ] && echo true)">refresh:PIXMAP</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Right ] && echo true)">image_next 1</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Right ] && echo true)">refresh:PIXMAP</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = q ] && echo true)">exit:QUIT</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = p ] && echo true)">enable:tmr</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = p ] && echo true)">disable:back</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = p ] && echo true)">disable:forward</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = s ] && echo true)">disable:tmr</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = s ] && echo true)">enable:back</action>
	<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = s ] && echo true)">enable:forward</action>
</window>'

gtkdialog -p IMGGUI $GEO 2>&1 >/dev/null

###### end

@01micko
Copy link
Contributor Author

01micko commented Oct 15, 2021

labwc is using less resources now 😄

20211016_06h08m53s_grim

@johanmalm
Copy link

@01micko
Out of interest, are you running this on slack rather than ubuntu/debian?
I like the wwals script 😃
Screenshot taken with

grim -g "$(slurp)"

20211016_09h44m48s_grim

@dimkr
Copy link
Contributor

dimkr commented Oct 16, 2021

Great to see you here, @johanmalm! Puppy needs a Wayland replacement for JWM (https://joewing.net/projects/jwm/) and labwc is definitely the top contender.

@01micko
Copy link
Contributor Author

01micko commented Oct 16, 2021

Yes slackware64-current.

I like the wwals script

Thanks!

It needs to handle multiple monitors, that's the next thing.

@johanmalm
Copy link

Greetings to you both.

Yes - I've run both jwm and openbox over years. I like traditional stacking managers, but find mutter/kwin/etc too heavy and too dependent on their respective eco-systems.

I'm trying to just focus on the labwc "Acceptance Criteria". I suspect it'll take a long time to reach the stability of openbox, but I've used it as my daily driver for quite some time.

@johanmalm
Copy link

For wwals I had to build gtkdialog and change the path (/usr/share/backgrounds) - but otherwise it worked out of the box for me (on Arch Linux with a modest wayland setup).

@johanmalm
Copy link

It involves dconf-editor which tells me that dconf doesn't know about our ptheme changes. Perhaps we can fix that programmatically instead of stumbling through the dconf-editor GUI.

I'm not familiar with ptheme and I really don't know much about GTK theming, but found the following hack to work okay:

https://github.com/johanmalm/labwc-tweaks/blob/2f7cd9c4f84461bfb3148b73aab00560a2bdce9f/main.c#L25

@01micko
Copy link
Contributor Author

01micko commented Oct 17, 2021

@johanmalm

New code for wwals - now supporting multi monitors

At first run no need to edit the script, just run BGDIR=/path/to/wallpapers wwals

Only tested with 1 and 2 screens but should work with any number greater than 2.

I originally designed this GUI about 4 or 5 years ago when I picked up an old acer w500 iconia tablet. It worked ok with the touch interface. Only the backend has changed to suit wlroots based compositors.

It probably needs a bit more dialog for better UX, just to inform the user what is going on. Maybe one day. At the moment it does exactly what I want.


wwals

  • wayland compositor wallpaper setter
#!/bin/bash

# wayland wallpapers

# choose a wallpaper
# (c) Michael Amadio 2021 GPL (/usr/share/doc/legal)
# this changes walls for wayland wlroots compositors
# requires 'swaybg', 'wlr-randr', 'gtkdialog'

# setup config #------------------
rm -f /tmp/buttons 2>/dev/null # in case of a crash
BGDIR=${BGDIR:-/usr/share/backgrounds}
export CONFDIR=$XDG_CONFIG_HOME/wwals
[ -d "$CONFDIR" ] || mkdir -p $CONFDIR
CONF=$CONFDIR/wwals.conf
if [ ! -f "$CONF" ];then
	echo "BGDIR=$BGDIR" > $CONF
fi
. $CONF
export CMD_FILE=$CONFDIR/cmd
export BGDIR

## setup vars #------------------
a=`wlr-randr | grep -m1 'preferred' | grep -o '[0-9].*px' | sed 's/ px//'`
NUM_MONS=1
MONITOR=
# for gui on main monitor
SCRX=${a%x*}
SCRY=${a#*x}

# get number of monitors and output names
MONITORS="$(while read -r MON REST
do
	case "${MON:0:3}" in
		[0-9]*|Phy|Ena|Mod|Pos|Tra|Sca)continue;;
	esac
	echo $MON
done <<<$(printf "$(wlr-randr)"))"

echo $MONITORS
NUM_MONS=$(echo $MONITORS | wc -w)

# bail out if in portrait (tablets)
[ $SCRX -lt $SCRY ] && echo '<window  title="Background Choice" width-request="400" resizable="false">
	<vbox>
	<hbox space-expand="true" space-fill="true">
		<pixmap icon_size="6">
			<input file stock="gtk-dialog-warning"></input>
		</pixmap>
		<text space-expand="true" space-fill="true">
			<label>Please switch back into Landscape mode to choose a Wallpaper</label>
		</text>
	</hbox>
	<hbox>
		<button ok></button>
	</hbox>
	</vbox>
	</window>'|gtkdialog -s -c && exit

export W=$((7 * $SCRX / 10)) #70%
export H=$((6 * $SCRY / 10)) #60%
export PH=$(($H - 70))

## functions #------------------
set_wall() { # single wallpaper
	wall="/usr/share/backgrounds/$@"
	# build command
	printf %s "swaybg -i \"$wall\" >/dev/null 2>&1 &" > $CMD_FILE # so compositor can set bg at start up
}

set_multi() { # diferent wallpapers per monitor
	echo "$1"
	# build command
	echo -n "--output $2 -i \"$BGDIR/$1\" " >> $CMD_FILE
}

multimon() {
	export Q='<window  title="Multiple Monitors" width-request="400" resizable="false">
	<vbox>
	<hbox space-expand="true" space-fill="true">
		<pixmap icon_size="6">
			<input file stock="gtk-dialog-info"></input>
		</pixmap>
		<text space-expand="true" space-fill="true" use-markup="true">
			<label>"You have '$1' monitors connected. Would you like the same background on each of them? If you choose <b>No</b> then you will be given the option to use different backgrounds on each screen."</label>
		</text>
	</hbox>
	<hbox>
		<button yes></button><button no></button>
	</hbox>
	</vbox>
	</window>'
	eval `gtkdialog -p Q -c`
	echo $EXIT
	case $EXIT in
		Yes)return 0;;
		abort)exit 0;;
		*)return 1;;
	esac
}

button_gui() {
	# populate main gui
	WALLS=$(ls -1 $BGDIR)
	c=1
	while read WALL
	  do 
		echo '<button image-position="top" tooltip-text="Click to set '"${WALL##*/}"' as wallpaper!">
	        <label>'"$WALL"'</label>
			<variable>'"BG${c}"'</variable>
			<input file>'$BGDIR'/'"$WALL"'</input>
			<height>'$PH'</height>
			<action>'$1 "\"$WALL\"" $2'</action>
			<action type="exit">exit</action>
	      </button>' >> /tmp/buttons
	      c=$((${c}+1))
	  done <<<$WALLS
}

main_gui() {
BUTTONS=`cat /tmp/buttons`
export GUI='<window title="Background Choice '$1'">
  <hbox height-request="'$H'" width-request="'$W'">
    <hbox scrollable="true">
      '$BUTTONS'
    </hbox>
  </hbox>
</window>'
gtkdialog -p GUI -c || printf "$GUI" # printf for debug
rm -f /tmp/buttons
}

export -f set_wall
export -f set_multi
export -f multimon
export -f button_gui
export -f main_gui

# main #------------------
SET_CMD=set_wall

if [ $NUM_MONS -gt 1 ]; then
	if multimon $NUM_MONS ; then
		SET_CMD=set_multi
		echo -n 'swaybg ' > $CMD_FILE
		for MONITOR in $(echo $MONITORS); do
			button_gui $SET_CMD $MONITOR
			main_gui " - Monitor: $MONITOR"
		done
		if [ -e "$CMD_FILE" ]; then
			echo -n ' >/dev/null 2>&1 &' >> $CMD_FILE
		fi
	else
		button_gui $SET_CMD
		main_gui
	fi
else
	button_gui $SET_CMD
	main_gui
fi
if [ -e "$CMD_FILE" ]; then
	killall swaybg >/dev/null 2>&1
	. $CMD_FILE
else
	exit 1
fi
exit 0

Screenshots

20211017_19h45m57s_grim

20211017_19h46m19s_grim

20211017_19h46m57s_grim

@johanmalm
Copy link

johanmalm commented Oct 19, 2021

It's a great script. Is it worth putting it in a git repo online so that people can clone it?

I had to make the following tweaks to make it work.

@@ -63,7 +63,7 @@ export PH=$(($H - 70))
 
 ## functions #------------------
 set_wall() { # single wallpaper
-	wall="/usr/share/backgrounds/$@"
+	wall="${BGDIR}/$@"
 	# build command
 	printf %s "swaybg -i \"$wall\" >/dev/null 2>&1 &" > $CMD_FILE # so compositor can set bg at start up
 }

and

@@ -10,7 +10,7 @@
 # setup config #------------------
 rm -f /tmp/buttons 2>/dev/null # in case of a crash
 BGDIR=${BGDIR:-/usr/share/backgrounds}
-export CONFDIR=$XDG_CONFIG_HOME/wwals
+export CONFDIR=${XDG_CONFIG_HOME:-$HOME/.config}/wwals
 [ -d "$CONFDIR" ] || mkdir -p $CONFDIR
 CONF=$CONFDIR/wwals.conf
 if [ ! -f "$CONF" ];then

@01micko
Copy link
Contributor Author

01micko commented Oct 19, 2021

It's a great script. Is it worth putting it in a git repo online so that people can clone it?

Yes I think I will put it in a gist with your tweaks. I do intend to support -m, --mode in the next iteration and possibly remove external calls to sed and grep.

@01micko
Copy link
Contributor Author

01micko commented Oct 19, 2021

20211020_06h16m37s_grim

Running Yambar.

I just can't figure out how to start it on the correct screen!

I need to make sure that the cursor is at less than half my overall width.How? My overall res across both screens is 3840 x 1080.

@johanmalm
Copy link

Ah - I've discovered the same issue. It's a short-coming in the layer-shell implementation. I was trying to fix it last night but got stuck. Will be sorted 😄

@01micko
Copy link
Contributor Author

01micko commented Oct 20, 2021

@johanmalm - gist is created

EDIT: I did it the other way around - I removed non-essential externals but haven't yet implemented -m for mode.

@01micko
Copy link
Contributor Author

01micko commented Oct 22, 2021

yambar - the puppy icon is 'A' from pdingobats2 - a ding bat font I created a decade ago

20211022_22h41m45s_grim

RHS

20211022_22h42m01s_grim

@johanmalm
Copy link

I just can't figure out how to start it on the correct screen!

I have fixed a few layer-shell short-comings now.

Config file below show how to specify a monitor (eDP-1 in this example)
Get all available outputs using wlr-randr

  height: 26
  location: top
  background: 111111cc
  foreground: ffffffff
  monitor: "eDP-1"
  spacing: 5
  margin: 7

  left:
    - foreign-toplevel:
        content:
          map:
            tag: activated
            values:
              false:
                - string: {text: "{app-id}", foreground: ff000066}
              true:
                - string: {text: "{app-id}", foreground: 00ff00ff}

@johanmalm
Copy link

yambar - the puppy icon is 'A' from pdingobats2 - a ding bat font I created a decade ago

20211022_22h41m45s_grim

Would you mind sharing the config for that?

@01micko
Copy link
Contributor Author

01micko commented Oct 22, 2021

@johanmalm Not at all!

# Typical laptop setup, with wifi, brightness, battery etc, for
# i3/Sway.

# For X11/i3, you'll want to replace calls to swaymsg with i3-msg, and
# the sway-xkb module with the xkb module.

# fonts we'll be re-using here and there
awesome: &awesome Font Awesome 5 Free:style=solid:pixelsize=14
awesome_brands: &awesome_brands Font Awesome 5 Brands:pixelsize=16

std_underline: &std_underline {underline: { size: 2, color: ff0000ff}}

# This is THE bar configuration
bar:
  height: 28
  location: top
  spacing: 5
  margin: 7

  # Default font
  font: DejaVuSans:pixelsize=14

  foreground: dddddddd
  background: 11111133

  border:
    width: 1
    color: 555555cc
    margin: 5
    top-margin: 0

  left:
    - label:
        content:
          - string: { on-click: pupmenu, text: A, left-margin: 12, right-margin: 18, font: pdingobats2:pixelsize=18, foreground: ebb120dd,  deco: {background: {color: 11111133}} }
    - label:
        content:
          string:
            on-click: defaultterminal
            text: 
            left-margin: 5
            right-margin: 5
            font: *awesome
            foreground: dddddddd
            deco: {background: {color: 00000033}}
    - label:
        content:
          string:
            on-click: firefox
            text: firefox
            left-margin: 5
            right-margin: 5
            font: *awesome_brands
            foreground: dd00dddd
            deco: {background: {color: 00000033}}
    - label:
        content:
          string:
            on-click: thunar
            text: folder
            left-margin: 5
            right-margin: 5
            font: *awesome
            foreground: ffe198dd
            deco: {background: {color: 00000033}}
    - foreign-toplevel:
        content:
          map:
            tag: activated
            values:
              false: {empty: {}}
              true:
                - string: {text: "{app-id}: {title}"}

  right:
    - removables:
        anchors:
          drive: &drive { text: , font: *awesome, foreground: 3d3d3ddd}
          optical: &optical {text: , font: *awesome, foreground: bdbdbddd}
        spacing: 5
        content:
          map:
            tag: mounted
            values:
              false:
                map:
                  tag: optical
                  on-click: udisksctl mount -b {device}
                  values:
                    false: [{string: *drive}, {string: {text: "{label}"}}]
                    true: [{string: *optical}, {string: {text: "{label}"}}]
              true:
                map:
                  tag: optical
                  on-click: udisksctl unmount -b {device}
                  values:
                    false:
                      - string: {<<: *drive, deco: *std_underline}
                      - string: {text: "{label}"}
                    true:
                      - string: {<<: *optical, deco: *std_underline}
                      - string: {text: "{label}"}
    - alsa:
        card: hw:Generic
        mixer: Master
        content:
          map:
            tag: online
            values:
              false: {string: {text: , font: *awesome, foreground: ff0000ff}}
              true:
                map:
                  on-click: /bin/sh -c "amixer -q sset Speaker unmute && amixer -q sset Headphone unmute && amixer -q sset Master toggle"
                  tag: muted
                  values:
                    true: {string: {text: , font: *awesome, foreground: ffffff66}}
                    false:
                      ramp:
                        tag: volume
                        items:
                          - string: {text: , font: *awesome}
                          - string: {text: , font: *awesome}
                          - string: {text: , font: *awesome}
                          - string: {text: , font: *awesome}
                          - string: {text: , font: *awesome}
    - clock:
        time-format: "%H:%M %Z"
        content:
          - string: {text: , font: *awesome, on-click: yad --calendar, foreground: bbcfffdd}
          - string: {text: "{time}"}
    - label:
        content:
          string:
            on-click: logout_gui
            text: 
            font: *awesome
            foreground: dd0033dd

Note that there are obvious puppyisms in the onclick: calls.

Also, here is pdingobats, which includes a weather font, thermometer and other perhaps useful icons
pdingobats.zip
.

@01micko
Copy link
Contributor Author

01micko commented Oct 22, 2021

I just can't figure out how to start it on the correct screen!

I have fixed a few layer-shell short-comings now.

That at least made the bar start correctly - before it wasn't accepting mouse input.

Config file below show how to specify a monitor (eDP-1 in this example) Get all available outputs using wlr-randr

  monitor: "eDP-1"

The monitor: part is the key.

Thanks!

@dimkr
Copy link
Contributor

dimkr commented Oct 23, 2021

How hard would it be to adapt the JWM menu generator to generate a labwc menu? 🤔

If labwc can replace JWM's window management and yambar can replace the panels, the only missing piece for a pure Wayland desktop is the menu.

@01micko
Copy link
Contributor Author

01micko commented Oct 23, 2021

How hard would it be to adapt the JWM menu generator to generate a labwc menu? thinking

If labwc can replace JWM's window management and yambar can replace the panels, the only missing piece for a pure Wayland desktop is the menu.

Haha! 👅

https://github.com/johanmalm/labwc/issues/96

@johanmalm
Copy link

There is always jgmenu - although not designed for wayland. Not sure how much work is involved in supporting XGrabKeybaord() et al.

And there is https://github.com/nwg-piotr/nwg-launchers
…although I’ve not tried it for a long while.

Where is the source code for pupmenu? Is it GTK3? Is it a long-running application or do you start a new instance every time you run it?

@01micko
Copy link
Contributor Author

01micko commented Oct 23, 2021

pupmenu is a gtkdialog application developed by radky in puppy circles.

jgmenu does look interesting. I'm familiar with cairo and pango but perhaps a good alternative to pango would be dnkl's fcft.

@01micko
Copy link
Contributor Author

01micko commented Nov 6, 2021

@dimkr

submenus are working now 😸

recording.mp4

@dimkr
Copy link
Contributor

dimkr commented Nov 6, 2021

@01micko Looks great!

@01micko
Copy link
Contributor Author

01micko commented Nov 6, 2021

All the basics are pretty much in place now. Just need to develop a few user friendly apps and work on some mouse bindings for labwc and user-space should be a fairly stable experience for most.

Then I have to develop the startup/shutdown routines as well as weed out apps that simply don't work under pure wayland/wlroots.

Also, adding gtk-layer-shell to gtkdialog will be very useful.

Then, an alpha for release might be ready 🤣

@dimkr
Copy link
Contributor

dimkr commented Nov 6, 2021

Also, adding gtk-layer-shell to gtkdialog will be very useful.

I was thinking, maybe I should implement the layer shell protocol in Cage.

Then, I can write a simple GTK+ 3 panel that resembles JWM's tray (using https://github.com/wmww/gtk-layer-shell) and menu (using code borrowed from the menu generator), then replace JWM's tray and right-click menu with it.

With a setup like this, Cage will have two windows: a fullscreen Xwayland window, and a thin panel window which is always above it (a window in the overlay layer, anchored to the top, etc').

We'll be able to use this panel+menu thingy with labwc, to mimic Puppy's traditional desktop more closely.

@johanmalm
Copy link

In openbox, there is

http://openbox.org/wiki/Help:Actions#ShowMenu

which let’s the user specify the position of the menu.

@01micko
Copy link
Contributor Author

01micko commented Nov 7, 2021

Just leaving this here.

lizzy.mp4

pulsemixer

@dimkr
Copy link
Contributor

dimkr commented Nov 8, 2021

@01micko After #2610 and #2611, it should be possible to add a labwc petbuild alongside the Cage one, and start working on labwc vs. X separation (i.e. stuff like starting labwc via ~/.profile, calling .xinitrc when the compositor starts, skipping xorgwizard, fixing the graphics wizard, and so on).

There's a branch that fixes #2611, which updates wlroots to master (as of yesterday), as a placeholder for the 0.15.0 release. We can merge it now and update wlroots as needed (until the 0.15.0 release), so we can start working on integrating labwc even before the release.

@01micko
Copy link
Contributor Author

01micko commented Nov 8, 2021

I think labwc needs to be built from master as well until @johanmalm is ready to make a new release.

@dimkr
Copy link
Contributor

dimkr commented Nov 8, 2021

Also, adding gtk-layer-shell to gtkdialog will be very useful.

See https://github.com/dimkr/gtkdialog/tree/meson 😸

@dimkr dimkr mentioned this issue Nov 8, 2021
@johanmalm
Copy link

I think labwc needs to be built from master as well until @johanmalm is ready to make a new release.

Happy to upversion against a particular wlroots commit, but unless there is a particular request for it, I'll wait until wlroots 0.15.0 is released.

@01micko
Copy link
Contributor Author

01micko commented Dec 18, 2021

@dimkr @johanmalm a video of a gtkdialog menu

Limitations

  • <menu> widget must be the direct child of <menubar>
  • uses a slow find routine to find icons on first start but faster after that as the file generated is kept in /tmp. Could keep it in ~/.config/ I guess
  • generated from jwmrc and grokked out of that with mostly pure bash - as said find slows it. If I get the itch I'll code one in C and the gtkdialog could use it from stdout
  • need to press Quit if no menuitem is pressed to kill the menu.
  • puppy specific ATM
gtkdialog-menu.mp4

@01micko
Copy link
Contributor Author

01micko commented Dec 19, 2021

Discussion moved to #2617

@01micko 01micko closed this as completed Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants