From 7e93aeae3e61300f0dedc65c26549a745f09c09b Mon Sep 17 00:00:00 2001 From: speedie <71722170+speediegq@users.noreply.github.com> Date: Wed, 18 May 2022 14:39:37 -0700 Subject: [PATCH 1/6] Add custom resolution option Currently untested but added custom resolution option --- ddisplay | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ddisplay b/ddisplay index 8daa294..bdc0bd5 100644 --- a/ddisplay +++ b/ddisplay @@ -11,7 +11,7 @@ RESOLUTION="$(printf 'HERE')" # Your native resolution for the primary displa MIRROR() { # Asking for the resolution -MIRROR=$(printf "4K UHD\n1080p\n720p\n480p\nNah I give up" | dmenu -b -l 5 -p "Choose the resolution.") +MIRROR=$(printf "4K UHD\n1080p\n720p\n480p\nCustom Resolution\nNah I give up" | dmenu -b -l 5 -p "Choose the resolution.") if [ "$MIRROR" = "4K UHD" ]; then xrandr --output $PRIMARY --rate 60 --mode 3840×2160 --fb 3840×2160 --panning 3840×2160 --output $SECONDARY --rate 60 --mode 3840×2160 --same-as $PRIMARY @@ -23,6 +23,9 @@ elif [ "$MIRROR" = "480p" ]; then xrandr --output $PRIMARY --rate 60 --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate 60 --mode 640x480 --same-as $PRIMARY elif [ "$MIRROR" = "Exit" ]; then exit 0 +elif [ "$MIRROR" = "Custom Resolution" ]; then +CRES=$(printf "Enter a resolution. Example: 1920x1080" | dmenu -g 1 -b -l 1 -p 'Enter a resolution.') +xrandr --output $PRIMARY --rate 60 --mode $CRES --fb $CRES --panning $CRES --output $SECONDARY --rate 60 --mode $CRES --same-as $PRIMARY fi exit 0 } From 52112c75578123efc88e6f0b8f6bd0023464a827 Mon Sep 17 00:00:00 2001 From: speedie <71722170+speediegq@users.noreply.github.com> Date: Wed, 18 May 2022 14:46:26 -0700 Subject: [PATCH 2/6] Replace if statements with case, applies on top of my previous commit --- ddisplay | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/ddisplay b/ddisplay index bdc0bd5..329c348 100644 --- a/ddisplay +++ b/ddisplay @@ -11,35 +11,25 @@ RESOLUTION="$(printf 'HERE')" # Your native resolution for the primary displa MIRROR() { # Asking for the resolution -MIRROR=$(printf "4K UHD\n1080p\n720p\n480p\nCustom Resolution\nNah I give up" | dmenu -b -l 5 -p "Choose the resolution.") +MIRROR=$(printf "4K UHD\n1080p\n720p\n480p\nCustom Resolution\nExit" | dmenu -b -l 5 -p "Choose the resolution.") -if [ "$MIRROR" = "4K UHD" ]; then -xrandr --output $PRIMARY --rate 60 --mode 3840×2160 --fb 3840×2160 --panning 3840×2160 --output $SECONDARY --rate 60 --mode 3840×2160 --same-as $PRIMARY -elif [ "$MIRROR" = "1080p" ]; then -xrandr --output $PRIMARY --rate 60 --mode 1920x1080 --fb 1920x1080 --panning 1920x1080 --output $SECONDARY --rate 60 --mode 1920x1080 --same-as $PRIMARY -elif [ "$MIRROR" = "720p" ]; then -xrandr --output $PRIMARY --rate 60 --mode 1280x720 --fb 1280x720 --panning 1280x720 --output $SECONDARY --rate 60 --mode 1280x720 --same-as $PRIMARY -elif [ "$MIRROR" = "480p" ]; then -xrandr --output $PRIMARY --rate 60 --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate 60 --mode 640x480 --same-as $PRIMARY -elif [ "$MIRROR" = "Exit" ]; then -exit 0 -elif [ "$MIRROR" = "Custom Resolution" ]; then -CRES=$(printf "Enter a resolution. Example: 1920x1080" | dmenu -g 1 -b -l 1 -p 'Enter a resolution.') -xrandr --output $PRIMARY --rate 60 --mode $CRES --fb $CRES --panning $CRES --output $SECONDARY --rate 60 --mode $CRES --same-as $PRIMARY -fi -exit 0 -} +case "$MIRROR" in +"4K UHD") xrandr --output $PRIMARY --rate 60 --mode 3840×2160 --fb 3840×2160 --panning 3840×2160 --output $SECONDARY --rate 60 --mode 3840×2160 --same-as $PRIMARY ;; +"1080p") xrandr --output $PRIMARY --rate 60 --mode 1920x1080 --fb 1920x1080 --panning 1920x1080 --output $SECONDARY --rate 60 --mode 1920x1080 --same-as $PRIMARY ;; +"720p") xrandr --output $PRIMARY --rate 60 --mode 1280x720 --fb 1280x720 --panning 1280x720 --output $SECONDARY --rate 60 --mode 1280x720 --same-as $PRIMARY ;; +"480p") xrandr --output $PRIMARY --rate 60 --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate 60 --mode 640x480 --same-as $PRIMARY ;; +"Exit") exit 0 ;; +"Custom Resolution") CRES=$(printf "Enter a resolution. Example: 1920x1080" | dmenu -g 1 -b -l 1 -p 'Enter a resolution.') && xrandr --output $PRIMARY --rate 60 --mode $CRES --fb $CRES --panning $CRES --output $SECONDARY --rate 60 --mode $CRES --same-as $PRIMARY ;; +esac # Asking what you want to do ACTION=$(printf "Mirror\nExternal\nDisconnect\nExit" | dmenu -b -l 5 -p "What do you want to do with your cool monitor?") -if [ "$ACTION" = "Mirror" ]; then -MIRROR -elif [ "$ACTION" = "External" ]; then -xrandr --output $SECONDARY --auto --right-of $PRIMARY -elif [ "$ACTION" = "Disconnect" ]; then -xrandr --output $PRIMARY --rate 60 --mode $RESOLUTION --fb $RESOLUTION --panning $RESOLUTION --output $SECONDARY --off && xrandr --output $SECONDARY --off --right-of $PRIMARY -elif [ "$ACTION" = "Exit" ]; then -exit 0 -fi +case "$ACTION" in +"Mirror") MIRROR ;; +"External") xrandr --output $SECONDARY --auto --right-of $PRIMARY ;; +"Disconnect") xrandr --output $PRIMARY --rate 60 --mode $RESOLUTION --fb $RESOLUTION --panning $RESOLUTION --output $SECONDARY --off && xrandr --output $SECONDARY --off --right-of $PRIMARY ;; +"Exit") exit 0 ;; +esac + exit 0 From f0168ab15c7c1441a045157645eb551c29310f36 Mon Sep 17 00:00:00 2001 From: speedie <71722170+speediegq@users.noreply.github.com> Date: Sat, 21 May 2022 08:29:55 -0700 Subject: [PATCH 3/6] fix a few bugs --- ddisplay | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ddisplay b/ddisplay index 329c348..68d814f 100644 --- a/ddisplay +++ b/ddisplay @@ -7,6 +7,12 @@ SECONDARY="$(printf 'HERE')" # Choose your connected display (again, xrandr RESOLUTION="$(printf 'HERE')" # Your native resolution for the primary display ################################################################################################### +# Custom resolution +CUSTOMRES() { +CRES=$(printf "Enter a resolution. Example: 1920x1080" | dmenu -g 1 -b -l 1 -p 'Enter a resolution.') +xrandr --output $PRIMARY --rate 60 --mode $CRES --fb 640x480 --panning $CRES --output $SECONDARY --rate 60 --mode $CRES --same-as $PRIMARY +} + # Mirror resolutions MIRROR() { @@ -19,8 +25,9 @@ case "$MIRROR" in "720p") xrandr --output $PRIMARY --rate 60 --mode 1280x720 --fb 1280x720 --panning 1280x720 --output $SECONDARY --rate 60 --mode 1280x720 --same-as $PRIMARY ;; "480p") xrandr --output $PRIMARY --rate 60 --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate 60 --mode 640x480 --same-as $PRIMARY ;; "Exit") exit 0 ;; -"Custom Resolution") CRES=$(printf "Enter a resolution. Example: 1920x1080" | dmenu -g 1 -b -l 1 -p 'Enter a resolution.') && xrandr --output $PRIMARY --rate 60 --mode $CRES --fb $CRES --panning $CRES --output $SECONDARY --rate 60 --mode $CRES --same-as $PRIMARY ;; +"Custom Resolution") CUSTOMRES esac +} # Asking what you want to do ACTION=$(printf "Mirror\nExternal\nDisconnect\nExit" | dmenu -b -l 5 -p "What do you want to do with your cool monitor?") From ab2a4a7fcffc3663f333f61bcba300a3dcaf803f Mon Sep 17 00:00:00 2001 From: speedie <71722170+speediegq@users.noreply.github.com> Date: Sat, 21 May 2022 08:33:15 -0700 Subject: [PATCH 4/6] add refresh rate option since not everyone has a 60hz monitor & fixed typo --- ddisplay | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ddisplay b/ddisplay index 68d814f..e9d71c6 100644 --- a/ddisplay +++ b/ddisplay @@ -3,14 +3,15 @@ ############################### SETTINGS (EDIT THEM) ############################################## PRIMARY="$(printf 'HERE')" # Choose your correct primary display (use xrandr for more info) -SECONDARY="$(printf 'HERE')" # Choose your connected display (again, xrandr for more info)) +SECONDARY="$(printf 'HERE')" # Choose your connected display (again, xrandr for more info) RESOLUTION="$(printf 'HERE')" # Your native resolution for the primary display ################################################################################################### # Custom resolution CUSTOMRES() { CRES=$(printf "Enter a resolution. Example: 1920x1080" | dmenu -g 1 -b -l 1 -p 'Enter a resolution.') -xrandr --output $PRIMARY --rate 60 --mode $CRES --fb 640x480 --panning $CRES --output $SECONDARY --rate 60 --mode $CRES --same-as $PRIMARY +CREF=$(printf "Enter a refresh rate. Example: 60" | dmenu -g 1 -b -l 1 -p 'Enter a refresh rate.') +xrandr --output $PRIMARY --rate $CREF --mode $CRES --fb $CRES --panning $CRES --output $SECONDARY --rate $CREF --mode $CRES --same-as $PRIMARY } # Mirror resolutions @@ -18,12 +19,13 @@ MIRROR() { # Asking for the resolution MIRROR=$(printf "4K UHD\n1080p\n720p\n480p\nCustom Resolution\nExit" | dmenu -b -l 5 -p "Choose the resolution.") +CREF=$(printf "Enter a refresh rate. Example: 60" | dmenu -g 1 -b -l 1 -p 'Enter a refresh rate.') case "$MIRROR" in -"4K UHD") xrandr --output $PRIMARY --rate 60 --mode 3840×2160 --fb 3840×2160 --panning 3840×2160 --output $SECONDARY --rate 60 --mode 3840×2160 --same-as $PRIMARY ;; -"1080p") xrandr --output $PRIMARY --rate 60 --mode 1920x1080 --fb 1920x1080 --panning 1920x1080 --output $SECONDARY --rate 60 --mode 1920x1080 --same-as $PRIMARY ;; -"720p") xrandr --output $PRIMARY --rate 60 --mode 1280x720 --fb 1280x720 --panning 1280x720 --output $SECONDARY --rate 60 --mode 1280x720 --same-as $PRIMARY ;; -"480p") xrandr --output $PRIMARY --rate 60 --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate 60 --mode 640x480 --same-as $PRIMARY ;; +"4K UHD") xrandr --output $PRIMARY --rate $CREF --mode 3840×2160 --fb 3840×2160 --panning 3840×2160 --output $SECONDARY --rate $CREF --mode 3840×2160 --same-as $PRIMARY ;; +"1080p") xrandr --output $PRIMARY --rate $CREF --mode 1920x1080 --fb 1920x1080 --panning 1920x1080 --output $SECONDARY --rate $CREF --mode 1920x1080 --same-as $PRIMARY ;; +"720p") xrandr --output $PRIMARY --rate $CREF --mode 1280x720 --fb 1280x720 --panning 1280x720 --output $SECONDARY --rate $CREF --mode 1280x720 --same-as $PRIMARY ;; +"480p") xrandr --output $PRIMARY --rate $CREF --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate $CREF --mode 640x480 --same-as $PRIMARY ;; "Exit") exit 0 ;; "Custom Resolution") CUSTOMRES esac @@ -35,7 +37,7 @@ ACTION=$(printf "Mirror\nExternal\nDisconnect\nExit" | dmenu -b -l 5 -p "What do case "$ACTION" in "Mirror") MIRROR ;; "External") xrandr --output $SECONDARY --auto --right-of $PRIMARY ;; -"Disconnect") xrandr --output $PRIMARY --rate 60 --mode $RESOLUTION --fb $RESOLUTION --panning $RESOLUTION --output $SECONDARY --off && xrandr --output $SECONDARY --off --right-of $PRIMARY ;; +"Disconnect") xrandr --output $PRIMARY --rate $REF --mode $RESOLUTION --fb $RESOLUTION --panning $RESOLUTION --output $SECONDARY --off && xrandr --output $SECONDARY --off --right-of $PRIMARY ;; "Exit") exit 0 ;; esac From 0102b9442ca02d04e6cade8ae2cf7968a68b90f5 Mon Sep 17 00:00:00 2001 From: Gabubu <88589756+GabubuAvailable@users.noreply.github.com> Date: Sat, 21 May 2022 16:36:00 +0000 Subject: [PATCH 5/6] modifications + added refresh rate etc... --- ddisplay | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ddisplay b/ddisplay index e9d71c6..7026196 100644 --- a/ddisplay +++ b/ddisplay @@ -3,14 +3,15 @@ ############################### SETTINGS (EDIT THEM) ############################################## PRIMARY="$(printf 'HERE')" # Choose your correct primary display (use xrandr for more info) -SECONDARY="$(printf 'HERE')" # Choose your connected display (again, xrandr for more info) -RESOLUTION="$(printf 'HERE')" # Your native resolution for the primary display +SECONDARY="$(printf 'HERE')" # Choose your connected display (again, xrandr for more info)) +RESOLUTION="$(printf 'HERE')" # Your native resolution for the primary display (ie. 1920x1080) +REFRESH="$(printf 'HERE')" # Your native refresh rate for the primary display (ie. 60) ################################################################################################### # Custom resolution CUSTOMRES() { -CRES=$(printf "Enter a resolution. Example: 1920x1080" | dmenu -g 1 -b -l 1 -p 'Enter a resolution.') -CREF=$(printf "Enter a refresh rate. Example: 60" | dmenu -g 1 -b -l 1 -p 'Enter a refresh rate.') +CRES=$(printf ' ' | dmenu -b -l 0 -p 'Enter a resolution (ie. 1920x1080): ') +CREF=$(printf ' ' | dmenu -b -l 0 -p 'Enter a refresh rate (ie. 60): ') xrandr --output $PRIMARY --rate $CREF --mode $CRES --fb $CRES --panning $CRES --output $SECONDARY --rate $CREF --mode $CRES --same-as $PRIMARY } @@ -18,16 +19,15 @@ xrandr --output $PRIMARY --rate $CREF --mode $CRES --fb $CRES --panning $CRES -- MIRROR() { # Asking for the resolution -MIRROR=$(printf "4K UHD\n1080p\n720p\n480p\nCustom Resolution\nExit" | dmenu -b -l 5 -p "Choose the resolution.") -CREF=$(printf "Enter a refresh rate. Example: 60" | dmenu -g 1 -b -l 1 -p 'Enter a refresh rate.') +MIRROR=$(printf "4K UHD\n1080p\n720p\n480p\nCustom Resolution\nExit" | dmenu -b -l 6 -p "Choose the resolution.") case "$MIRROR" in -"4K UHD") xrandr --output $PRIMARY --rate $CREF --mode 3840×2160 --fb 3840×2160 --panning 3840×2160 --output $SECONDARY --rate $CREF --mode 3840×2160 --same-as $PRIMARY ;; -"1080p") xrandr --output $PRIMARY --rate $CREF --mode 1920x1080 --fb 1920x1080 --panning 1920x1080 --output $SECONDARY --rate $CREF --mode 1920x1080 --same-as $PRIMARY ;; -"720p") xrandr --output $PRIMARY --rate $CREF --mode 1280x720 --fb 1280x720 --panning 1280x720 --output $SECONDARY --rate $CREF --mode 1280x720 --same-as $PRIMARY ;; -"480p") xrandr --output $PRIMARY --rate $CREF --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate $CREF --mode 640x480 --same-as $PRIMARY ;; +"4K UHD") xrandr --output $PRIMARY --rate 60 --mode 3840×2160 --fb 3840×2160 --panning 3840×2160 --output $SECONDARY --rate 60 --mode 3840×2160 --same-as $PRIMARY ;; +"1080p") xrandr --output $PRIMARY --rate 60 --mode 1920x1080 --fb 1920x1080 --panning 1920x1080 --output $SECONDARY --rate 60 --mode 1920x1080 --same-as $PRIMARY ;; +"720p") xrandr --output $PRIMARY --rate 60 --mode 1280x720 --fb 1280x720 --panning 1280x720 --output $SECONDARY --rate 60 --mode 1280x720 --same-as $PRIMARY ;; +"480p") xrandr --output $PRIMARY --rate 60 --mode 640x480 --fb 640x480 --panning 640x480 --output $SECONDARY --rate 60 --mode 640x480 --same-as $PRIMARY ;; +"Custom Resolution") CUSTOMRES ;; "Exit") exit 0 ;; -"Custom Resolution") CUSTOMRES esac } @@ -37,7 +37,7 @@ ACTION=$(printf "Mirror\nExternal\nDisconnect\nExit" | dmenu -b -l 5 -p "What do case "$ACTION" in "Mirror") MIRROR ;; "External") xrandr --output $SECONDARY --auto --right-of $PRIMARY ;; -"Disconnect") xrandr --output $PRIMARY --rate $REF --mode $RESOLUTION --fb $RESOLUTION --panning $RESOLUTION --output $SECONDARY --off && xrandr --output $SECONDARY --off --right-of $PRIMARY ;; +"Disconnect") xrandr --output $PRIMARY --rate $REFRESH --mode $RESOLUTION --fb $RESOLUTION --panning $RESOLUTION --output $SECONDARY --off && xrandr --output $SECONDARY --off --right-of $PRIMARY ;; "Exit") exit 0 ;; esac From 8a8f3587ab98265cb2d369edd48d04c0deaf4786 Mon Sep 17 00:00:00 2001 From: Gabubu <88589756+GabubuAvailable@users.noreply.github.com> Date: Sat, 21 May 2022 16:47:19 +0000 Subject: [PATCH 6/6] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3fcb874..61c8eb2 100644 --- a/README.md +++ b/README.md @@ -2,30 +2,30 @@ A dmenu script for connecting your external monitor ## What ddisplay is? -Is a dmenu script that helps you to connect your external monitor/tv/video projector to your bare metal +It's a dmenu script that helps you to connect your external monitor/tv/video projector to your bare metal ## How can I install it? 1: Download the "ddisplay" file (it would be available on releases too) 2: Open your text editor and load the file -3: Edit these 3 lines. +3: Edit these 4 lines. -![image](https://user-images.githubusercontent.com/88589756/168911425-d4cb9aa4-3abd-4973-8ac5-68d5385dfce5.png) +![image](https://user-images.githubusercontent.com/88589756/169661028-d7d3e300-e415-4fe2-bd06-b9a385cfe9d9.png) -You don't know what should you type there? Connect your external monitor, open the terminal and type `xrandr`. It would show something like this: +You don't know what you should type there? Connect your external monitor, open the terminal and then type `xrandr`. It would show something like this: ![image](https://user-images.githubusercontent.com/88589756/168911787-a452a1fa-72ac-4234-a25f-1968384ac360.png) According to this, you'll find everything you need: -![image](https://user-images.githubusercontent.com/88589756/168912453-47417863-5749-4f9d-913e-a63ece5f09d9.png) +![image](https://user-images.githubusercontent.com/88589756/169661208-925174ea-1b2f-452f-92a7-c5b1b2bee7cf.png) Like that: -![image](https://user-images.githubusercontent.com/88589756/168913090-0921d752-173b-47a6-b3f0-34e6d8044c15.png) +![image](https://user-images.githubusercontent.com/88589756/169661308-9525d293-5a24-44d6-88b9-80bf130614b8.png) -4: Save the file, and `chmod +x ./ddisplay` and `doas (or replace doas with sudo) cp ./ddisplay /bin/ddisplay` +4: Save the file, and `chmod +x ./ddisplay` and `doas (sudo) cp ./ddisplay /bin/ddisplay` 5: Enjoy connecting your cool monitor/tv/video projector ;)