~teejee2008/timeshift/trunk

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
#!/bin/bash

app_command='timeshift-gtk'

if [ `id -u` -eq 0 ]; then
	#user is admin
	${app_command}
else
	#user is not admin
	if `echo $- | grep "i" >/dev/null 2>&1`; then
		#script is running in interactive mode
		su - -c "${app_command}"
	else
		#script is running in non-interactive mode
		if command -v gksu >/dev/null 2>&1; then
			gksu ${app_command}
		elif command -v pkexec >/dev/null 2>&1; then
			pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ${app_command}
		elif command -v sudo >/dev/null 2>&1; then
			x-terminal-emulator -e "sudo ${app_command}"
		elif command -v su >/dev/null 2>&1; then
			x-terminal-emulator -e "su - -c '${app_command}'"
		else
			x-terminal-emulator -e "echo 'Command must be run as root user: ${app_command}'"
		fi
	fi
fi