-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale-viber
128 lines (116 loc) · 3.05 KB
/
scale-viber
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# scale-viber, (C) spiros Georgaras <[email protected]>, 2020
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Last modified: 12/02/2021 19:46:36 +0200
function print_help(){
echo "Utility to scale Viber under Linux
Usage: $(basename "$0") [OPTIONS] [Scale Factor]
Options are:
-d DESK
Location of Viber's Desktop file
Default: /usr/share/applications/viber.desktop
-p PATH
Path of Viber's executable
Default: /opt/viber/Viber
-h Print this help and exit
[Scale Factor] is 0.1 - 2.0 (zoom factor)
If [Scale Factor] is not specified, 1.2 is used
"
}
SCALE="1.2"
while [ ! -z "$1" ];do
case "$1" in
-h)
print_help
exit
;;
-d)
shift
DESK="$1"
shift
;;
-p)
shift
VIBER_COMMAND="$1"
shift
;;
*)
SCALE="$1"
shift
;;
esac
done
if [ $(id -u) != "0" ];then
print_help
echo "ERROR: You must be root to execute this script"
echo
exit 1
fi
echo -ne "Looking for Viber desktop file ... "
if [ -z "$DESK" ];then
if [ -e /usr/share/applications/viber.desktop ];then
DESK=/usr/share/applications/viber.desktop
else
echo "not found"
echo
print_help
echo "Please use -d parameter to specify it..."
exit 1
fi
else
if [ ! -e "$DESK" ];then
echo "not found"
echo
echo "Please check the value of parameter -p"
echo
exit 1
fi
fi
echo found
echo -ne "Looking for Viber executable ... "
if [ -z "$VIBER_COMMAND" ];then
if [ -e /opt/viber/Viber ];then
VIBER_COMMAND=/opt/viber/Viber
fi
else
if [ ! -e "$DESK" ];then
echo "not found"
echo
echo "Please check the value of parameter -d"
echo
exit 1
fi
fi
echo found
if [ -z "$VIBER_COMMAND" ];then
V1=$(which Viber)
V2=$(which viber)
if [ ! -z "$V1" ]; then VIBER_COMMAND="$V1";fi
if [ ! -z "$V2" ]; then VIBER_COMMAND="$V2";fi
if [ -z "$VIBER_COMMAND" ];then
echo "not found"
echo
print_help
echo "Please use -p parameter to specify it..."
exit 1
else
echo found
fi
fi
echo -ne "Alterning Desktop file ... "
sed "$DESK" -i -e '/Exec=/d'
echo "Exec=bash -c \"QT_SCALE_FACTOR=${SCALE} ${VIBER_COMMAND}\" %u" >> "$DESK"
echo "done"