Setup: Ubuntu, Openbox, notebook, occasionally an external screen.

I’ve set things up so that if an external monitor is attached when I start my notebook, a script (run by Openbox’s autostart), xrandr makes that the primary monitor.

What I’d like to do is run that script when I turn off or otherwise disconnect that external monitor, so that I can make the notebook’s built-in screen the primary again. Does anyone here have any ideas how to do that automatically?

  • N0b3d@lemmy.mlOP
    link
    fedilink
    arrow-up
    1
    ·
    3 years ago

    Hmm. Maybe I’m doing something wrong but doing

    inotifywatch -e modify /sys/class/drm/card0-HDMI-A-2/status
    

    only gives me “No events occurred.” (after ctrl-c stops it). Oddly, I can see the file contents change (connected to disconnected and back again) if I cat it in a separate term window so I don’t know what’s going on.

    • Helix 🧬@feddit.deB
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      3 years ago

      hm, maybe you need another event type. What GPU is it?

      Events:
              access          file or directory contents were read
              modify          file or directory contents were written
              attrib          file or directory attributes changed
              close_write     file or directory closed, after being opened in
                              writeable mode
              close_nowrite   file or directory closed, after being opened in
                              read-only mode
              close           file or directory closed, regardless of read/write mode
              open            file or directory opened
              moved_to        file or directory moved to watched directory
              moved_from      file or directory moved from watched directory
              move            file or directory moved to or from watched directory
              move_self               A watched file or directory was moved.
              create          file or directory created within watched directory
              delete          file or directory deleted within watched directory
              delete_self     file or directory was deleted
              unmount         file system containing file or directory unmounted
      

      May be create or delete