-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathresizescreen
67 lines (54 loc) · 2.68 KB
/
resizescreen
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
#!/bin/bash
#check for dualscreen
dualscreen=$(xrandr | grep -v disconnected | grep -v VIRTUAL | grep connected | wc -l)
if [ "$dualscreen" != "1" ]
then
echo "Sorry, but xrandr scaling has trouble with multiscreen's. Thus you are unable to use this."
exit
fi
# Set the default screensize
size=25
# Grab the command options
optstr=hpvs:
while getopts $optstr var
do
case $var in
p) pause=yes ;;
v) verbose=yes ;;
s) size=$OPTARG ;;
h) echo "This is a simple script to give you a boosted virtual resolution +25% by default. IE, the max resolution for many netbook is 1024x600. With this you can "trick" it to being 1280x750 by boosting it 25%. This can make it to blurry for some, but it helps you run apps that need a higher resolution. For 1024x600, I find the sweet spot to be 35%, but everybody has different taste/eyes. It is not recommended, but you can go as high, or low if you pass a negitive number, as you want. Want 20000x20000, go for it. Don't expect to see much, but still. Go for it :).
-h This help
-p Pauses before running the command. Use with -v to see the command before it runs
-s The size to increase by in %, without the % (example -s 25). Default is 25
-v Gives more info as it runs";exit ;;
esac
done
shift $(( $OPTIND - 1 ))
#Grab the current used screen
output=$(xrandr | grep -e " connected [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
# Grabing the current X res
x=$(xrandr | grep -v connected | grep -v Screen | sed -e 's/\s\+/\n/g' | sed '/^$/d' | head -n 1 | sed -e 's/x/\n/g' | head -n 1)
# Grabing the current y res
y=$(xrandr | grep -v connected | grep -v Screen | sed -e 's/\s\+/\n/g' | sed '/^$/d' | head -n 1 | sed -e 's/x/\n/g' | tail -n 1)
# This grabs the current screensize, be it the actual size or virtual
current=$(xrandr | grep Screen | sed -e 's/\,/\n/g' | grep current | sed -e 's/ x /x/g' | sed -e 's/\s\+/\n/g' | sed '/^$/d' | grep -v current)
# Thanks to /u/Schmeidenbacher on Reddit for this. Grabs the new boosted screen size
newx=$(( $x * ( 100 + $size ) / 100 ))
newy=$(( $y * ( 100 + $size ) / 100 ))
scale=$(awk 'BEGIN{print '$newx' / '$x'}')
# This provides some feedback
if [ "$verbose" == "yes" ]
then
echo "Real Resolution - "$x"x"$y""
echo "Current Resolution - $current"
echo "New Resolution - "$newx"x"$newy""
echo "Scale - $scale"
echo "xrand command is - xrandr --output $output --mode "$x"x"$y" --panning "$newx"x"$newy" --scale "$scale"x"$scale""
fi
# Adds a pause before running the actual command.
if [ "$pause" == "yes" ]
then
read -p "Press any key to continue." -s
fi
# The actual command that boosts your screen size
xrandr --output $output --mode "$x"x"$y" --panning "$newx"x"$newy" --scale "$scale"x"$scale"