mirror of
https://gitlab.com/dabruh/dotfiles.git
synced 2024-12-26 03:48:12 +01:00
Streamline monitors_exist with usb_devices_exist
This commit is contained in:
parent
f5676e638d
commit
4cac467d32
1 changed files with 10 additions and 5 deletions
|
@ -65,15 +65,20 @@ monitor_exist() {
|
|||
# monitors_exist checks if the specified monitors are connected to the system
|
||||
# $1..$n: The monitor names to search for
|
||||
monitors_exist() {
|
||||
local monitor
|
||||
local monitor matches=0
|
||||
|
||||
for monitor in "$@"; do
|
||||
if ! monitor_exist "$monitor"; then
|
||||
return 1
|
||||
if monitor_exist "$monitor"; then
|
||||
echo "$monitor"
|
||||
matches=$((matches + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Monitors exist: ${*}"
|
||||
if [ "$matches" -ne "$#" ]; then
|
||||
echo "Amount of devices does not match the amount of arguments" 1>&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -303,7 +308,7 @@ main() {
|
|||
|
||||
for monitor in "${monitors[@]}"; do
|
||||
IFS=',' read -r -a monitor_array <<<"$monitor"
|
||||
if monitors_exist "${monitor_array[@]}"; then
|
||||
if monitors_exist "${monitor_array[@]}" >/dev/null; then
|
||||
echo "Applying dock profile for ${monitor_array[*]}"
|
||||
xrandr \
|
||||
--output "${monitor_array[0]}" --mode 1920x1200 --rotate normal --pos 1200x1474 --primary \
|
||||
|
|
Loading…
Reference in a new issue