Extended-to-duplicate monitor script without function key
up vote
0
down vote
favorite
I would like to create a bash script that allows me to:
change the mode of my screen from extended to duplicate and vice versa.
My keyboard does not have the function key and I would like to create a script that will cut me off this operation, but I do not know how to do it
Thanks a lot!
linux bash ubuntu
add a comment |
up vote
0
down vote
favorite
I would like to create a bash script that allows me to:
change the mode of my screen from extended to duplicate and vice versa.
My keyboard does not have the function key and I would like to create a script that will cut me off this operation, but I do not know how to do it
Thanks a lot!
linux bash ubuntu
See stackoverflow.com/help/how-to-ask
– oguzismail
Nov 20 at 8:11
Can you share the output of this commandxrandr --current
– ArchNoob
Nov 20 at 8:16
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to create a bash script that allows me to:
change the mode of my screen from extended to duplicate and vice versa.
My keyboard does not have the function key and I would like to create a script that will cut me off this operation, but I do not know how to do it
Thanks a lot!
linux bash ubuntu
I would like to create a bash script that allows me to:
change the mode of my screen from extended to duplicate and vice versa.
My keyboard does not have the function key and I would like to create a script that will cut me off this operation, but I do not know how to do it
Thanks a lot!
linux bash ubuntu
linux bash ubuntu
asked Nov 20 at 7:56
Gionata Donati
165
165
See stackoverflow.com/help/how-to-ask
– oguzismail
Nov 20 at 8:11
Can you share the output of this commandxrandr --current
– ArchNoob
Nov 20 at 8:16
add a comment |
See stackoverflow.com/help/how-to-ask
– oguzismail
Nov 20 at 8:11
Can you share the output of this commandxrandr --current
– ArchNoob
Nov 20 at 8:16
See stackoverflow.com/help/how-to-ask
– oguzismail
Nov 20 at 8:11
See stackoverflow.com/help/how-to-ask
– oguzismail
Nov 20 at 8:11
Can you share the output of this command
xrandr --current
– ArchNoob
Nov 20 at 8:16
Can you share the output of this command
xrandr --current
– ArchNoob
Nov 20 at 8:16
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
To formulate your bash function, you first need to know the connected screens with this command.
xrandr --current
It will show you an output similar to this
Screen 0: minimum 8 x 8, current 1600 x 900, maximum 32767 x 32767
eDP1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 380mm x 210mm
1600x900 60.04*+ 59.82 39.99
1400x900 59.96 59.88
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
800x450 60.00
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
As you can see, I have 2 outputs eDPI1
(My laptop screen) and HDMI1
my external monitor that is currently disconnected.
With these variables, I can now write a function that toggles from mirror to extend and back.
#!/bin/bash
export SCREEN_STATE="extended"
function screenToggle() {
if [[ $SCREEN_STATE == "extended" ]]; then
xrandr --output eDPI1 --output HDMI1 --same-as eDPI1
export SCREEN_STATE="mirrored"
else
xrandr --output eDPI1 --output HDMI1 --left-of eDPI1
export SCREEN_STATE="extended"
fi
}
Note that I haven't tested this code and on the first run, the displays will go to mirror mode due to the second line and you can't change that behaviour.
For more values that you may need to pass to control the resolution see man xrandr
and this similar question.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
To formulate your bash function, you first need to know the connected screens with this command.
xrandr --current
It will show you an output similar to this
Screen 0: minimum 8 x 8, current 1600 x 900, maximum 32767 x 32767
eDP1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 380mm x 210mm
1600x900 60.04*+ 59.82 39.99
1400x900 59.96 59.88
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
800x450 60.00
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
As you can see, I have 2 outputs eDPI1
(My laptop screen) and HDMI1
my external monitor that is currently disconnected.
With these variables, I can now write a function that toggles from mirror to extend and back.
#!/bin/bash
export SCREEN_STATE="extended"
function screenToggle() {
if [[ $SCREEN_STATE == "extended" ]]; then
xrandr --output eDPI1 --output HDMI1 --same-as eDPI1
export SCREEN_STATE="mirrored"
else
xrandr --output eDPI1 --output HDMI1 --left-of eDPI1
export SCREEN_STATE="extended"
fi
}
Note that I haven't tested this code and on the first run, the displays will go to mirror mode due to the second line and you can't change that behaviour.
For more values that you may need to pass to control the resolution see man xrandr
and this similar question.
add a comment |
up vote
1
down vote
accepted
To formulate your bash function, you first need to know the connected screens with this command.
xrandr --current
It will show you an output similar to this
Screen 0: minimum 8 x 8, current 1600 x 900, maximum 32767 x 32767
eDP1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 380mm x 210mm
1600x900 60.04*+ 59.82 39.99
1400x900 59.96 59.88
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
800x450 60.00
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
As you can see, I have 2 outputs eDPI1
(My laptop screen) and HDMI1
my external monitor that is currently disconnected.
With these variables, I can now write a function that toggles from mirror to extend and back.
#!/bin/bash
export SCREEN_STATE="extended"
function screenToggle() {
if [[ $SCREEN_STATE == "extended" ]]; then
xrandr --output eDPI1 --output HDMI1 --same-as eDPI1
export SCREEN_STATE="mirrored"
else
xrandr --output eDPI1 --output HDMI1 --left-of eDPI1
export SCREEN_STATE="extended"
fi
}
Note that I haven't tested this code and on the first run, the displays will go to mirror mode due to the second line and you can't change that behaviour.
For more values that you may need to pass to control the resolution see man xrandr
and this similar question.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
To formulate your bash function, you first need to know the connected screens with this command.
xrandr --current
It will show you an output similar to this
Screen 0: minimum 8 x 8, current 1600 x 900, maximum 32767 x 32767
eDP1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 380mm x 210mm
1600x900 60.04*+ 59.82 39.99
1400x900 59.96 59.88
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
800x450 60.00
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
As you can see, I have 2 outputs eDPI1
(My laptop screen) and HDMI1
my external monitor that is currently disconnected.
With these variables, I can now write a function that toggles from mirror to extend and back.
#!/bin/bash
export SCREEN_STATE="extended"
function screenToggle() {
if [[ $SCREEN_STATE == "extended" ]]; then
xrandr --output eDPI1 --output HDMI1 --same-as eDPI1
export SCREEN_STATE="mirrored"
else
xrandr --output eDPI1 --output HDMI1 --left-of eDPI1
export SCREEN_STATE="extended"
fi
}
Note that I haven't tested this code and on the first run, the displays will go to mirror mode due to the second line and you can't change that behaviour.
For more values that you may need to pass to control the resolution see man xrandr
and this similar question.
To formulate your bash function, you first need to know the connected screens with this command.
xrandr --current
It will show you an output similar to this
Screen 0: minimum 8 x 8, current 1600 x 900, maximum 32767 x 32767
eDP1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 380mm x 210mm
1600x900 60.04*+ 59.82 39.99
1400x900 59.96 59.88
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
800x450 60.00
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
As you can see, I have 2 outputs eDPI1
(My laptop screen) and HDMI1
my external monitor that is currently disconnected.
With these variables, I can now write a function that toggles from mirror to extend and back.
#!/bin/bash
export SCREEN_STATE="extended"
function screenToggle() {
if [[ $SCREEN_STATE == "extended" ]]; then
xrandr --output eDPI1 --output HDMI1 --same-as eDPI1
export SCREEN_STATE="mirrored"
else
xrandr --output eDPI1 --output HDMI1 --left-of eDPI1
export SCREEN_STATE="extended"
fi
}
Note that I haven't tested this code and on the first run, the displays will go to mirror mode due to the second line and you can't change that behaviour.
For more values that you may need to pass to control the resolution see man xrandr
and this similar question.
edited Nov 20 at 8:53
answered Nov 20 at 8:48
ArchNoob
1,0011228
1,0011228
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388510%2fextended-to-duplicate-monitor-script-without-function-key%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
See stackoverflow.com/help/how-to-ask
– oguzismail
Nov 20 at 8:11
Can you share the output of this command
xrandr --current
– ArchNoob
Nov 20 at 8:16