This repository has been archived by the owner on May 27, 2021. It is now read-only.
/
linux
89 lines (61 loc) · 2.31 KB
/
linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
####################################################################
# PREY Alert Module Linux Functions - by Tomas Pollak (bootlog.org)
# URL : http://preyproject.com
# License: GPLv3
####################################################################
function change_wallpaper {
gconftool=`which gconftool-2`
kdesktop=`which kdesktop`
xfce=`which xfconf-query`
if [ -n "$gconftool" ]; then
wallpaper_command="$gconftool --type string --set /desktop/gnome/background/picture_filename $wallpaper"
wallpaper_command_two="$gconftool --type string --set /desktop/gnome/background/picture_options 'scaled'"
elif [ -n "$kdesktop" ]; then # untested
wallpaper_command="$kdesktop KBackgroundIface setWallpaper $wallpaper 8" # 8 = scale
elif [ -n "$xfce" ]; then # requires xfce 4.6
wallpaper_command="$xfce -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s $wallpaper"
fi
if [ -n "$wallpaper_command" ]; then
if [ `whoami` == 'root' ]; then # thanks to Rodrigo Linfati (linfati.cl) for the fix!
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID \
DBUS_SESSION_BUS_WINDOWID=$DBUS_SESSION_BUS_WINDOWID \
su $logged_user -c "$wallpaper_command"
if [ -n "$wallpaper_command_two" ]; then # couldn't find a way to run both commands as one (gconf complains with &&'s)
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID \
DBUS_SESSION_BUS_WINDOWID=$DBUS_SESSION_BUS_WINDOWID \
su $logged_user -c "$wallpaper_command_two"
fi
else
$wallpaper_command
if [ -n "$wallpaper_command_two" ]; then
$wallpaper_command_two
fi
fi
fi
}
function alert_user {
# veamos si tenemos zenity o kdialog
zenity=`which zenity`
kdialog=`which kdialog`
if [ -n "$zenity" ]; then
# shall we play with the guy?
# $zenity --question --text "Is this computer yours?"
# if [ $? = 0 ]; then
# TODO: inventar buena talla
# fi
# alert_command="$zenity --info --text"
alert_command="$zenity --error --text"
elif [ -n "$kdialog" ]; then #untested!
alert_command="$kdialog --error"
fi
if [ -n "$alert_command" ]; then
if [ `whoami` == 'root' ]; then
DISPLAY=:0 su $logged_user -c "$alert_command \"$alert_message\"" &
else
$alert_command "$alert_message" &
fi
fi
}