Created
October 26, 2023 17:06
-
-
Save naranyala/8b0c16c9e42918fc8c0fbcf5c4177c5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get a list of available resolutions using xrandr and sort them in reverse order | |
resolutions=$(xrandr | awk '/[0-9]x[0-9]/ {print $1}' | sort -n -r) | |
# Function to display resolution options using Rofi | |
select_resolution() { | |
selected_resolution=$(echo -e "$resolutions" | rofi -dmenu -p "Select a resolution:") | |
if [ -n "$selected_resolution" ]; then | |
# Change the screen resolution to the selected option | |
xrandr --output $(xrandr | grep -oP '.*(?=\sconnected)') --mode $selected_resolution | |
msg="Resolution set to $selected_resolution" | |
echo "$msg" | notify-send "display" "$msg" | |
else | |
msg="No resolution selected. Exiting." | |
echo "$msg" | notify-send "display" "$msg" | |
fi | |
} | |
# Call the function to display the resolution options | |
select_resolution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment