# Hyperpixel Square with second monitor + xserver, choose on which display to start app

**URL:** https://forums.pimoroni.com/t/hyperpixel-square-with-second-monitor-xserver-choose-on-which-display-to-start-app/26506
**Category:** Support
**Created:** [November 7, 2024, 10:19am UTC](https://forums.pimoroni.com/t/hyperpixel-square-with-second-monitor-xserver-choose-on-which-display-to-start-app/26506 "2024-11-07T10:19:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kanduvisla](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/kanduvisla/32/11135_2.png) [@kanduvisla](https://forums.pimoroni.com/u/kanduvisla)
#### Post date: [November 7, 2024, 10:19am UTC](https://forums.pimoroni.com/t/hyperpixel-square-with-second-monitor-xserver-choose-on-which-display-to-start-app/26506/1 "2024-11-07T10:19:27Z")

</div>

Hi,

I have a Raspberry Pi 5 + Hyperpixel Square + a HDMI monitor connected.  
I have a graphical app that needs to be started, and I don’t have the need for an entire desktop UI, so I basically boot into the CLI, and then start X server to just run my App.

So my `.xinitrc` is basically a one-liner:

```auto
exec <app name>

```

I simply run `startx` and this works fine: the app starts on my hyperpixel square attached to the PI.

But… there are also cases where I want to run this App on a connected display. Up until now I did this by editing `/boot/firmware/config.txt` and rebooting the Pi, but surely there must be an easier way than this right?

I tried tinkering with the `.xinitrc` file, or try adding arguments and stuff, but the best I get is that my HDMI display clones what is shown on the Hyperpixel Square - in a 720x720 square on my 1920x1080 display.

So what are my options here? I’m fine with something like an argument or editing the `.xinitrc`-file, just as long as it doesn’t require rebooting the Pi everytime. It’s anoying.

Any thoughts on this?

---

<div class="post-metadata">

### Author: ![Harrybrook54](https://avatars.discourse-cdn.com/v4/letter/h/ad7895/32.png) [@Harrybrook54](https://forums.pimoroni.com/u/Harrybrook54)
#### Post date: [July 3, 2026, 9:08am UTC](https://forums.pimoroni.com/t/hyperpixel-square-with-second-monitor-xserver-choose-on-which-display-to-start-app/26506/2 "2026-07-03T09:08:31Z")

</div>

Hi kanduvisla,

Since you want to switch the display dynamically without rebooting, relying on `/boot/firmware/config.txt` won’t help as it’s parsed only at boot time. Instead of hardcoding it there, you can pass the display geometry or target the specific X display environment directly via your startup script variables.

When I was testing UI scaling and multi-window rendering behaviors for an [open-source manga reader app](https://tachiyomiapk.pro), we faced similar challenges where the software interface had to adapt dynamically to atypical aspect ratios or secondary external displays without crashing the active environment.

For your setup, instead of just running a single-line `exec <app name>`, you can use the environment variables to target specific screens. Try checking the output of `xrandr` before running your app, or define the target display dynamically like this inside your `.xinitrc`:

#### Specifying the display output dynamically before execution

DISPLAY=:0.1 exec \<app\_name\>

Alternatively, you can create two separate small shell scripts (e.g., `start_hyperpixel.sh` and `start_hdmi.sh`) that set the respective `xrandr` primary display output configuration right before triggering the `exec` command. This completely bypasses the need to reboot the Pi every time you switch screens.

Hope this points you in the right direction!

---

<div class="post-metadata">

### Author: ![collinsa56](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@collinsa56](https://forums.pimoroni.com/u/collinsa56)
#### Post date: [July 13, 2026, 8:17am UTC](https://forums.pimoroni.com/t/hyperpixel-square-with-second-monitor-xserver-choose-on-which-display-to-start-app/26506/3 "2026-07-13T08:17:20Z")

</div>

`DISPLAY=:0.1` is probably not the way to go here as the Hyperpixel and HDMI are usually served by the same X server. So I would set the primary output or turn on / off the display you want before launching the app (using \*\*XRandR\*\*). Its a pain to edit config.txt and reboot every time . A much cleaner solution is to wrap your startx command in a small programme that runs the appropriate xrandr commands first .
