Score:0

Set display mode via command line

ga flag

How can I set the display mode to "mirror" in a bash script? (Without using the GUI gnome settings). And only once (not everytime a new display is attached)

Edit I got a suggestion to use xrandr "same-as" argument (How to enable "mirror" feature in the display settings using command line?). Thanks for that. But the problem with that solution is that it needs to be done each time a display is attached. I need the "mirror" option to be the default action when attaching a new display. We basically provide devices to a client, but if the client attaches multiple displays, he/she shouldn't need to execute anything. We actually got it working that way on Xubuntu 18.04 (Xfce), but I have no idea if that's default behavior or not.

Display Mode

Artur Meinild avatar
vn flag
If the existing answer isn't sufficient, another possible solution should rather be added to the [existing thread on the same topic](https://askubuntu.com/questions/461553/how-to-enable-mirror-feature-in-the-display-settings-using-command-line).
BeastOfCaerbannog avatar
ca flag
Have a look at the suggestions in this thread: [Run script when monitor is connected](https://askubuntu.com/questions/630202/run-script-when-monitor-is-connected)
Levente avatar
cn flag
@ArturMeinild I am not sure but there might be a trick here? Up until 20.04 we could safely assume that Xorg will be the display server, so answers pointing to the very versatile and helpful `xrandr` command were reliable. But 22.04 comes by default with Wayland. I would be surprised if xrandr worked on Wayland, as it appears to be specific to Xorg... So, does xrandr work on Wayland? If not, then does Wayland has an equivalent thing?
Levente avatar
cn flag
@OP are you using Xorg as display server? It's highly relevant to the correct answer. Your account seems to suggest that you could execute the xrandr command with success and the desired effect? It would worth clarifying then that you use Xorg.
fre_der avatar
ga flag
@Levente: we indeed disabled Wayland because of other issues.
fre_der avatar
ga flag
I was actually looking for a setting (in Gnome, Ubuntu) that would just change the default behavior of newly attached displays to just "mirror" instead of "extend", just like Xubuntu 18.04. But I guess I'll have to live with the fact that this is no longer possible, and build a scripted solution based on the suggestions
BeastOfCaerbannog avatar
ca flag
Does this answer your question? [make mirroring displays the default in gnome](https://askubuntu.com/questions/1427414/make-mirroring-displays-the-default-in-gnome)
NotTheDr01ds avatar
vn flag
Does this answer your question? [make mirroring displays the default in gnome](https://askubuntu.com/questions/1427414/make-mirroring-displays-the-default-in-gnome)
fre_der avatar
ga flag
I already switched back to Xubuntu, not only for this but also for other issues (https://askubuntu.com/questions/1442443/disable-overview-on-startup-not-working-when-booting-without-display-connected) I appreciate the comments, I really do, but why does a trivial thing (new monitor = mirroring by default) need this much effort? I'm aware the term "much effort" is relative, but I just think this should be a lot easier, as in: set setting X to "mirror".
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.