Linux list all displays

Is there a command to list all open displays on a machine?

When SSH’d locally into my computer (don’t ask, it’s a workaround), I can’t start graphical applications without running:

If I run this first and then run a graphical application, things work out. If not, it doesn’t work, there’s no display to attach to. Is there a command for listing all available displays (ie: all possible values) on a machine?

To get that display number from a command line script, try w . More info: list existing X display names?

5 Answers 5

If you want the X connection forwarded over SSH, you need to enable it on both the server side and the client side. (Depending on the distribution, it may be enabled or disabled by default.) On the server side, make sure that you have X11Forwarding yes in /etc/sshd_config (or /etc/ssh/sshd_config or wherever the configuration file is). On the client side, pass the -X option to the ssh command, or put ForwardX11 in your ~/.ssh/config .

If you run ssh -X localhost , you should see that $DISPLAY is (probably) localhost:10.0 . Contrast with :0.0 , which is the value when you’re not connected over SSH. (The .0 part may be omitted; it’s a screen number, but multiple screens are rarely used.) There are two forms of X displays that you’re likely to ever encounter:

With ssh -X localhost , you can access the X server through both displays, but the applications will use a different method: :NUMBER accesses the server via local sockets and shared memory, whereas HOSTNAME:NUMBER accesses the server over TCP, which is slower and disables some extensions.

Note that you need a form of authorization to access an X server, called a cookie and normally stored behind the scenes in the file ~/.Xauthority . If you’re using ssh to access a different user account, or if your distribution puts the cookies in a different file, you may find that DISPLAY=:0 doesn’t work within the SSH session (but ssh -X will, if it’s enabled in the server; you never need to mess with XAUTHORITY when doing ssh -X ). If that’s a problem, you need to set the XAUTHORITY environment variable or obtain the other user’s cookies.

To answer your actual question:

    Local displays correspond to a socket in /tmp/.X11-unix .

(cd /tmp/.X11-unix && for x in X*; do echo ":$"; done) 
netstat -lnt | awk ' sub(/.*:/,"",$4) && $4 >= 6000 && $4 < 6100 < print ($1 == "tcp6" ? "ip6-localhost:" : "localhost:") ($4 - 6000) >' 

(The rest of this bullet point is of academic interest only.) From another machine, you can use nmap -p 6000-6099 host_name to probe open TCP ports in the usual range. It’s rare nowadays to have X servers listening on a TCP socket, especially outside the loopback interface. Strictly speaking, another application could be using a port in the range usually used by X servers. You can tell whether an X server is listening by checking which program has the port open.

Читайте также:  Developing windows applications in linux

Источник

How do I list connected displays using the command line?

This lists the display names and detected available resolutions. You can also reconfigure your displays using xrandr.

Note that this might not work if you’re using the NVidia or ATI drivers; I’m not sure.

xrandr only works when you run it under X-windows. After all, it is X that handles all but the most basic video drivers. If you are in a terminal inside X and it still doesn’t work, then you’ve most likely lost your $DISPLAY environment variable, somehow.

xrandr —query | grep ‘\bconnected\b’ if you just wanted to see the connected monitors and their resolutions.

For most machines with the proprietary driver loaded, /usr/lib/nvidia-current/bin/nvidia-xconfig —query-gpu-info —nvidia-cfg-path=/usr/lib/nvidia-current works. Note that I said «with the proprietary driver loaded». For instance, it does not work if the driver is unloaded or nouveau is loaded. Therefore, when using Bumblebee, run optirun /usr/lib/nvidia-current/bin/nvidia-xconfig —query-gpu-info . The —nvidia-cfg-path part is not needed here as optirun sets the correct library path.

/var/log/Xorg.0.log (where 0 is the display number) may also contain valuable information about available screens. For Optimus laptops, this log contains only details on the Intel screen, so replace 0 by 8 to find out the log from the X server started by Bumblebee.

You must log in to answer this question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Obtaining List of all Xorg Displays

I would like to know how I can obtain a list of all Xorg displays on my system, along with a list of screens associated with each display. I spent some time looking through the Xlib documentation, but was not able to find a function that does what I want. Please assume that I have no other dependencies other than a POSIX-complaint OS and X (e.g., no GTK). If what I ask is not possible assuming these minimal dependencies, then a solution using other libraries is fine. Thank you very much for your help!

2 Answers 2

The only way I know of to get a list of displays is to check the /tmp/.X11-unix directory.

Once you do that, you can use Xlib to query each display for more information.

#include #include #include #include int main(void) < DIR* d = opendir("/tmp/.X11-unix"); if (d != NULL) < struct dirent *dr; while ((dr = readdir(d)) != NULL) < if (dr->d_name[0] != 'X') continue; char display_name[64] = ":"; strcat(display_name, dr->d_name + 1); Display *disp = XOpenDisplay(display_name); if (disp != NULL) < int count = XScreenCount(disp); printf("Display %s has %d screens\n", display_name, count); int i; for (i=0; i> closedir(d); > return 0; > 

Running the above gives me this output with my current displays/screens:

Display :0 has 1 screens 0: 3046x1050 Display :1 has 2 screens 0: 1366x768 1: 1680x1050 

Never found a better way of listing X displays other than that. I’d very much like to know if any better alternative exists.

Читайте также:  Kali linux убрать пароль

Источник

Как вывести список активных дисплеев (в командной строке)?

xrandr -q дает мне список подключенных дисплеев, но как я могу узнать (с учетом сценариев), активен ли дисплей в настоящее время?

Контекст: я хотел бы написать скрипт для переключения дисплея. Если он активен, его следует отключить, если нет — включить.

Примечание: xrandr -q в основном предоставляет эту информацию, поскольку активные режимы помечены * , но эту информацию трудно извлечь в скрипте bash.

3 ответа

Активные дисплеи имеют разрешение и номер смещения, показанные в идентификационной строке на выходе xrandr . Вот что я имею в виду:

$ xrandr | grep connected eDP1 connected primary 1366x768+1280+256 (normal left inverted right x axis y axis) 345mm x 194mm DP1 disconnected (normal left inverted right x axis y axis) HDMI1 disconnected (normal left inverted right x axis y axis) VGA1 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 340mm x 270mm VIRTUAL1 disconnected (normal left inverted right x axis y axis) 

В выходных данных вы видите, что встроенный монитор моего ноутбука и VGA1 оба подключены и имеют разрешение (в случае встроенного дисплея eDP1 это 1366×768). Таким образом, задача просто превращается в обработку текста. Для этой цели я написал небольшую функцию, которую вы можете использовать в своих скриптах или ~/.bashrc :

enter image description here

С выключенным монитором VGA

Источник

Thread: How do I list all active displays.

wodzu12 is offlineFirst Cup of Ubuntu

How do I list all active displays.

yes. i have no idea how to list all running X sessions
please, dont judge me for asking that, i’ve been searching for an hour and i have no idea how to list that.
help!

btw, the closest thing to what i need is ck-list-sessions, but it doesn’t show my freenx display. i need something that would show all my displays running.

dcstar is offlineUbuntu addict and loving it

Join Date Feb 2005 Location Melbourne, Australia Beans 13,510 —> Beans 13,510 Distro Ubuntu 14.04 Trusty Tahr

Re: How do I list all active displays.

QuoteOriginally Posted by wodzu12 View Post

yes. i have no idea how to list all running X sessions
please, dont judge me for asking that, i’ve been searching for an hour and i have no idea how to list that.
help!

btw, the closest thing to what i need is ck-list-sessions, but it doesn’t show my freenx display. i need something that would show all my displays running.

Please use the Forum search and Wiki search for immediate help
Please mark your thread as Solved when appropriate
New to technical forums?: How To Ask Questions The Smart Way

wodzu12 is offlineFirst Cup of Ubuntu

Re: How do I list all active displays.

  • Site Areas
  • Settings
  • Private Messages
  • Subscriptions
  • Who’s Online
  • Search Forums
  • Forums Home
  • Forums
  • The Ubuntu Forum Community
    1. Ubuntu Official Flavours Support
      1. New to Ubuntu
      2. General Help
      3. Installation & Upgrades
      4. Hardware
      5. Desktop Environments
      6. Networking & Wireless
      7. Multimedia Software
    2. Ubuntu Specialised Support
      1. Ubuntu Development Version
      2. Security
      3. Virtualisation
      4. Ubuntu Servers, Cloud and Juju
        1. Server Platforms
        2. Ubuntu Cloud and Juju
      5. Gaming & Leisure
        1. Emulators
      6. Wine
      7. Development & Programming
        1. Packaging and Compiling Programs
        2. Development CD/DVD Image Testing
        3. Ubuntu Application Development
        4. Ubuntu Dev Link Forum
        5. Programming Talk
        6. Repositories & Backports
          1. Ubuntu Backports
            1. Bug Reports / Support
      8. System76 Support
      9. Apple Hardware Users
    3. Ubuntu Community Discussions
      1. Ubuntu, Linux and OS Chat
        1. Recurring Discussions
        2. Full Circle Magazine
      2. The Cafe
        1. Cafe Games
      3. Market
      4. Mobile Technology Discussions (CLOSED)
      5. Announcements & News
      6. Weekly Newsletter
      7. Membership Applications
      8. The Fridge Discussions
      9. Forum Council Agenda
      10. Forum Feedback & Help
        1. Request a LoCo forum
      11. Resolution Centre
    4. Other Discussion and Support
      1. Other OS Support and Projects
        1. Other Operating Systems
          1. Ubuntu/Debian BASED
          2. Debian
          3. MINT
          4. Arch and derivatives
          5. Fedora/RedHat and derivatives
          6. Mandriva/Mageia
          7. Slackware and derivatives
          8. openSUSE and SUSE Linux Enterprise
          9. Mac OSX
          10. PCLinuxOS
          11. Gentoo and derivatives
          12. Windows
          13. BSD
          14. Any Other OS
      2. Assistive Technology & Accessibility
      3. Art & Design
      4. Education & Science
      5. Documentation and Community Wiki Discussions
      6. Tutorials
        1. Outdated Tutorials & Tips
      7. Ubuntu Women
      8. Ubuntu LoCo Team Forums
        1. Americas LoCo Teams
          1. Argentina Team
            1. Software
            2. Hardware
            3. Comunidad
          2. Arizona Team — US
          3. Arkansas Team — US
          4. Brazil Team
          5. California Team — US
          6. Canada Team
          7. Centroamerica Team
          8. Chile Team
            1. Comunidad
            2. Hardware
            3. Software
            4. Instalaci�n y Actualizaci�n
          9. Colombia Team — Colombia
          10. Georgia Team — US
          11. Illinois Team
          12. Indiana — US
          13. Kentucky Team — US
          14. Maine Team — US
          15. Minnesota Team — US
          16. Mississippi Team — US
          17. Nebraska Team — US
          18. New Mexico Team — US
          19. New York — US
          20. North Carolina Team — US
          21. Ohio Team — US
          22. Oklahoma Team — US
          23. Oregon Team — US
          24. Pennsylvania Team — US
          25. Peru Team
          26. Texas Team — US
          27. Uruguay Team
          28. Utah Team — US
          29. Virginia Team — US
          30. West Virginia Team — US
        2. Asia and Oceania LoCo Teams
          1. Australia Team
          2. Bangladesh Team
          3. Hong Kong Team
          4. Myanmar Team
          5. Philippine Team
          6. Singapore Team
        3. Europe, Middle East, and African (EMEA) LoCo Teams
          1. Albania Team
          2. Catalan Team
          3. Portugal Team
          4. Egypt Team
          5. Georgia Team
          6. Ireland Team — Ireland
          7. Kenyan Team — Kenya
          8. Kurdish Team — Kurdistan
          9. Lebanon Team
          10. Morocco Team
          11. Saudi Arabia Team
          12. Sudan Team
          13. Tunisia Team
        4. Other Forums & Teams
        5. LoCo Archive
          1. Afghanistan Team
          2. Alabama Team — US
          3. Alaska Team — US
          4. Algerian Team
          5. Andhra Pradesh Team — India
          6. Austria Team
          7. Bangalore Team
          8. Bolivia Team
          9. Cameroon Team
          10. Colorado Team — US
          11. Connecticut Team
          12. Costa Rica Team
          13. Delhi Team
          14. Ecuador Team
          15. El Salvador Team
          16. Florida Team — US
          17. Galician LoCo Team
          18. Greek team
          19. Hawaii Team — US
          20. Honduras Team
          21. Idaho Team — US
          22. Iowa Team — US
          23. Jordan Team
          24. Kansas Team — US
          25. Libya Team
          26. Louisiana Team — US
          27. Maryland Team — US
          28. Massachusetts Team
          29. Michigan Team — US
          30. Missouri Team — US
          31. Montana Team — US
          32. Namibia Team
          33. Nevada Team — US
          34. New Hampshire Team — US
          35. New Jersey Team — US
          36. Northeastern Team — US
          37. Panama Team
          38. Paraguay Team
          39. Qatar Team
          40. Quebec Team
          41. Rhode Island Team — US
          42. Senegal Team
          43. South Carolina Team — US
          44. South Dakota Team — US
          45. Switzerland Team
          46. Tamil Team — India
          47. Tennessee Team — US
          48. Trinidad & Tobago Team
          49. Uganda Team
          50. United Kingdom Team
          51. US LoCo Teams
          52. Venezuela Team
          53. Wales Team
          54. Washington DC Team — US
          55. Washington State Team — US
          56. Wisconsin Team
          57. Yemen Team
          58. Za Team — South Africa
          59. Zimbabwe Team
Читайте также:  Linux mint установка иконок

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Источник

Оцените статью
Adblock
detector