Skip to content

Commit

Permalink
Merge pull request #1 from speediegq/main
Browse files Browse the repository at this point in the history
Add custom resolution option and some modifications
  • Loading branch information
GabubuAvailable authored May 21, 2022
2 parents 089bf42 + 8a8f358 commit af179d8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;)

Expand Down
48 changes: 25 additions & 23 deletions ddisplay
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,41 @@
############################### 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
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 ' ' | 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
}

# Mirror resolutions
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\nExit" | dmenu -b -l 6 -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
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 ;;
"Custom Resolution") CUSTOMRES ;;
"Exit") exit 0 ;;
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 $REFRESH --mode $RESOLUTION --fb $RESOLUTION --panning $RESOLUTION --output $SECONDARY --off && xrandr --output $SECONDARY --off --right-of $PRIMARY ;;
"Exit") exit 0 ;;
esac

exit 0

0 comments on commit af179d8

Please sign in to comment.