summarylogtreecommitdiffstats
path: root/steam-native.install
blob: e4bbef677eb0811a4d654f5fc4b0c2857b4f3fce (plain)
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
# Colored makepkg-like functions
msg_blue() {
	printf "${blue}==>${bold} $1${all_off}\n"
}

note() {
	printf "${blue}==>${yellow} NOTE:${bold} $1${all_off}\n"
}

all_off="$(tput sgr0)"
bold="${all_off}$(tput bold)"
yellow="${bold}$(tput setaf 3)"
blue="${bold}$(tput setaf 4)"

RESTART=0
#MIRROR_URL='https://www.dropbox.com/sh/xexyu68u2xnfgn6/AACEvmC_k22iLY9brSA9tgIQa'

_update() {
	update-desktop-database -q
	[ $RESTART -eq 1 ] && \
		note 'Relog or restart your system to access changes'
}

post_install() {
	if grep -q 'STEAM_RUNTIME=1' /etc/environment; then
		msg_blue 'Removing Steam runtime'
		sed -i '/STEAM_RUNTIME/d' /etc/environment
	else
		msg_blue 'No Steam runtime detected'
	fi
	if grep -q 'STEAM_RUNTIME=0' /etc/environment; then
		msg_blue 'Native runtime already set'
	else
		msg_blue 'Setting native runtime'
		echo 'STEAM_RUNTIME=0' >> /etc/environment
		RESTART=1
	fi
	if grep -q 'STEAM_FRAME_FORCE_CLOSE=1' /etc/environment; then
		msg_blue 'Close to tray already enabled'
	else
		msg_blue 'Setting close to tray'
		echo 'STEAM_FRAME_FORCE_CLOSE=1' >> /etc/environment
		RESTART=1
	fi
	_update
	#[ "$(uname -m)" == 'x86_64' ] && \
	#	note "If native isn't working try to overwrite these files to '/usr/lib32':\n\t${MIRROR_URL}"
}

post_upgrade() {
	if [ $(vercmp "$2" '1.0.0.50-12') -le 0 ]; then
		if grep -q 'LD_LIBRARY_PATH=/usr/lib' /etc/environment; then
			sed -i '/LD_LIBRARY_PATH/d' /etc/environment
			note 'Library path set by prior package version has been removed since it is not needed anymore'
			RESTART=1
		fi
	fi
	post_install "$1"
}

post_remove() {
	if grep -q 'STEAM_RUNTIME=0' /etc/environment; then
		msg_blue 'Removing native runtime'
		sed -i '/STEAM_RUNTIME/d' /etc/environment
		RESTART=1
	else
		msg_blue 'No native runtime detected'
	fi
	if grep -q 'STEAM_FRAME_FORCE_CLOSE=1' /etc/environment; then
		msg_blue 'Removing close to tray'
		sed -i '/STEAM_FRAME_FORCE_CLOSE/d' /etc/environment
		RESTART=1
	else
		msg_blue 'No close to tray detected'
	fi
	_update
	#[ "$(uname -m)" == 'x86_64' ] && \
	#	note "Don't forget to remove these if you copied them separately:\n\t${MIRROR_URL}"
}