summaryrefslogtreecommitdiff
path: root/opera.sh
blob: f87ad7ebf6a1256fcf93cfd657a228cc586eadbd (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
#!/bin/sh

migrate_profiledir() {
	# restore location of opera dir for new opera to do automatic profile migration
	# we used to setup OPERA_PERSONALDIR to use XDG config path
	# but seems there's no way to tell new opera where to take old profile for
	# migration than it's hardcoded $HOME/.opera
	# so we move stuff back there before launching opera

	DOT_DIR="$HOME/.opera"
	XDG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/opera"

	# skip if already migrated
	if [ -e $XDG_DIR/Preferences ]; then
		return
	fi

	OPERA_PERSONALDIR=$DOT_DIR
	if [ ! -d "$OPERA_PERSONALDIR/operaprefs.ini" ]; then
		OPERA_PERSONALDIR=$XDG_DIR
	fi

	if [ "$OPERA_PERSONALDIR" = "$DOT_DIR" ]; then
		# already there
		return
	fi

	# if ~/.opera contains just OperaAutoupdateChecker.sqlite, remove it
	rm -f $DOT_DIR/OperaAutoupdateChecker.sqlite
	test -d "$DOT_DIR" && rmdir --ignore-fail-on-non-empty $DOT_DIR

	# neither dir exists, nothing to do
	if [ ! -d "$DOT_DIR" ] && [ ! -d $XDG_DIR ]; then
		return
	fi

	# if no dir, just move
	if [ ! -d "$DOT_DIR" ]; then
		mv $XDG_DIR $DOT_DIR
		return
	fi

	# may attempt to figure which dir is newer and then rename
}

migrate_profiledir

exec /usr/lib/opera/opera "$@"