Is there a way to setting new daily wallpaper automatically everyday without restart linux?
Is there a way to setting new daily wallpaper automatically everyday without restart linux? I use Ubuntu 24.04.
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 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.
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 do you know exactly which environment variables are required to make it able to run from inside crontab?
@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 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.
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.
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.
@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
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.
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.
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