Page 1 of 2
resetting monitors more effectively
Posted: Tue Jul 29, 2025 3:42 am
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.
Re: resetting monitors more effectively
Posted: Wed Jul 30, 2025 1:40 am
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!"
Re: resetting monitors more effectively
Posted: Wed Jul 30, 2025 11:03 am
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.
Re: resetting monitors more effectively
Posted: Sun Aug 03, 2025 7:08 am
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..
Re: resetting monitors more effectively
Posted: Sun Aug 03, 2025 10:00 am
by CharlesV
Interesting post. Do you still get the time lag if your display settings are NOT set to 'none' ?
Re: resetting monitors more effectively
Posted: Sun Aug 03, 2025 10:41 am
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
Re: resetting monitors more effectively [Solved]
Posted: Tue Aug 05, 2025 4:27 pm
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 !
Re: resetting monitors more effectively
Posted: Tue Aug 05, 2025 8:04 pm
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 :-)
Re: resetting monitors more effectively
Posted: Wed Aug 06, 2025 7:12 am
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.
Re: resetting monitors more effectively
Posted: Wed Aug 06, 2025 9:46 am
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?