๐ Help passing root password in script
๐ก Newskategorie: Linux Tipps
๐ Quelle: reddit.com
I have a script that randomly chooses a jpg file, moves it to my SDDM theme directory renaming it as background.jpg but I want to run this script upon logging out of XFCE. This is not an issue but I am prompted for a password. I'd like to do this without being prompted. Below is the script. Is this possible?
## Save all files in the array $files
files=(*)
## Get a random number between 0 (arrays start counting at 0) and the
## the number of files -1 (the last file in the array)
rand=-1
until (( $rand < ${#files[@]} && $rand >= 0 )); do rand=$RANDOM; done
## Move the file, renaming as necessary
sudo cp "${files[$rand]}" /usr/share/sddm/themes/chili/assets/background.jpg
[link] [comments] ...