Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
[Bash] Bash Detect Moniter
-
- Posts: 14
- Joined: 2023-09-29 03:45
- Has thanked: 4 times
[Bash] Bash Detect Moniter
I am trying to find a way to use a bash script to detect if a certain monitor is connected and then have it launch btop (a hardware monitoring program) onto that monitor. I am not sure what information i need to capture in order for the script to see it is open. Would anyone know how to do hardware detection?
-
- df -h | grep > 20TiB
- Posts: 1418
- Joined: 2012-10-06 05:31
- Location: /dev/chair
- Has thanked: 80 times
- Been thanked: 191 times
Re: [Bash] Bash Detect Moniter
The first things that spring to mind for checking what is connected are 'xrandr --listmonitors', '/sys/class/drm/card0-[output]/status', and '/sys/class/drm/card0-[output]/edid' (possibly useful for matching a specific monitor rather than the output port).
It might also be possible to get this triggered from udev, but testing that is more scewing about than I'm up for right now TBH.
Alternatively, this little daemon might be of interest, though I haven't tried it myself.
It might also be possible to get this triggered from udev, but testing that is more scewing about than I'm up for right now TBH.
Alternatively, this little daemon might be of interest, though I haven't tried it myself.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.
-
- Posts: 14
- Joined: 2023-09-29 03:45
- Has thanked: 4 times
Re: [Bash] Bash Detect Moniter
Hello,
Thanks I ran that first command and i found the monitor:
XWAYLAND2 1024/150x600/90+0+480 XWAYLAND2
the other commands did just said that directory didn't exist
Its easy to tell which one it is because its for raspberry pies.
This does seem promising I would just need to figure out if HDMI is just HDMI like VGA is VGA, as well as, if i need to mess with DVI
Thanks I ran that first command and i found the monitor:
XWAYLAND2 1024/150x600/90+0+480 XWAYLAND2
the other commands did just said that directory didn't exist
Its easy to tell which one it is because its for raspberry pies.
Code: Select all
case "${SRANDRD_OUTPUT} ${SRANDRD_EVENT}" in
"DVI-0 connected") xrandr --output DVI-0 --auto --right-of LVDS;;
"VGA-0 connected") xrandr --output VGA-0 --auto --left-of LVDS;;
esac
-
- df -h | grep > 20TiB
- Posts: 1418
- Joined: 2012-10-06 05:31
- Location: /dev/chair
- Has thanked: 80 times
- Been thanked: 191 times
Re: [Bash] Bash Detect Moniter
Ahh, that newfangled wayand thing I see. There's probably some wayland-specific way to get what you're after as well, but I don't use it so I don't know what it might be.
Yeah, those sysfs nodes are dependent on the GPU driver. They're probably a more efficient way to get the information since it's provided by the driver/kernel rather than querying X, but depending on the driver in use you may not have them or they may be under different directories/names.
In any case, if xrandr works, xrandr works.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.
-
- Posts: 14
- Joined: 2023-09-29 03:45
- Has thanked: 4 times
Re: [Bash] Bash Detect Moniter
I've been tinkering with this for a little bit and i'm new to xrandr and I havent been able to get any of the statements to work. I figured by taking a case statement where if the output to the monitor exists then do this command would be what i need. However, whenever i try to test any of the out put logic by itself I just get not found; ignoring.
Here is an example basic test code that should work based on what im seeing online Xrandr Guide
Would you be able to help?
Here is an example basic test code that should work based on what im seeing online Xrandr Guide
Code: Select all
xrandr --output VGA1-0
-
- Posts: 14
- Joined: 2023-09-29 03:45
- Has thanked: 4 times
Re: [Bash] Bash Detect Moniter
Hello after months of googling i have made progress!
This code kept failing and for the life of me i couldnt figure out why it didnt find the connection.
The reason is because my system doesn't use DVI or VGA it uses XWAYLAND.
Im at a new error now, which i am not sure how to figure out it cant find LVDS does anyone know what wayland uses for this?
This code kept failing and for the life of me i couldnt figure out why it didnt find the connection.
Code: Select all
xrandr --output DVI-0 --auto --right-of LVDS;;
Im at a new error now, which i am not sure how to figure out it cant find LVDS does anyone know what wayland uses for this?
-
- Global Moderator
- Posts: 2719
- Joined: 2018-06-20 15:16
- Location: Colorado
- Has thanked: 41 times
- Been thanked: 201 times
Re: [Bash] Bash Detect Moniter
LVDS is essentially the lower level interface every gpu and display has. If exposed in software then there is a physical connection inside a laptop or embedded system where this gpu and display connection is inches apart and connected directly. It is a display type without and external connector. DP, HDMI, and VGA are then little sections or daughter boards of circuitry that convert this LVDS signal into another type of signal suitable for longer connections to a display using a cable. Within the display there is then another little batch of circuits that convert this signal back into LVDS and wired to the display.
That's all hardware details, Wayland, or it's fuller featured and experienced grandfather X, are software ensembles called a 'display server'.
The outputs LVDS, DP, HDMI, VGA all perform the same function as far as wayland is concerned.
That's all hardware details, Wayland, or it's fuller featured and experienced grandfather X, are software ensembles called a 'display server'.
The outputs LVDS, DP, HDMI, VGA all perform the same function as far as wayland is concerned.
-
- Posts: 14
- Joined: 2023-09-29 03:45
- Has thanked: 4 times
Re: [Bash] Bash Detect Moniter
I knew cables had daughter boards in them but never knew what it was for or did, that was very good information and glad you provided it.
I am unsure however of how to troubleshoot my issue then. It cant fight the output
I tried VGA, DP, HDMI, and LVDS none were detected (both left and right). There has to be an output being i can see the display and interact with it. xrandr -q tells me its connected but does not tell me how. Do you know how to find the output at all?
I am unsure however of how to troubleshoot my issue then. It cant fight the output
Code: Select all
xrandr --output XWAYLAND8 --auto --left-of VGA