Sample Header Ad - 728x90

"Unable to use GNOME Shell's builtin screenshot interface" when running cronjob

1 vote
0 answers
1112 views
I have a script that takes screenshots and saves them to a GDrive-connected folder:
#!/bin/bash
 
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
SHELL=/bin/bash
 
 
#This takes and stores the picture:
 
gnome-screenshot -f /run/user/1000/gvfs/google-drive:host=gmail.com,user=sequestranaut/0AFiS_dr3-R8XUk9PVA/1g82k8rd0L54vmYTHzrqoR_4Ys7Rg_1w1/$(date '+%e-%m-%a-%T')
 
 
#This clears the folder:
 
if [ $(ls /run/user/1000/gvfs/google-drive:host=gmail.com,user=sequestranaut/0AFiS_dr3-R8XUk9PVA/1g82k8rd0L54vmYTHzrqoR_4Ys7Rg_1w1/* 2/dev/null | wc -l) -gt 799 ] 
  then rm -f /run/user/1000/gvfs/google-drive:host=gmail.com,user=sequestranaut/0AFiS_dr3-R8XUk9PVA/1g82k8rd0L54vmYTHzrqoR_4Ys7Rg_1w1/* 
fi
I've tested the script and verified it works if launched normally from Terminal. The exit code for running it is zero, it behaves as expected when run from a shell, execute permissions exist for all users, but for some reason I can't get it to run thru crontab:
*/1 * * * /home/iain/Scripts/ScreenshotScript.sh
*/1 * * * * /home/iain/Scripts/test.sh
The other cronjob listed above works just fine. It appends the output of the date command to a text file on my Desktop with no issue, so I don't think it's an issue with crontab itself. I get an error message each time the ScreenshotScript that says this:
(gnome-screenshot:110460): GLib-GIO-CRITICAL **: 15:07:01.783:
g_dbus_connection_call_sync_internal: assertion 'G_IS_DBUS_CONNECTION
(connection)' failed
 
** Message: 15:07:01.783: Unable to use GNOME Shell's builtin screenshot interface, resorting to fallback X11.
I thought the issue was the $DISPLAY variable, so I changed that by putting this at the top of the script:
if [[ -z "$DISPLAY" ]]  
    then
    DISPLAY=":0" 
    export DISPLAY  
fi
But that didn't change anything. Furthermore, I tried running the script in X11 instead of Wayland (my current display server), but I still got the same error. Can anyone point me in the right direction?
Asked by ee_un (11 rep)
Apr 4, 2023, 03:53 PM
Last activity: Apr 4, 2023, 04:28 PM