mirror of https://gitlab.com/dabruh/dotfiles.git
Cache xrandr output
This commit is contained in:
parent
1888ec9c96
commit
0cab2a6640
|
@ -4,6 +4,8 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
_monitors="" # Cache for the xrandr output
|
||||
|
||||
# Get the number of monitors connected to the system
|
||||
get_monitor_count() {
|
||||
xrandr --listmonitors | head -n1 | cut -d' ' -f2
|
||||
|
@ -16,7 +18,12 @@ get_monitor_count() {
|
|||
# HDMI-1,disconnected
|
||||
# DP-1,disconnected
|
||||
_get_monitors() {
|
||||
xrandr | grep -Eo '^.* ((dis|)connected)( primary|) ' | sed 's/ /,/g' | sed 's/,$//g'
|
||||
if [ -z "$_monitors" ]; then
|
||||
# Cache the xrandr output
|
||||
_monitors=$(xrandr | grep -Eo '^.* ((dis|)connected)( primary|) ' | sed 's/ /,/g' | sed 's/,$//g')
|
||||
fi
|
||||
|
||||
echo "$_monitors"
|
||||
}
|
||||
|
||||
# Function that gets all monitors and takes an optional amount of arguments to filter the list.
|
||||
|
|
Loading…
Reference in New Issue