BingWall icon indicating copy to clipboard operation
BingWall copied to clipboard

Is there a way to setting new daily wallpaper automatically everyday without restart linux?

Open guirahy opened this issue 1 year ago • 12 comments

Is there a way to setting new daily wallpaper automatically everyday without restart linux? I use Ubuntu 24.04.

guirahy avatar May 14 '24 00:05 guirahy

00 09 * * 1-7 env XDG_RUNTIME_DIR=/run/user/1000 bing-wall

in crontab -e each day at 9:00 but you need to close it afterwards. maybe need to use /snap/bin/bing-wall

hifron avatar Jul 24 '24 04:07 hifron

@hifron that env does not work for me. i had to copy my entire env into the crontab file to make it work. not sure which one is really making it works.

ivanjx avatar Aug 24 '24 08:08 ivanjx

00 09 * * 1-7 env XDG_RUNTIME_DIR=/run/user/1000 bing-wall

in crontab -e each day at 9:00 but you need to close it afterwards. maybe need to use /snap/bin/bing-wall

You can use bing-wall --set This will download and set the wallpaper and close the app automatically.

keshavbhatt avatar Aug 24 '24 14:08 keshavbhatt

@keshavbhatt do you know exactly which environment variables are required to make it able to run from inside crontab?

ivanjx avatar Aug 24 '24 14:08 ivanjx

@keshavbhatt do you know exactly which environment variables are required to make it able to run from inside crontab?

I dont know why we need env variables. The app executable should be callable directly. Otherwise try to run using full path like /snap/bin/bing-wall --set or snap run bing-wall --set

keshavbhatt avatar Aug 24 '24 14:08 keshavbhatt

@keshavbhatt according to this it is DBUS_SESSION_BUS_ADDRESS that is required by the gsettings program to be able to run properly from crontab.

edit: im using wayland.

ivanjx avatar Aug 24 '24 15:08 ivanjx

fix:

#!/bin/bash

export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
export QT_QPA_PLATFORM=offscreen

/snap/bin/bing-wall --set

to test: env -i thescript.sh

note: env -i resets the environment variable supplied by the gui terminal so it acts like crontab environment instead.

ivanjx avatar Aug 24 '24 15:08 ivanjx

If there is some script to delete old wallpapers in bash/powershell, it needs non-gui part of user and maybe it won't work, but not tested this way from crontab.

hifron avatar Aug 24 '24 15:08 hifron

@keshavbhatt latest update seems to partially break my script now. after setting the wallpaper, instead of immediately exiting it is stuck with this message:

Gtk-Message: 18:54:29.441: Failed to load module "canberra-gtk-module"
Gtk-Message: 18:54:29.441: Failed to load module "canberra-gtk-module"
Qt: Session management error: Could not open network socket

update: it seems that QT_QPA_PLATFORM=offscreen is being ignored in my script for some reason. this is the result of env -i thescript.sh

qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, wayland-egl, wayland, xcb.

update 2: updated my script to work with the new changes. hopefully a real solution will be found later.

#!/bin/bash

export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus

timeout 5s /snap/bin/bing-wall -platform offscreen --set

ivanjx avatar Nov 04 '24 11:11 ivanjx

update: it seems that QT_QPA_PLATFORM=offscreen is being ignored in my script for some reason. this is the result of env -i thescript.sh

Yes, you are right.

In recent update, where i migrated the application to Qt6. The application startup script sets the variable to xcb. This was done to run the app in x11 mode (xwayland) when user is on wayland session. The reason to run with xwayland is: the window decoration is not matching the system window decoration. Until that is fixed on toolkit level i decided to run the in xwayland mode.

keshavbhatt avatar Nov 04 '24 12:11 keshavbhatt

update 2: updated my script to work with the new changes. hopefully a real solution will be found later.

Ideally the app should exit after setting the wallpaper and there should be no window that should appear.

I will try to fix it in next release.

keshavbhatt avatar Nov 04 '24 12:11 keshavbhatt

00 09 * * 1-7 env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus QT_QPA_PLATFORM=xcb: /snap/bin/bing-wall -platform offscreen --set

it is possible to chain env with : before commands, but if there is command1&&command2 there couldn't be comm1&& comm2 with space before comm2 due comm2 not found

in bash it is possible to practice: DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus QT_QPA_PLATFORM=xcb: /snap/bin/bing-wall -platform offscreen --set but cron sh is more restricted, like with some XDG_RUNTIME_DIR=/run/user/1000 or maybe in .profile set some variables for QT :) but cron is distinct world even when systemd-cron in the making... with -user cron files or even

translation from user crontab to systemd for --user services, so: Space - Final Frontier

.profile (loaded on login, but maybe not for cron)

QT_QPA_PLATFORM=xcb
export QT_QPA_PLATFORM
QTWEBENGINE_DISABLE_SANDBOX=1
export QTWEBENGINE_DISABLE_SANDBOX
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment --systemd --all

update: with systemd-cron this works: 55 8 * * 1-5 env XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 audtool -1 playlist-jump 1&&env XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 audacious -p

hifron avatar Feb 08 '25 15:02 hifron