37 lines
1.4 KiB
Bash
Executable File
37 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
#########################################################################################
|
|
# Shellscript : set Desktop by desktoppr
|
|
# Autor : Andreas Vogel, nextenterprise gmbh
|
|
#########################################################################################
|
|
# set -x
|
|
######################### Variablen #####################################################
|
|
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
|
picture_path="/usr/local/Desktop_background/2560x1600_Macbook_A.jpg"
|
|
loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
|
|
desktoppr="/usr/local/bin/desktoppr"
|
|
|
|
if [ ! -x "$desktoppr" ]; then
|
|
echo "cannot find desktoppr at $desktoppr, exiting"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# test if a user is logged in
|
|
if [ -n "$loggedInUser" ]
|
|
then
|
|
uid=$(id -u "$loggedInUser")
|
|
echo "running $desktoppr $picture_path as user"
|
|
launchctl asuser "$uid" sudo -u "$loggedInUser" "$desktoppr" "$picture_path"
|
|
current_picture_path=$(desktoppr)
|
|
|
|
if [[ $current_picture_path != $picture_path ]]
|
|
then
|
|
echo "Picture Path is not correct. Try change again."
|
|
launchctl asuser "$uid" sudo -u "$loggedInUser" "$desktoppr" "$picture_path"
|
|
else
|
|
echo "Picture Path is correct"
|
|
exit 0
|
|
fi
|
|
else
|
|
echo "no user logged in, no desktop set"
|
|
fi |