GithubHelp home page GithubHelp logo

Comments (6)

Ventto avatar Ventto commented on July 30, 2024

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.

thiagokokada avatar thiagokokada commented on July 30, 2024

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.

Ventto avatar Ventto commented on July 30, 2024

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.

thiagokokada avatar thiagokokada commented on July 30, 2024

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.

Ventto avatar Ventto commented on July 30, 2024

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.

thiagokokada avatar thiagokokada commented on July 30, 2024

Thanks @Ventto.

from mons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.