I have an old laptop set up with mint (what I had a usb laying around for) and running foundryvtt with docker. That’s all set up and working great, starts services on reboot, runs headless.

What I would like to do, mainly because I think it would look cool, is have a small CRT screen that I have plugged into the laptop via HDMI to display the performance status with htop, or docker output or something. I can do this with starting a terminal session with the other display plugged in, but this requires user interaction and all of that.

This side of linux is kind of new to me, so I am not sure what direction I need to start looking in. Is it possible to set up a service to run headless and output to a display in a way that automatically comes up if the device is rebooted? Or is it possible to modify my existing docker container to output logs to display?

Appreciate any input to help get me pointed in the right direction.

EDIT: Solved!

Thanks to everyone for pointing me towards getty, grub boot settings, and bash profiles - got a setup that I’m happy with.

I was able to disable the laptop monitor and enable the CRT by adding this to /etc/default/grub

# Disable laptop monitor (LVDS-1) and only output to CRT (HDMI-A-1)
GRUB_CMDLINE_LINUX_DEFAULT="video=LVDS-1:d video=HDMI-A-1:1024x768"

(don’t forget sudo update-grub to apply)

I initially set it to 640x480, but display was better with higher res and large font size, which I scales up with sudo dpkg-reconfigure console-setup

I created a service account for this, and set up a systemd service to start getty on that account based on those docs

[Service]
Type=idle
ExecStart=
ExecStart=-/sbin/agetty --skip-login --noreset --noclear --autologin axies - ${TERM}![](https://ttrpg.network/pictrs/image/cf0ab3f3-9674-4578-a230-c8f3df7a7bdc.webp)

Then I added htop to the ~/.bash_profile for that user and… done!

Only thing is there is some overscan on the display and initially about 3 rows / cols were cut off on each side. I was able to adjust the CRT display itself to mostly mitigate this, so now only a bit is cut off and it’s usable, but it’s not perfect. I tried setting the margin in the video options in grub with margin_top, margin_left etc., as per these docs but that didn’t work, even though I verified the resolution was applying correctly. But it is functional!

  • ikidd@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    1 day ago

    You can enable Dropbear SSH server during boot, I know it’s used to be able to enter disk encryption passwords during boot on headless servers. Presumably you could use this to display boot processes on another system quite easily with an SSH session on the system with a display. You could automate that system to monitor for available SSH sessions and start displaying it when it’s available.

    • AldinTheMage@ttrpg.networkOP
      link
      fedilink
      arrow-up
      2
      ·
      1 day ago

      You mean like using a separate computer to display? I thought about that. Actually this old thing has a battery compartment with enough space to fit a raspberry pi inside so I may try and make it a self contained PC at some point. Would be cool to have it monitor multiple servers and display a status dashboard when they’re up. That sounds like a fun future project :)

    • AldinTheMage@ttrpg.networkOP
      link
      fedilink
      arrow-up
      3
      ·
      2 days ago

      That definitely looks like it is in the direction I want to go. I’ll read those docs. I do have getty on mint so I’ll do some testing

  • pryre@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    2 days ago

    The people here talking about a display server (x11/Wayland) are missing your point I think. If you put a display server on this “box” then it will become a normal server, not a headless one. At that point, you may as well run a full VM and have the output go wherever you want, etc. I’m not sure what the equivalent is in the docker world, but I’m pretty sure that’s not what you’re asking for.

    Is it possible for you to get SSH running on this “server”? If so, you may be able to set it up with an SSH client on the host PC (the laptop?) that is full screen on the CRT/HDMI output?

    Maybe I’m misunderstanding as well though. Any headless server I’ve used in Linux will still give you a TTY on the display. Do you not get that? Someone else mentioned Getty, which is likely the service that is managing that. You should be able to configure Getty to give you a specific tty (e.g. tty9) on a specific output, then configure it either to autologin or to run a script on that tty.

    • AldinTheMage@ttrpg.networkOP
      link
      fedilink
      arrow-up
      3
      ·
      2 days ago

      I do get a tty and that works fine if I start it manually. I can also ssh into it while on my local network.

      I think what I need to configure is to have it automatically start a tty at boot with specific credentials and auto start whatever monitoring I want. That should work I think. The only downside of that is I don’t want it to run on the laptop screen at all, only the hdmi output, so that is where I want to learn more about how all of those display interfaces work on linux so I can configure the service accordingly (I think)

      • pryre@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        2 days ago

        Yeah ok, that makes more sense. Some starting points (arch user by practice, but Mint will have similar interfaces):

        • use DPMS to turn screens on and off dynamically. This would be to put a monitor to sleep.
        • I would think there is a kernel parameter to either disable a display output or the driver used by the laptop display.
        • I believe “agetty” is the program that gives you a terminal on a display. Thile general term for what you are interacting with is a getty. You can see an example of setting up a generic automatic login in section 2.3.1 of that link.
        • The easy way out to run a command on start is to run bash, then have the command in the bottom of your .bashrc file.
        • the slightly better way to do this is to create a new user that will be just for this purpose (like a service account).
        • the better way would be to run the command straight through the terminal, instead of starting a shell in interactive mode. This would be replacing ${TERM} with something like /bin/sh -c '/bin/htop'.
        • I’m not sure how you could get a specific tty on a specific monitor, but I would expect there is a way to do it through the kernel parameters. This probably isn’t needed as you don’t plan on having another screen anyway. You could just use tty1 and be done with it.
        • the other thing you may want to do is to set “quiet” mode in the kernel parameters, as the system may print status messages onto the tty be default.
        • AldinTheMage@ttrpg.networkOP
          link
          fedilink
          arrow-up
          4
          ·
          24 hours ago

          This was really helpful - It got me pointed down the right track to figure out the video= settings in the grub config. I was able to disable the laptop monitor and enable the CRT by adding this to /etc/default/grub

          # Disable laptop monitor (LVDS-1) and only output to CRT (HDMI-A-1)
          GRUB_CMDLINE_LINUX_DEFAULT="video=LVDS-1:d video=HDMI-A-1:1024x768"
          

          I initially set it to 640x480, but display was better with higher res and large font size, which I scales up with sudo dpkg-reconfigure console-setup

          I created a service account for this, and set up a systemd service to start getty on that account based on those docs

          [Service]
          Type=idle
          ExecStart=
          ExecStart=-/sbin/agetty --skip-login --noreset --noclear --autologin axies - ${TERM}![](https://ttrpg.network/pictrs/image/cf0ab3f3-9674-4578-a230-c8f3df7a7bdc.webp)
          

          Then I added htop to the ~/.bash_profile for that user and… done!

          Only thing is there is some overscan on the display and initially about 3 rows / cols were cut off on each side. I was able to adjust the CRT display itself to mostly mitigate this, so now only a bit is cut off and it’s usable, but it’s not perfect. I tried setting the margin in the video options in grub with margin_top, margin_left etc., as per these docs but that didn’t work, even though I verified the resolution was applying correctly. But it is functional!

          • pryre@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            24 hours ago

            Well done! That looks amazing!

            I’m not too sure about the overs can issue, I would have thought the options you found were the right ones.

            Another option for display along the same lines might be btop. People like to get fancy with status monitors. Either way, I think yours is looking great.

            • AldinTheMage@ttrpg.networkOP
              link
              fedilink
              arrow-up
              3
              ·
              23 hours ago

              Thank you! I’m very happy with it, and I learned a lot. If I can figure out the margin thing I will definitely try to set up a fancier looking monitor, but right now htop is the most legible because of how it is displayed. Mainly just menu labels get cut off

              • caseyweederman@lemmy.ca
                link
                fedilink
                arrow-up
                2
                ·
                21 hours ago

                I enjoyed this journey, congrats.
                I would also like to recommend btop.
                Also don’t get a different monitor, that one has such a strong aesthetic.

                • AldinTheMage@ttrpg.networkOP
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  4 hours ago

                  Thank you! Once I can figure out the margins I’m going to get a custom btop preset configured. Right now I can’t configure it in a way that important info isn’t cut off on the edges.

                  The TV does have dials to adjust, but only slightly, and if I adjust too much, it messes up the scan lines and the signal doesn’t come through clearly. I feel like the answer is just a little further down the rabbit hole of kernel params :)

        • AldinTheMage@ttrpg.networkOP
          link
          fedilink
          arrow-up
          4
          ·
          1 day ago

          This is great info, thanks! I did some messing around yesterday and got it opening a tty on boot, and disabled the startx so it stays there. I will look into the monitor power stuff too. Thanks!

  • nyan@lemmy.cafe
    link
    fedilink
    English
    arrow-up
    4
    ·
    2 days ago

    You should be able to set up the system to autologin on startup and then run commands from the auto-logged-in user’s .bash_profile, if you can reduce what you want to do to a script. You’d probably want to specially set up a user for this, to reduce security risks.

    (I just stood up a weird little Gentoo media PC that does approximately this—logs a user in on startup and then runs startx from .bash_profile to make it easier to use with no keyboard attached and no DM. You’d just want to put a different command in instead.)

    • AldinTheMage@ttrpg.networkOP
      link
      fedilink
      arrow-up
      2
      ·
      1 day ago

      I was trying to start the monitoring program as part of the systemd service. Idk why I didn’t think to use the bash profile on a service account. That should work perfect! Thanks

  • hddsx@lemmy.ca
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    2 days ago

    I don’t know what headless means but that might just be a me problem.

    So your server now has a monitor and you don’t always want to connect to it? It seems like a big waste of power.

    Anyway, you could probably start an xserver in the background and output to the xserver outputting to the CRT. Then instruct your terminal to launch on that display. Just make sure you right an xorg.conf file configured to the right display.

    There’s probably a more modern way to do this in Wayland but I’m not familiar.

    What OS?

    • AldinTheMage@ttrpg.networkOP
      link
      fedilink
      arrow-up
      6
      ·
      edit-2
      2 days ago

      From what I know, headless means different things depending on context - in this instance I’m using it in the sense that my server does not require any user session, or any user input devices, it just powers on and all of the services start up at the system level. I can SSH into it to configure things, but it doesn’t require any user session or input to run the services. A video output probably falls outside of this in some sense, but I would like it to be automatic without requiring an active user session.

      The monitor I have is an old Panasonic tv / radio combo, so the display can be flipped on with a physical switch when I’m at my desk, so shouldn’t be any wasted power usage. It won’t be on all the time.

      I’m using Linux Mint, which is probably not optimal, but I had a USB ready and I’m just using terminal stuff so it didn’t seem like it mattered too much. It does have systemd, which made it pretty easy to set up the docker stuff

      Thanks for the input!