I'm working on a script for user Bob with the relevant parts shown below. Problem I'm having is if I put this cronjob under user Bob, zenity will work but shutdown wont. And if I put it under root shutdown will work but zenity won't be visible on console.
#!/bin/bash eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u Bob gnome-session)/environ)"; someValue=`DISPLAY=:0.0 zenity --text="tell me your value" --entry` ... ... /sbin/shutdown -h "now"
I also tried running under root and using su to Bob for zenity and exiting back to root to shutdown, but that didn't work.
Is there a way to do this?
OS is Linux Mint and Bob is the only user of the machine