diff --git a/data/meson.build b/data/meson.build
index 98c585753cad7b700250269094d90a7f8bfc255d..7eb1cf12d374455ed0ae030edb30210978735119 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,3 +1,16 @@
+runconf = configuration_data()
+runconf.set('bindir', bindir)
+runconf.set('libexecdir', libexecdir)
+runconf.set('pkgdatadir', pkgdatadir)
+runconf.set('wlrootsdir', join_paths(libexecdir, 'wlroots'))
+configure_file(
+  input: 'phosh.in',
+  output: 'phosh',
+  install_dir: bindir,
+  configuration: runconf,
+  install: true
+)
+
 schemas = ['sm.puri.phosh.gschema.xml']
 compiled = gnome.compile_schemas(
   build_by_default: true
diff --git a/data/phosh.in b/data/phosh.in
new file mode 100755
index 0000000000000000000000000000000000000000..b0f47f2ad60ab47d49881a6929999d5803378d3c
--- /dev/null
+++ b/data/phosh.in
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+ROOTSTON="/usr/bin/rootston"
+ROOTSTON_INI="@pkgdatadir@/rootston.ini"
+
+if [ -x @wlrootsdir@/rootston ]; then
+  ROOTSTON=@wlrootsdir@/rootston
+elif [ -x @bindir@/rootston ]; then
+  ROOTSTON=@bindir@/rootston
+elif [ -x /usr/lib/wlroots/rootston ]; then
+  ROOTSTON=/usr/lib/wlroots/rootston
+fi
+
+if [ -f "/etc/phosh/rootston.ini" ]; then
+  ROOTSTON_INI=/etc/phosh/rootston.ini
+fi
+
+exec "${ROOTSTON}" -C "${ROOTSTON_INI}" -E "gnome-session --disable-acceleration-check --session=phosh"
diff --git a/debian/rules b/debian/rules
index 5ce4b23418c35c15de600c77a721cb3e2062f581..b2d064b1a9956dfcd86608b919fa838545e15510 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,8 +7,6 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 override_dh_auto_install:
 	dh_auto_install
-	# Move phosh to arch indep dir
-	mv debian/phosh/usr/lib/*/phosh debian/phosh/usr/lib/phosh/phosh
 	cp rootston.ini debian/phosh/usr/share/phosh/
 
 override_dh_installsystemd:
diff --git a/meson.build b/meson.build
index d93d05cf1aadb57cd3ebce6d65d69bcc99af4aac..0543d12ee7dbf4d368ef7303bda187b58735fdd7 100644
--- a/meson.build
+++ b/meson.build
@@ -5,6 +5,12 @@ project('phosh', 'c',
   default_options: [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11' ],
 )
 
+prefix = get_option('prefix')
+bindir = join_paths(prefix, get_option('bindir'))
+datadir = join_paths(prefix, get_option('datadir'))
+libexecdir = join_paths(prefix, get_option('libexecdir'))
+pkgdatadir = join_paths(datadir, meson.project_name())
+
 config_h = configuration_data()
 config_h.set_quoted('GETTEXT_PACKAGE', 'phosh')
 config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
diff --git a/src/meson.build b/src/meson.build
index 4389231911d9a5c9e9386eaf2f51c3a4168a52ec..1e0a8fdec7b78a4c20cc63016d50cc59c36b73aa 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -87,6 +87,6 @@ phosh_deps = [
 phosh = executable('phosh', phosh_sources,
   dependencies: phosh_deps,
   install: true,
-  install_dir: get_option('libexecdir'),
+  install_dir: libexecdir,
 )