jlesage / docker-baseimage-gui

A minimal docker baseimage to ease creation of X graphical application containers
MIT License
1.16k stars 174 forks source link

Questions: when does openbox rc.xml.template got initialized and how to add a polybar entry #135

Open eastpyne opened 1 month ago

eastpyne commented 1 month ago

I have a few questions that are not issues, but I am unsure where to ask them. Please let me know if this is not the appropriate place to open such queries. Appreciate your help in advance.

  1. I followed your example to add xterm as an app. How can I configure it to open maximized when the Docker container starts? I believe I need to add a statement to /opt/base/etc/openbox/main-window-selection.xml, but I am unsure which one. Could you please advise?

  2. I successfully added both polybar and xterm to the Docker container. How can I ensure both apps load at startup, so I have a taskbar and xterm running simultaneously? On a normal system, I would add exec polybar to /etc/xinitrc or ~/.xinitrc. What is the equivalent for the Docker setup?

eastpyne commented 1 month ago

Update to question 2:

I successfully added a service such as Polybar (learned and modified from the included openbox service). Here's how you can do it:

  1. Add Polybar to the Dockerfile:

    RUN add-pkg polybar  # This is equivalent to apk add --no-cache polybar
  2. Create Initialization Script: In rootfs/etc/cont-init.d/, add a file named 10-polybar.sh. This script will be executed by /init.sh, which is part of the jlesage/baseimage-gui.

    #!/bin/sh
    
    set -e  # Exit immediately if a command exits with a non-zero status.
    set -u  # Treat unset variables as an error.
    
    mkdir -p /var/run/polybar
    chown $USER_ID:$GROUP_ID /var/run/polybar
  3. Configure the Service: In rootfs/etc/service.d, create the following structure:

    rootfs/etc/service.d
    ├── gui
    │   └── polybar.dep
    ├── polybar
    │   ├── disabled
    │   ├── run
    │   └── xvnc.dep
    • The gui/polybar.dep file is necessary for Polybar to start.

    • In the run file:

      exec /usr/bin/polybar
    • In the disabled file:

      if is-bool-val-true "${BAR:-0}"; then
       echo "false"
      else
       echo "true"
      fi

By following these steps, you can add and configure Polybar as a service in your Docker environment.

jlesage commented 1 month ago

To maximize the app by default, see: https://github.com/jlesage/docker-baseimage-gui?tab=readme-ov-file#maximizing-only-the-main-window

Also, services are documented here: https://github.com/jlesage/docker-baseimage-gui?tab=readme-ov-file#services