resetting monitors more effectively  [Solved]

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
User avatar
leanLux
Posts: 37
Joined: Tue Jul 01, 2025 10:02 am

resetting monitors more effectively

#1 Post by leanLux »

I recently wrote a Firefox start shell-script which still left the tiny bug of my external phillips monitor unadressed, that it does occasionally scale a tiny bit larger than the screen allows - me not seeing the tabs on top properly anymore.

So I first addressed this with

Code: Select all

xrandr --output HDMI-1 --scale 1x1 
# but this does not work always, so I used
xrandr --output HDMI-1 --mode 1920x1080
It seems to set the proper coordinates work better than scaling, because by setting the resolution to the native resolution,
it is ensured that the display is operating at its optimal settings, which can resolve issues related to scaling and display artifacts.
Last edited by leanLux on Thu Jul 31, 2025 12:46 am, edited 2 times in total.
A forum entry about AI does not mean that it is written by AI.

User avatar
leanLux
Posts: 37
Joined: Tue Jul 01, 2025 10:02 am

Re: resetting monitors more effectively

#2 Post by leanLux »

Actually, I was to hasty - after all, none of my screen resize commands worked for a while after starting the laptop and external TV.
I then run both and again nothing happened - but when I left and came back later it was reset.
I will monitor which of below settings work and get back to you

Code: Select all

#!/bin/bash

# Dynamically detect HDMI output
HDMI=$(xrandr | grep " connected" | grep HDMI | cut -d" " -f1)

# If no HDMI monitor is detected, exit the script with a message
if [ -z "$HDMI" ]; then
  echo "No HDMI monitor detected. Exiting..."
  exit 1
fi

# Retry logic (10 retries with 3-second delays)
for i in {1..10}; do
  xrandr --output "$HDMI" --mode 1920x1080 && break
  echo "Retry $i: HDMI not ready. Waiting..."
  sleep 3
done

# If we reach here, either it's succeeded or we've exhausted retries
if [ $i -eq 10 ]; then
  echo "Failed to set resolution after 10 retries. Exiting."
  exit 1
fi

echo "Resolution set successfully!"
A forum entry about AI does not mean that it is written by AI.

User avatar
leanLux
Posts: 37
Joined: Tue Jul 01, 2025 10:02 am

Re: resetting monitors more effectively

#3 Post by leanLux »

Sorry for all the confusion, but this problem did persist until I switched to another port (which I think was not important) but also did look into the Phillips-TVs setting and changed the display-settings from "automatic scaling" not to "16:9" or "widescreen" but simply to "NONE".
So it seems that the simple solution is that the external monitor needs to be disabled doing any scaling and my resize prompt above was irrelevant.

Note: This problem is not resolved yet, since my monitor often still opens slightly scaled.
However - re-entering

Code: Select all

xrandr --output HDMI-1 --mode 1920x1080
did work - but strangely after about 10 seconds only.
I have no idea why but will keep you updated.
A forum entry about AI does not mean that it is written by AI.

User avatar
leanLux
Posts: 37
Joined: Tue Jul 01, 2025 10:02 am

Re: resetting monitors more effectively

#4 Post by leanLux »

I still monitor this script each day when I restart the laptop and so far can say that patience is the key, cause for some reason not understood by me,
sometimes it does take entire 5 minutes for the second phillips monitor to reset properly - no need to do anything.
If this works for a week each time (even with delay) I choose this post as the solution.
Log:
  • Sunday it took entire 5 minutes to reset, but it by itself.
  • Monday: I started the laptop twice and only started my external monitor after linux did run and had executed the script: Both times the monitor was in the exact right scaling
  • Tuesday: Monitor and laptop were switched on the same time and it worked perfectly
I think that by now we established that this command seems to work but just needs some minute patience for some strange reason. Unfortunately I have no idea why it takes so long to reset its size..
Last edited by leanLux on Tue Aug 05, 2025 3:13 am, edited 2 times in total.
A forum entry about AI does not mean that it is written by AI.

User avatar
CharlesV
Global Moderator
Posts: 7787
Joined: Sun Jul 07, 2019 5:11 pm

Re: resetting monitors more effectively

#5 Post by CharlesV »

Interesting post. Do you still get the time lag if your display settings are NOT set to 'none' ?
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

User avatar
leanLux
Posts: 37
Joined: Tue Jul 01, 2025 10:02 am

Re: resetting monitors more effectively

#6 Post by leanLux »

I checked and the display had already defaulted to widescreen, so I’ve now set it to PC mode and adjusted the color temperature to warmer. I deliberately left the screensetting as-is and didn’t revert it to 'NONE' again, as I want to avoid any resets. I’m also keeping a log in the comment above of how long it takes to get the shell script running each time I launch it—that way I can track what’s working or not over time.
Thanks for your interest - I wonder whether our profile helmet is from predator or the Matrix 2
A forum entry about AI does not mean that it is written by AI.

User avatar
leanLux
Posts: 37
Joined: Tue Jul 01, 2025 10:02 am

Re: resetting monitors more effectively  [Solved]

#7 Post by leanLux »

I spent way too long trying to figure out why wmctrl wouldn’t move my Firefox window (in my case, used for Disney+ streaming). The command looked right — I even verified the window ID with wmctrl -l and double-checked the geometry syntax. Yet nothing happened.

Turns out, if a window is maximized (which Firefox tends to do when launching certain content), wmctrl and even xdotool refuse to move it. I confirmed this with xprop, where I saw:

Code: Select all

_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT
That was the culprit.

You need to unmaximize the window first before moving it. Then you can re-maximize it if needed.

Here’s the final working script I built for my startup routine. It waits for an internet connection, launches apps, and smartly moves whichever of my streaming/news tabs is active to my large screen:

Code: Select all

 #!/usr/bin/env bash
Wait until there is a connection so that no windows have to be refreshed.

while ! /bin/ping -c1 1.1.1.1 >/dev/null 2>&1; do sleep 2 done
Launch Firefox

/usr/bin/firefox &
Position Thunderbird

wmctrl -r "thunderbird" -e 0,-25,515,-1,-1
Give Firefox time to start

sleep 5
Define accepted streaming/news window titles

STREAMING_WINDOWS=("Disney+" "Netflix" "Tagesschau" "ZDF")
Find the first matching window

for NAME in "${STREAMING_WINDOWS[@]}"; do STREAM_WIN=$(wmctrl -l | grep "$NAME" | awk '{print $1}') if [ -n "$STREAM_WIN" ]; then break fi done
Move window to external screen if found

if [ -n "$STREAM_WIN" ]; then wmctrl -ir "$STREAM_WIN" -b remove,maximized_vert,maximized_horz wmctrl -ir "$STREAM_WIN" -e 0,1920,0,-1,-1 wmctrl -ir "$STREAM_WIN" -b add,maximized_vert,maximized_horz else echo "No streaming/news window found." fi 
Hope this helps anyone else who’s been pulling their hair out over this. Cheers!
P.S. AH, and don't forget to always switch on the monitor at least at the same time the computer starts up, or earlier - else no windows can be moved to that monitor !
A forum entry about AI does not mean that it is written by AI.

User avatar
CharlesV
Global Moderator
Posts: 7787
Joined: Sun Jul 07, 2019 5:11 pm

Re: resetting monitors more effectively

#8 Post by CharlesV »

Yeah, THAT is an interesting one.. and I stumbled on it a year or two ago. (Also when using devilspie too ). Its like FF completely destroys the window label.

ps: and yes, the helmet is modeled after Predator ( I use various Predator images in various places.. this one kind of stayed with me as I had an MC Jacket VERY similar to that one) tni - I have started building my own version of a Predator helmet and cannot wait to ride my Harley with it on :-)
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

User avatar
b3ta
Posts: 87
Joined: Mon Aug 20, 2018 4:34 am

Re: resetting monitors more effectively

#9 Post by b3ta »

leanLux wrote: Tue Aug 05, 2025 4:27 pm Hope this helps anyone else who’s been pulling their hair out over this. Cheers!
Oh, this is lovely. Thank you.

I had a similarly hair-reducing experience with our TV that I also drive from an ancient laptop with AVL on it. With actual TV one doesn't pick up things like this without a test signal, but with computer output it's another matter. In the end it wasn't clock timing or other things I used to change in X config files relating to a CRT — it was the actual TV settings. Turned out that I needed to move the image using the TV remote. On another cheap TV that had gotten knocked, the screen had moved inside the bezel, and needed a similar knock in the opposite direction.

So sometimes it's a low-tech solution ­— unlike yours, though: well done on that.

---

One leading question: Can one do things like this in Wayland yet? I'm not necessarily averse to it, but it needs to be able to support such work-flows for it to work for me.

User avatar
leanLux
Posts: 37
Joined: Tue Jul 01, 2025 10:02 am

Re: resetting monitors more effectively

#10 Post by leanLux »

Without your reply, bta, I would have not written this, but this morning,

First thing after everything worked yesterday was for this very startup script to take another Firefox window, (with a ton of unrelated tabs) move it to the monitor and fullscreen that perfectly.
Even running it later manually would not be able to distinguish other FF-windows.

Since I had way too many tabs open, I closed most of them; and on the next restart it worked again.
So it seems that computer issues only should be fixed if they encounter errors repeatedly. Or do you disagree?
A forum entry about AI does not mean that it is written by AI.

Post Reply

Return to “Tips & Tricks by users (not for help)”