Comments (6)
Hi @m45t3r, thanks for the feedback.
Indeed, I came across the problem as well. Few weeks ago, I tried the deamon mode on two different computers, but I couldn't reproduce that stuttering.
After an investigation:
- EDID is a data structure provided by a digital display to describe its capabilities to a video source
- After plugging-in a monitor, a file called
edid
is created in/sys/class/drm/*/
.
Inconvenience:
- If your driver doesn't use/support DRM, you won't get it
- Some amplificators are considered as monitors, causing
edid
file creation as well
The juice is worth the squeeze and I can't keep using xrandr after getting such a stuttering.
So a first workaround would be:
prev=0; i=0
while true; do
for edid in /sys/class/drm/*/edid; do
[ -n "$(cat "$edid")" ] && i=$((i+1))
done
[ "$i" -eq 1 ] && [ "$i" != "$prev" ] && "${XRANDR}" --auto
prev="$i"; i=0
sleep 2
done
from mons.
Looks good, however I am getting the following warning though:
./mons: line 244: warning: command substitution: ignored null byte in input
And btw, there is another interesting file in this directory:
$ cat /sys/class/drm/card0-eDP-1/enabled
enabled
$ cat /sys/class/drm/card0-HDMI-A-1/enabled
disabled
In fact, this seems to be a good choice for detecting connect/disconnect monitors, since my eDP entry is enabled and HDMI were disabled in the above case.
from mons.
Warning message, but does it work ?
What is your /bin/sh
?
Try to replace this:
[ -n "$(cat "$edid")" ] && i=$((i+1))
With this:
[ -n "$(<"$edid")" ] && i=$((i+1))
It avoids both forking a subshell and executing the /bin/cat
non-builtin command.
from mons.
In Arch Linux, {/usr}/bin/sh
points to bash
:
$ pacman -Qo /usr/bin/sh
/usr/bin/sh is owned by bash 4.4.012-2
Btw, even changing the line I as suggested:
[ -n "$(<"$edid")" ] && i=$((i+1))
I get the same error. However, this seems to work though:
# Daemon mode
if $aFlag ; then
prev=0; i=0
while true; do
for status in /sys/class/drm/*/status; do
[ "$(<"$status")" = "connected" ] && i=$((i+1))
done
if [ "$i" -eq 1 ] && [ "$i" != "$prev" ]; then
"${XRANDR}" --auto --dpi "${dpi}"
fi
prev="$i"; i=0
sleep 2
done
fi
BTW, /sys/class/drm/*/status
seems to return connected
or disconected
, exactly what we want (and without relaying in EDID support).
from mons.
Sold !
I had chosen edid
to avoid extending the door for non-monitor devices.
Hoping that the check on status
file (which is more generic) does the job for everyone.
from mons.
Thanks @Ventto.
from mons.
Related Issues (20)
- Feature Request: Flag to trigger optional rotation HOT 2
- Bug: mons -s works only one time HOT 5
- mons -a; problem going from 4:3 external to 16:9 internal HOT 3
- Unable to install mons HOT 3
- Add mons to the FreeBSD ports HOT 4
- Tagging recent commits
- Please provide examples in --help and README.md HOT 2
- Feature Request: --verbose mode to print all xrandr calls executed, and --dry-run to print but not call
- Feature Request: Ability to supply scale setting for a given monitor
- Mirroring makes primary montior blank
- Feature Request: set refresh rate
- Makefile installs an empty manpage if help2man isn't present
- Daemon mode doesn't work on Ubuntu with dash as /bin/sh
- Is it possible to use 2 monitors in extended mode with a third monitor mirroring one of them?
- Ignore intel VIRTUAL[1-9] outputs HOT 1
- AUR packages outdated / broken HOT 1
- PKGBUILD Arch Linux mons-git "broken"
- Daemon mode fails due to non-existing "/sys/class/drm/*/status"
- ./mons.sh: line 86: fg: no job control HOT 1
- RAM usage goes up when switching i3 workspaces in secondary monitor only mode HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mons.