You are not logged in.

#1 2024-10-10 02:34:04

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

Wallpaper setter for Carbon - X11 and Wayland

This topic has been split from the  BunsenLabs-wayland repository thread.
We need to choose wallpaper setters for Carbon - preferably a single utility for X11 and Wayland, if that's possible.

azote wrote:

Azote is a ...frontend to the swaybg (sway/Wayland) and feh (X windows) commands.

...should work on all wlroots-based Wayland compositors, as well as on some X11 window managers.

Needs testing, but this suggests Azote might be usable in the X11 BL Carbon, as well as with Wayland. (As long as we ship feh, which is handy anyway.) The fewer cases of having different BL apps for X11 vs Wayland, the better. smile

Last edited by johnraff (2024-11-15 06:02:12)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#2 2024-10-10 05:39:22

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

Re: Wallpaper setter for Carbon - X11 and Wayland

^ yes, just tested in openbox

OB-azote-thumb.png


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

Offline

#3 2024-10-10 07:01:39

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

Re: Wallpaper setter for Carbon - X11 and Wayland

Thanks!
Sounds as if we can just replace nitrogen with azote and carry on...


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

#4 2024-10-13 15:36:17

DeepDayze
Like sands through an hourglass...
From: In Linux Land
Registered: 2017-05-28
Posts: 1,897

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

Thanks!
Sounds as if we can just replace nitrogen with azote and carry on...

Will Azote be a drop-in replacement where all you need to do is change nitrogen to azote in autostart for X11 BL sessions?


Real Men Use Linux

Offline

#5 2024-10-14 11:16:54

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

Re: Wallpaper setter for Carbon - X11 and Wayland

DeepDayze wrote:
johnraff wrote:

Thanks!
Sounds as if we can just replace nitrogen with azote and carry on...

Will Azote be a drop-in replacement where all you need to do is change nitrogen to azote in autostart for X11 BL sessions?

I would suggest that an if/else statement in autostart would be appropriate because some folk will want to stick with nitrogen I guess. Of course testing will be needed but trixe is still probably close to a year away so plenty of time.


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

Offline

#6 2024-10-15 00:15:56

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

Re: Wallpaper setter for Carbon - X11 and Wayland

^OK so let's not fix what isn't broken, and leave Nitrogen as it is on BL Boron.

But since we've got the time, why not just go to Azote for Carbon? Having only one wallpaper setting app instead of two (for X11 and Wayland) will make life a bit simpler for users and devs both.

We can still ship the standard Nitrogen config file though, just as we do for other apps no longer part of the standard BL setup, like Terminator. Could even have a commented-out section in autostart, but I'm not sure if Nitrogen has enough advantages over Azote to justify that. It will need some hands-on testing...

Last edited by johnraff (2024-10-15 00:18:07)


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

#7 2024-11-09 08:30:59

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

But since we've got the time, why not just go to Azote for Carbon? Having only one wallpaper setting app instead of two (for X11 and Wayland) will make life a bit simpler for users and devs both.

We can still ship the standard Nitrogen config file though, just as we do for other apps no longer part of the standard BL setup, like Terminator. Could even have a commented-out section in autostart, but I'm not sure if Nitrogen has enough advantages over Azote to justify that. It will need some hands-on testing...

Installed Azote from Debian Trixie yesterday on Carbon VM and was less than impressed to be honest, though the issues I found look more like packaging mistakes.

1) It's a huge install compared with Nitrogen: dependencies on 105 packages totalling 149MB!
https://packages.debian.org/trixie/azote
One of the dependencies is on libgtk-3-dev which is huge in itself:
https://packages.debian.org/trixie/libgtk-3-dev
I don't think it's right for a regular binary package to be depending on a list of *-dev packages.

2) Finally installed, it crashes with Python error No module named 'PIL'. Web-searching to find the missing package python3-pil. Install that, and this time it's Optional wlr-randr package required. Optional?? Anyway, install wlr-randr and it finally runs.
So two missing package dependencies.

The GUI wasn't especially nice  - almost half of the window is taken up by a single screen while the directory contents are squashed into the rest:
B39I8Fll.png

I suppose Azote is all there is for 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

#8 2024-11-09 12:43:00

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

I suppose Azote is all there is for Wayland?

No, but it's all debian has.

I certainly agree that it's way too heavy on deps and even then they aren't all satisfied. It's only a glorified python script! I built it in fact and only recently deleted from my repo. Here's the debian/control

Source: azote
Section: misc
Priority: optional
Maintainer: Mick Amadio <01micko@gmail.com>
Build-Depends: debhelper-compat (= 13), python3-setuptools, python3-build, python3-installer, python3-wheel, python3-all, dh-python
Standards-Version: 4.6.1
Homepage: https://github.com/nwg-piotr/azote
Rules-Requires-Root: no

Package: azote
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}, python3, python3-pil, python3-send2trash, python3-cairo, libgtk-3-0t64, swaybg, wlr-randr
Description: Azote is a GTK+3 - based picture browser and background setter
 The user interface is being developed with multi-headed setups in mind.
 Azote also includes several colour management tools.

WTF is the debian maintainer thinking when mine worked fine?

----

I made a great wallpaper setter in gtkdialog in the old puppy days and even @malm loved liked (don't want to get too cocky!) it. It could run anywhere (X or wayland).

It's been on my 'to do' to write one in C but I haven't had the time.

The old gtkdialog is kind of like yad (which incidentally got removed from testing in September) but gtkdialog has a lexer parser that processes an xml-like syntax, so very different to yad in terms of the way it's described in a shell script.

The trouble with it is that it was invented in the old GTK-1.0 days and only just made it to gtk2 before the devs gave up - as they do, IRL and all. A puppy dev named 'thunor' (an SDL game dev actually - wrote some fun ones!)  picked up dev about 10 years ago and ported it to gtk-3.0 (of which I was a very small part). But eventually he disappeared and we were left with a bunch of bitrot. When we discovered wayland (my self and my puppy bud @dimkr - github handle) we got some inspiration and added wayland support to the code base - gtk-layer-shell to be specific. @dimkr is a talented programmer but he decided he didn't have the time to fix gtkdialog, can't blame him though. The code base is huge. There are also bigger fish to fry. Also I haven't got the time or skill to fix it otherwise I would. I'll post some links later in another thread to demonstrate it's enormous potential. Any C coders looking for a project then let me know!

---

I do have a yad script for wallpapers for wayland, wrote about six months ago. Might be worth revisiting, so long as the debain/experimental  version of yad trickles down to testing soon enough.


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

Offline

#9 2024-11-09 19:04:27

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Wallpaper setter for Carbon - X11 and Wayland

For the Wayland session, why not just go with swaybg for now? It's not a GUI image picker, but it's straightforward and light.

Ol' skool Openbox users are already familiar with setting a background via autostart and feh.


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#10 2024-11-10 03:33:47

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

Re: Wallpaper setter for Carbon - X11 and Wayland

^The appeal of Azote was that it works on X too so we wouldn't need two separate apps for the same function. (I'm quite keen to keep multiplication to a minimum.)

But swaybg looks nice and small - I'll fire up my VM and try it out. Tint2 + swaybg might be a reasonable compromise.

I'll also try uninstalling libgtk-3-dev, run azote and see what breaks...

Last edited by johnraff (2024-11-10 03:34:21)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#11 2024-11-10 04:51:17

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

Re: Wallpaper setter for Carbon - X11 and Wayland

swaybg is a dependency of azote so will be there anyway.

---

I've been playing with @Hjdskes phosphorus  https://github.com/Hjdskes/phosphorus

It's unmaintained 8 years yikes but it is quality code and didn't take me a lot to get it to compile with no gcc/ld warnings.

The beauty of it is that it has a 'plugin' engine so theoretically, one could write a wayland plugin. Something about on his website - https://www.hjdskes.nl/projects/phosphorus/

That’s why Phosphorus leverages plugins for these tasks. The idea is that every Desktop Environment or every Wayland compositor has its own plugin to use its own backend. These plugins can be written either in C or in Python 3, and can be installed separately from Phosphorus.

I might fork it and have a play because there is nothing GUI out there except azote and waypaper (both python) for wayland. First thing I'll do is purge Auto tools! I'm much more comfortable with meson.


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

Offline

#12 2024-11-10 05:03:55

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

But swaybg looks nice and small - I'll fire up my VM and try it out.

It works OK though unlike tint2 after setting the wallpaper it stays running and using some memory. Not a lot, but the same as eg greetd, pipewire... Maybe Wayland doesn't allow set-and-forget for backgrounds?

Maybe a yad frontend for swaybg would be a lighter alternative to azote?

I'll also try uninstalling libgtk-3-dev, run azote and see what breaks...

Of course that doesn't work because azote depends on libgtk-3-dev and would just be uninstalled with 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 )

Introduction to the Bunsenlabs Boron Desktop

Offline

#13 2024-11-10 05:51:42

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

Maybe a yad frontend for swaybg would be a lighter alternative to azote?

Just noticed this:

Micko01 wrote:

I do have a yad script for wallpapers for wayland, wrote about six months ago. Might be worth revisiting, so long as the debain/experimental  version of yad trickles down to testing soon enough.

The yad in bookworm is 0.40.0-1+b1, experimental is 7.2, upstream is 14.1 but according to https://github.com/v1cont/yad/issues/240

0.40.0 is the LAST version to work without any major problems

A new Debian maintainer took over in May 2023 but it doesn't look as if much has been done since. Maybe they discovered the post 0.40 bugs?

Fingers crossed that something works out. Our desktop would be severely damaged without yad. I suppose we might be able to migrate back to zenity but it would be a lot of work and I fear some functionality would be lost.


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

#14 2024-11-10 06:02:13

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

Re: Wallpaper setter for Carbon - X11 and Wayland

micko01 wrote:

I've been playing with @Hjdskes phosphorus  https://github.com/Hjdskes/phosphorus

The beauty of it is that it has a 'plugin' engine so theoretically, one could write a wayland plugin. Something about on his website - https://www.hjdskes.nl/projects/phosphorus/

That looks interesting too. Jente has written a number of nice utilities to date. Cage too, is one of his.

If phosphorus is displaying backgrounds for the user to choose from then outputting a path to the chosen image file, then all that would be left for the plugin to do would be to send that info to eg swaybg, along with choices about fill/tile/etc, right? It doesn't sound that complicated. He's already provided an xlib plugin so add one for wayland and we're set.

Although it all sounds well within the range of what could be  done with yad and a bit of bash for that matter. Maybe the rendering options would complicate it a bit.


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

#15 2024-11-10 07:30:01

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:
micko01 wrote:

I've been playing with @Hjdskes phosphorus  https://github.com/Hjdskes/phosphorus

The beauty of it is that it has a 'plugin' engine so theoretically, one could write a wayland plugin. Something about on his website - https://www.hjdskes.nl/projects/phosphorus/

That looks interesting too. Jente has written a number of nice utilities to date. Cage too, is one of his.

If phosphorus is displaying backgrounds for the user to choose from then outputting a path to the chosen image file, then all that would be left for the plugin to do would be to send that info to eg swaybg, along with choices about fill/tile/etc, right? It doesn't sound that complicated. He's already provided an xlib plugin so add one for wayland and we're set.

Although it all sounds well within the range of what could be  done with yad and a bit of bash for that matter. Maybe the rendering options would complicate it a bit.

I've forked and patched so that it builds - untested as 'working'. I'll get to that.

https://github.com/01micko/phosphorus


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

Offline

#16 2024-11-11 02:55:26

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

Re: Wallpaper setter for Carbon - X11 and Wayland

^No, too much for me to update 8 year old code in phosphorus . I can build a deb just fine, a few warnings (<10) some IDK how to fix. It runs but with an empty GUI. No errors, Takes it's time to start up - searching images. Needs code to have it open only certain directories to search images.

Lets just go with a yad version. I just updated the one I have to work in X and wayland, tested on openbox and labwc.

#!/usr/bin/env bash

# (c) Copyright 2024 Mick Amadio <01micko@gmail.com> GPL3

# set the image
set_wall() {
    echo setting $1
    WALL=''
    if [[ -n "$WAYLAND_DISPLAY" ]];then
        if [[ -f "$HOME/.config/bunsen/wwall.conf" ]];then
            . $HOME/.config/bunsen/wwall.conf
		    OLDWALL=$WALL
	    fi
	else
        if [[ -f "$HOME/.config/bunsen/xwall.conf" ]];then
            . $HOME/.config/bunsen/xwall.conf
		    OLDWALL=$WALL
	    fi
	fi
	wall=${1##*/}
    oldwall=${WALL##*/}
    if [[ "$wall" == "$oldwall" ]];then
        yad --title="Icons" --window-icon=dialog-warning --name=dialog-warning \
            --image=dialog-warning --button="Ok!gtk-ok!" --text="Wallpapers are the same!" \
            >/dev/null 2>&1
        exit
    fi
    # swaybg modes: stretch, fit, fill, center, tile
    # feh modes: --bg-scale, --bg-center[ --image-bg=$color], --bg-fill, --bg-max[ --image-bg=$color], --bg-tile
    BG="--image-bg=black"
    COMMAND="$IMGV $1"
    yad --title="Confirm" --window-icon=dialog-question --name=dialog-question \
                --image=dialog-question \
                --text="Do you want to change wallpapers from $oldwall to $wall?\Choose a sizing option below." \
                --button='Stretch!!scale or stretch:2' \
                --button='Fill!!fill:3' \
                --button='Center!!center:4' \
                --button='Tile!!tile:5!' \
                --button="Preview!image-viewer!:sh -c '$COMMAND'" \
                --button='Cancel!gtk-cancel!:1' \
            >/dev/null 2>&1
    case $? in
        0);;
        1)exit;;
        2)OPT=stretch;;
        3)OPT=fill;;
        4)OPT=center;;
        5)OPT=tile;;
    esac
    # set now and write to config
    if [[ -n "$WAYLAND_DISPLAY" ]];then
        echo "WALL=$1" > $HOME/.config/bunsen/wwall.conf
        killall swaybg >/dev/null 2>&1
        swaybg -i "$1" -m "$OPT" 1>/dev/null 2>&1 &
    else
        echo "WALL=$1" > $HOME/.config/bunsen/xwall.conf
        case $OPT in
            stretch)feh --bg-scale "$1" &;;
            fill)feh --bg-fill "$1" &;;
            center)feh --bg-center --image-bg=$BG "$1" &;;
            tile)feh --bg-tile "$1" &;;
        esac
    fi
}
MSG=""
if [[ -n "$WAYLAND_DISPLAY" ]];then
    if pidof labwc >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running labwc\n"
    elif pidof sway >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running sway\n"
    else
        MSG="You are running wayland\n"
    fi
else
    if pidof openbox >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running openbox\n"
    elif pidof xfwm4 >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running xfce\n"
    else
        MSG="You are running Xorg\n"
    fi
fi

# MAIN
# kill parent if exists
read BPID b c <<<$(pidof yad)
[[ -n "$BPID" ]] && kill -KILL $BPID >/dev/null 2>&1
# set image viewer if wanted
IMGV=    ####ristretto
[[ -z "$IMGV" ]] && IMGV=bl-image-viewer
# find the image
cd $HOME/Pictures/wallpapers/wallpapers/default
OUT=$(yad --title="Wallpaper" --window-icon=preferences-desktop-wallpaper \
  --name=preferences-desktop-wallpaper --image=preferences-desktop-wallpaper \
  --width=550 --height=375 \
  --image-on-top --text="$MSG<big><big>Select a wallpaper and press OK</big></big>" \
  --file)
cd -
[[ -n "$OUT" ]] && set_wall $OUT

Probably should take out the xfce and sway test.

Features:

  • image preview - image viewer could be made configurable in the config if bl-image-viewer isn't installed.

  • Supports different modes

  • Runs in X or wayland

  • depends swaybg (wayland), feh(xorg), yad, pidof(sysv), kill(procps)

All easily availabe (except yad in testing! yad from unstable works)

Last edited by micko01 (2024-11-11 03:26:59)


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

Offline

#17 2024-11-14 07:26:53

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

Re: Wallpaper setter for Carbon - X11 and Wayland

micko01 wrote:

Lets just go with a yad version. I just updated the one I have to work in X and wayland, tested on openbox and labwc.

#!/usr/bin/env bash

# (c) Copyright 2024 Mick Amadio <01micko@gmail.com> GPL3

# set the image
set_wall() {
    echo setting $1
    WALL=''
    if [[ -n "$WAYLAND_DISPLAY" ]];then
        if [[ -f "$HOME/.config/bunsen/wwall.conf" ]];then
            . $HOME/.config/bunsen/wwall.conf
		    OLDWALL=$WALL
	    fi
	else
        if [[ -f "$HOME/.config/bunsen/xwall.conf" ]];then
            . $HOME/.config/bunsen/xwall.conf
		    OLDWALL=$WALL
	    fi
	fi
	wall=${1##*/}
    oldwall=${WALL##*/}
    if [[ "$wall" == "$oldwall" ]];then
        yad --title="Icons" --window-icon=dialog-warning --name=dialog-warning \
            --image=dialog-warning --button="Ok!gtk-ok!" --text="Wallpapers are the same!" \
            >/dev/null 2>&1
        exit
    fi
    # swaybg modes: stretch, fit, fill, center, tile
    # feh modes: --bg-scale, --bg-center[ --image-bg=$color], --bg-fill, --bg-max[ --image-bg=$color], --bg-tile
    BG="--image-bg=black"
    COMMAND="$IMGV $1"
    yad --title="Confirm" --window-icon=dialog-question --name=dialog-question \
                --image=dialog-question \
                --text="Do you want to change wallpapers from $oldwall to $wall?\Choose a sizing option below." \
                --button='Stretch!!scale or stretch:2' \
                --button='Fill!!fill:3' \
                --button='Center!!center:4' \
                --button='Tile!!tile:5!' \
                --button="Preview!image-viewer!:sh -c '$COMMAND'" \
                --button='Cancel!gtk-cancel!:1' \
            >/dev/null 2>&1
    case $? in
        0);;
        1)exit;;
        2)OPT=stretch;;
        3)OPT=fill;;
        4)OPT=center;;
        5)OPT=tile;;
    esac
    # set now and write to config
    if [[ -n "$WAYLAND_DISPLAY" ]];then
        echo "WALL=$1" > $HOME/.config/bunsen/wwall.conf
        killall swaybg >/dev/null 2>&1
        swaybg -i "$1" -m "$OPT" 1>/dev/null 2>&1 &
    else
        echo "WALL=$1" > $HOME/.config/bunsen/xwall.conf
        case $OPT in
            stretch)feh --bg-scale "$1" &;;
            fill)feh --bg-fill "$1" &;;
            center)feh --bg-center --image-bg=$BG "$1" &;;
            tile)feh --bg-tile "$1" &;;
        esac
    fi
}
MSG=""
if [[ -n "$WAYLAND_DISPLAY" ]];then
    if pidof labwc >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running labwc\n"
    elif pidof sway >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running sway\n"
    else
        MSG="You are running wayland\n"
    fi
else
    if pidof openbox >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running openbox\n"
    elif pidof xfwm4 >/dev/null >/dev/null 2>&1 ;then
        MSG="You are running xfce\n"
    else
        MSG="You are running Xorg\n"
    fi
fi

# MAIN
# kill parent if exists
read BPID b c <<<$(pidof yad)
[[ -n "$BPID" ]] && kill -KILL $BPID >/dev/null 2>&1
# set image viewer if wanted
IMGV=    ####ristretto
[[ -z "$IMGV" ]] && IMGV=bl-image-viewer
# find the image
cd $HOME/Pictures/wallpapers/wallpapers/default
OUT=$(yad --title="Wallpaper" --window-icon=preferences-desktop-wallpaper \
  --name=preferences-desktop-wallpaper --image=preferences-desktop-wallpaper \
  --width=550 --height=375 \
  --image-on-top --text="$MSG<big><big>Select a wallpaper and press OK</big></big>" \
  --file)
cd -
[[ -n "$OUT" ]] && set_wall $OUT

I just ran this on a Carbon VM and ran into a number of issues, a couple of them serious. I also have some enhancement suggestions. Should we open a new thread for this?

I could also run off an alternative, borrowing some of your code...

EDIT: first suggestion, since Nitrogen works beautifully on X, let's just keep it and make a bgsetter just for Wayland? It would simplify the code quite a bit. Maybe make a wrapper script to call Nitrogen only if running on X?

Last edited by johnraff (2024-11-14 07:47:05)


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

#18 2024-11-14 09:52:27

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

Re: Wallpaper setter for Carbon - X11 and Wayland

Somewhat stripped-down script to call from a Thunar right-click menu for image files. If on Wayland it will use Micko's set_wall function, on X11 it calls Nitrogen on the current directory. I couldn't find any way to display all the images in a directory on Wayland ala Nitrogen so thought it's easier to use Thunar's thumbnails.

#!/usr/bin/env bash

# (c) Copyright 2024 Mick Amadio <01micko@gmail.com> GPL3

# script to call from Thunar right-click "set as wallpaper" for image

# set the image
set_wall() {
    echo setting $1
    WALL=''
        if [[ -f "$HOME/.config/bunsen/wwall.conf" ]];then
        . $HOME/.config/bunsen/wwall.conf
		fi
    wall=${1##*/}
    oldwall=${WALL##*/}
    if [[ "$wall" == "$oldwall" ]];then
        yad --title="Icons" --window-icon=dialog-warning --name=dialog-warning \
            --image=dialog-warning --button="Ok!gtk-ok!" --text="Wallpapers are the same!" \
            >/dev/null 2>&1
        exit
    fi
    # swaybg modes: stretch, fit, fill, center, tile
    # feh modes: --bg-scale, --bg-center[ --image-bg=$color], --bg-fill, --bg-max[ --image-bg=$color], --bg-tile
    BG="--image-bg=black"
    yad --title="Confirm" --window-icon=dialog-question --name=dialog-question \
                --image=dialog-question \
                --text="Do you want to change wallpapers from $oldwall to $wall?\Choose a sizing option below." \
                --button='Stretch!!scale or stretch:2' \
                --button='Fill!!fill:3' \
                --button='Center!!center:4' \
                --button='Tile!!tile:5!' \
                --button="Preview!image-viewer!:sh -c '\"$IMGV\" \"$1\"'" \
                --button='Cancel!gtk-cancel!:1' \
            >/dev/null 2>&1
    case $? in
        0);;
        1)exit;;
        2)OPT=stretch;;
        3)OPT=fill;;
        4)OPT=center;;
        5)OPT=tile;;
    esac
    # set now and write to config
	echo "WALL=$1" > $HOME/.config/bunsen/wwall.conf
	killall swaybg >/dev/null 2>&1
	swaybg -i "$1" -m "$OPT" 1>/dev/null 2>&1 &
}


# MAIN
img="$1"
dir="${1%/*}"
if [[ -n "$WAYLAND_DISPLAY" ]]
then
	set_wall "$img"
else
	nitrogen "$dir"
fi

Last edited by johnraff (2024-11-18 07:03:59)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#19 2024-11-14 11:07:10

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

Re: Wallpaper setter for Carbon - X11 and Wayland

johnraff wrote:

Somewhat stripped-down script to call from a Thunar right-click menu for image files. If on Wayland it will use Micko's set_wall function, on X11 it calls Nitrogen on the current directory. I couldn't find any way to display all the images in a directory on Wayland ala Nitrogen so thought it's easier to use Thunar's thumbnails.

#!/usr/bin/env bash

# (c) Copyright 2024 Mick Amadio <01micko@gmail.com> GPL3

# script to call from Thunar right-click "set as wallpaper" for image

# set the image
set_wall() {
    echo setting $1
    WALL=''
        if [[ -f "$HOME/.config/bunsen/wwall.conf" ]];then
        . $HOME/.config/bunsen/wwall.conf
		fi
    wall=${1##*/}
    oldwall=${WALL##*/}
    if [[ "$wall" == "$oldwall" ]];then
        yad --title="Icons" --window-icon=dialog-warning --name=dialog-warning \
            --image=dialog-warning --button="Ok!gtk-ok!" --text="Wallpapers are the same!" \
            >/dev/null 2>&1
        exit
    fi
    # swaybg modes: stretch, fit, fill, center, tile
    # feh modes: --bg-scale, --bg-center[ --image-bg=$color], --bg-fill, --bg-max[ --image-bg=$color], --bg-tile
    BG="--image-bg=black"
    COMMAND="$IMGV $1"
    yad --title="Confirm" --window-icon=dialog-question --name=dialog-question \
                --image=dialog-question \
                --text="Do you want to change wallpapers from $oldwall to $wall?\Choose a sizing option below." \
                --button='Stretch!!scale or stretch:2' \
                --button='Fill!!fill:3' \
                --button='Center!!center:4' \
                --button='Tile!!tile:5!' \
                --button="Preview!image-viewer!:sh -c '$COMMAND'" \
                --button='Cancel!gtk-cancel!:1' \
            >/dev/null 2>&1
    case $? in
        0);;
        1)exit;;
        2)OPT=stretch;;
        3)OPT=fill;;
        4)OPT=center;;
        5)OPT=tile;;
    esac
    # set now and write to config
	echo "WALL=$1" > $HOME/.config/bunsen/wwall.conf
	killall swaybg >/dev/null 2>&1
	swaybg -i "$1" -m "$OPT" 1>/dev/null 2>&1 &
}


# MAIN
img="$1"
dir="${1%/*}"
if [[ -n "$WAYLAND_DISPLAY" ]]
then
	set_wall "$img"
else
	nitrogen "$dir"
fi

^Nice!

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

We really should split this out to a new thread for 2 reasons.

  1. It's off topic

  2. Nitrogen is almost dead (20210401)

The last release was 20170212

Apart from that, GTK-2.0 is very long in the tooth and some distros just aren't even bothering to ship it.


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

Offline

#20 2024-11-15 06:37:05

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

Re: Wallpaper setter for Carbon - X11 and Wayland

Nitrogen's last release was in 2017 and last commit was in 2021, but it works well as far as I can tell and handles things like multi-displays OK. New software usually brings in new bugs, I probably don't need to remind you. I think there's a good chance Nitrogen might stay usable for as long as there's an X11 version of BunsenLabs.

The same probably applies to GTK-2.0 I don't see Debian dropping it soon. Surely there are still some GTK-1 apps?

That doesn't mean I'm against moving on - just that we needn't feel obliged to shift to the newest technology. That said, the BL Wayland desktop could be a good chance to get set up with some solid foundations that won't crumble in a year or two...

So, for setting wallpapers in BL X11, I think there's a good case for staying with Nitrogen, if the alternative is having to make our own utility. If we find some pieces for Wayland that will work in X11 too, then OTOH that would be a case for making the switch.

Maybe time to look at Azote again. I plan to check once more if those dependency issues have been raised on Debian, and if not to send in bug reports. If a reasonably light Debian Azote appears then that might be the way to go for both X11 and Wayland.

If Azote just looks too unwieldy, the alternative is to carry on with a home-brewed image display + selector + swaybg utility. if all the pieces fit together nicely that might be attractive.


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

Board footer

Powered by FluxBB