Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Primtux-Eole
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Grenoble
Primtux-Eole
Commits
197c899d
Unverified
Commit
197c899d
authored
Apr 19, 2019
by
David Beniamine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect best resolution, Fix #31
parent
d4a58e35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
28 deletions
+44
-28
refreshVP.sh
refreshVP.sh
+44
-28
No files found.
refreshVP.sh
View file @
197c899d
...
...
@@ -24,6 +24,14 @@ then
export
XAUTHORITY
=
"/home/
$user
/.Xauthority"
fi
# show max between two res
max_res
(){
[
-z
"
$2
"
]
&&
echo
$1
&&
return
first
=
$(
echo
$1
|
sed
's/x/*/'
| bc
)
second
=
$(
echo
$2
|
sed
's/x/*/'
| bc
)
[
$first
-ge
$second
]
&&
echo
$1
||
echo
$2
}
# Default main screens (external VGA or internal screen)
MAIN_SCREENS
=
"DP-3 VGA-1 LVDS-1 eDP1"
...
...
@@ -49,43 +57,51 @@ screens=$(xrandr | grep " connected" | cut -f 1 -d ' ' \
# Auto detect best resolution
for
m
in
$(
xrandr |
awk
-v
pattern
=
"^
$MAIN_SCREEN
"
'/^.* connected/{IN=0} $0 ~ pattern {IN=1} /^ /{if(IN==1){print $1}}'
)
do
# echo "testing mode $m"
for
line
in
$(
xrandr |
awk
-v
pattern
=
"^
$MAIN_SCREEN
"
'/^.* connected/{IN=1} $0 ~ pattern {IN=0} {if(IN==1){print $1}}'
)
do
# echo "line $line"
if
[[
$line
=
~
[
0-9]
*
]]
then
# New mode
if
[
"
$line
"
==
"
$m
"
]
then
found
=
1
fi
else
# New screen
if
[
$found
==
0
]
then
break
fi
found
=
0
fi
# echo "Found ? $found"
done
if
[
$found
==
1
]
then
mode
=
"--mode
$m
"
break
fi
# echo "testing mode $m"
OTHERS
=
$(
xrandr |
awk
-v
pattern
=
"^
$MAIN_SCREEN
"
'/^.* connected/{IN=1} $0 ~ pattern {IN=0} {if(IN==1){print $1}}'
)
if
[
-z
"
$OTHERS
"
]
then
# one screen look for best common resolution
mode
=
$(
max_res
$m
$mode
)
else
# Several screen look for best common resolution
for
line
in
$OTHERS
do
# echo "line $line"
if
[[
$line
=
~
[
0-9]
*
]]
then
# New mode
if
[
"
$line
"
==
"
$m
"
]
then
found
=
1
fi
else
# New screen
if
[
"
$found
"
==
0
]
then
break
fi
found
=
0
fi
# echo "Found ? $found"
done
if
[
"
$found
"
==
1
]
then
mode
=
"
$m
"
break
fi
fi
done
# echo "mode $mode"
# Primary screen
cmd
=
"xrandr --output
$MAIN_SCREEN
--auto
$mode
--rotate normal --primary"
cmd
=
"xrandr --output
$MAIN_SCREEN
--auto
--mode
$mode
--rotate normal --primary"
# Add all connected as copy
prev_s
=
$MAIN_SCREEN
for
s
in
$(
echo
-e
$screens
)
do
cmd
=
"
$cmd
--output
$s
--auto
$mode
--same-as
$prev_s
--rotate normal"
cmd
=
"
$cmd
--output
$s
--auto
--mode
$mode
--same-as
$prev_s
--rotate normal"
prev_s
=
"
$s
"
done
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment