Skip to content

Commit

Permalink
Merge #1196
Browse files Browse the repository at this point in the history
1196: Simplify miral-app script and make terminal logic more robust r=wmww a=AlanGriffiths

Simplify miral-app script and make terminal logic more robust.

1. Adds a --shell-terminal-emulator option to miral-shell
2. Uses that (and Ctrl-Alt-T) instead of a separate "launcher" process in miral-app
3. Renames the miral-app "-launcher" option "-terminal"
4. Tries to detect a usable default terminal on the system

Co-authored-by: Alan Griffiths <[email protected]>
(cherry picked from commit c057d69)
  • Loading branch information
bors[bot] authored and AlanGriffiths committed Feb 14, 2020
1 parent 24e741c commit a8002a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
35 changes: 27 additions & 8 deletions examples/miral-shell/miral-app.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#!/usr/bin/env bash

miral_server=miral-shell
launcher=qterminal
hostsocket=
bindir=$(dirname $0)

for terminal in gnome-terminal weston-terminal qterminal lxterminal x-terminal-emulator
do
if which $terminal > /dev/null
then break;
fi
done

# Fixup for weird gnome-terminal script on Ubuntu
if [ "${terminal}" == "gnome-terminal" ] && [ -e "/usr/bin/gnome-terminal.real" ]
then
terminal="gnome-terminal --disable-factory"
fi

if [ "$(lsb_release -c -s)" != "xenial" ]
then
qt_qpa=wayland
Expand Down Expand Up @@ -43,14 +55,14 @@ do
echo "Usage: $(basename $0) [options] [shell options]"
echo "Options are:"
echo " -kiosk use miral-kiosk instead of ${miral_server}"
echo " -launcher <launcher> use <launcher> instead of '${launcher}'"
echo " -terminal <terminal> use <terminal> instead of '${terminal}'"
echo " -socket <socket> set the legacy mir socket [${socket}]"
echo " -wayland-display <socket> set the wayland socket [${wayland_display}]"
echo " -bindir <bindir> path to the miral executable [${bindir}]"
# omit -demo-server as mir_demo_server is in the mir-test-tools package
exit 0
elif [ "$1" == "-kiosk" ]; then miral_server=miral-kiosk
elif [ "$1" == "-launcher" ]; then shift; launcher=$1
elif [ "$1" == "-terminal" ]; then shift; terminal=$1
elif [ "$1" == "-socket" ]; then shift; socket=$1
elif [ "$1" == "-wayland-display" ]; then shift; wayland_display=$1
elif [ "$1" == "-bindir" ]; then shift; bindir=$1
Expand All @@ -65,11 +77,18 @@ if [ "${bindir}" != "" ]; then bindir="${bindir}/"; fi
if [ -e "${socket}" ]; then echo "Error: session endpoint '${socket}' already exists"; exit 1 ;fi
if [ -e "${XDG_RUNTIME_DIR}/${wayland_display}" ]; then echo "Error: wayland endpoint '${wayland_display}' already exists"; exit 1 ;fi

unset QT_QPA_PLATFORMTHEME

sh -c "MIR_SERVER_FILE=${socket} WAYLAND_DISPLAY=${wayland_display} ${hostsocket} ${bindir}${miral_server} ${enable_mirclient} $*"&
if [ "${miral_server}" == "miral-shell" ]
then
# miral-shell can launch it's own terminal with Ctrl-Alt-T
MIR_SERVER_FILE=${socket} WAYLAND_DISPLAY=${wayland_display} MIR_SERVER_SHELL_TERMINAL_EMULATOR=${terminal} NO_AT_BRIDGE=1 ${hostsocket} exec dbus-run-session -- ${bindir}${miral_server} ${enable_mirclient} $*
else
# miral-kiosk (and mir_demo_server) need a terminal launched
sh -c "MIR_SERVER_FILE=${socket} WAYLAND_DISPLAY=${wayland_display} ${hostsocket} ${bindir}${miral_server} ${enable_mirclient} $*"&

while [ ! -e "${XDG_RUNTIME_DIR}/${wayland_display}" ]; do echo "waiting for ${wayland_display}"; sleep 1 ;done
while [ ! -e "${XDG_RUNTIME_DIR}/${wayland_display}" ]; do echo "waiting for ${wayland_display}"; sleep 1 ;done

unset QT_QPA_PLATFORMTHEME
MIR_SOCKET=${socket} XDG_SESSION_TYPE=mir GDK_BACKEND=${gdk_backend} QT_QPA_PLATFORM=${qt_qpa} SDL_VIDEODRIVER=${sdl_videodriver} WAYLAND_DISPLAY=${wayland_display} NO_AT_BRIDGE=1 dbus-run-session -- ${launcher}
killall ${bindir}${miral_server} || killall ${bindir}${miral_server}.bin
MIR_SOCKET=${socket} XDG_SESSION_TYPE=mir GDK_BACKEND=${gdk_backend} QT_QPA_PLATFORM=${qt_qpa} SDL_VIDEODRIVER=${sdl_videodriver} WAYLAND_DISPLAY=${wayland_display} NO_AT_BRIDGE=1 dbus-run-session -- ${terminal}
killall ${bindir}${miral_server} || killall ${bindir}${miral_server}.bin
fi
9 changes: 7 additions & 2 deletions examples/miral-shell/shell_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <miral/wayland_extensions.h>

#include <linux/input.h>
#include <unistd.h>

int main(int argc, char const* argv[])
{
Expand All @@ -55,6 +56,8 @@ int main(int argc, char const* argv[])

ExternalClientLauncher external_client_launcher;

std::string terminal_cmd{"weston-terminal"};

auto const quit_on_ctrl_alt_bksp = [&](MirEvent const* event)
{
if (mir_event_get_type(event) != mir_event_type_input)
Expand All @@ -79,7 +82,7 @@ int main(int argc, char const* argv[])
return true;

case KEY_T:
external_client_launcher.launch({"weston-terminal"});
external_client_launcher.launch({terminal_cmd});
return false;

default:
Expand All @@ -103,6 +106,8 @@ int main(int argc, char const* argv[])
AppendEventFilter{quit_on_ctrl_alt_bksp},
StartupInternalClient{spinner},
pre_init(CommandLineOption{[&](std::string const& typeface) { ::wallpaper::font_file(typeface); },
"shell-wallpaper-font", "font file to use for wallpaper", ::wallpaper::font_file()})
"shell-wallpaper-font", "font file to use for wallpaper", ::wallpaper::font_file()}),
CommandLineOption{[&](std::string const& cmd) { terminal_cmd = cmd; },
"shell-terminal-emulator", "terminal emulator to use", terminal_cmd}
});
}

0 comments on commit a8002a8

Please sign in to comment.