aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans-Nikolai Viessmann2016-10-19 13:10:49 +0100
committerHans-Nikolai Viessmann2016-10-19 13:10:49 +0100
commitce94e92a5d58769bb22ec97ebfb69a38337b9479 (patch)
tree5e01516f91ce3c72642c890ba2886007d09f9d77
downloadstartw-1.1.0.tar.gz
startw-1.1.0.zip
Initial commit1.1.0
Added a ready-for release version of startw
-rw-r--r--LICENSE9
-rw-r--r--README53
-rw-r--r--example.conf/winitrc27
-rw-r--r--man/startw.133
-rwxr-xr-xstartw78
5 files changed, 200 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..1348246
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,9 @@
+The MIT License (MIT)
+
+Copyright (c) 2015-2016 Hans-Nikolai Viessmann
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README b/README
new file mode 100644
index 0000000..8d7c8bb
--- /dev/null
+++ b/README
@@ -0,0 +1,53 @@
+NAME
+ startw - initialise a Wayland session
+
+SYNOPSIS
+ startw [-h] [-v] [-c CONFIG] [-k KEYBOARDCONF]
+
+DESCRIPTION
+ The startw script is a front end to a Wayland shell (e.g. desktop man-
+ ager) that provides a somewhat nicer user interface for running a sin-
+ gle Wayland session. It is typically run without any arguments.
+
+ Much of the configuration for the Wayland shell is done through a shell
+ specific configuration file. However, some settings can only be given
+ through command-line arguments and/or environmental variables. For
+ instance, to configure the keyboard layout in most Wayland shells, the
+ following environment variables need to be set: XKB_DEFAULT_RULES,
+ XKB_DEFAULT_MODEL, XKB_DEFAULT_LAYOUT, XKB_DEFAULT_VARIANT,
+ XKB_DEFAULT_OPTION. The startw script handles this through the -k
+ option (see below on how to use it).
+
+ The script is analogues to the startx(1) and xinit(1) commands used to
+ initialise a X Window System session.
+
+OPTIONS
+ The arguments that are currently support by startx are:
+
+ -h print out the usage message and exit.
+
+ -v print out the version number and exit.
+
+ -c specify a configuration file other than the default.
+
+ -k specify the keyboard settings as a string formatted as "lay-
+ out;model;variant;options", e.g. "us;;;ctrl:nocaps" for a US key-
+ board with no caps-lock. See xkeyboard-config(7) for more informa-
+ tion.
+
+FILES
+ $(HOME)/.winitrc Client to run. Typically a shell script which runs
+ many programs in the background. (Default)
+
+SEE ALSO
+ startx(1), xinit(1)
+
+BUGS
+ No known bugs.
+
+AUTHOR
+ Hans-Nikolai Viessmann (hv15@hw.ac.uk)
+
+
+
+1.1.0 19 Oct 2016 startw(1)
diff --git a/example.conf/winitrc b/example.conf/winitrc
new file mode 100644
index 0000000..f04af34
--- /dev/null
+++ b/example.conf/winitrc
@@ -0,0 +1,27 @@
+# In this example I am using SWAY
+CONFIG="${HOME}/.config/sway/config"
+
+# Load general settings
+# Though we are piggybacking on X11 stuff, it is
+# independent of what composition manager we use.
+#
+# XXX: if you use systemd-user sessions, you will likely
+# need this, otherwise the user session might not function
+# correctly.
+if [ -d /etc/X11/xinit/xinitrc.d ] ; then
+ for f in /etc/X11/xinit/xinitrc.d/?* ; do
+ [ -x "${f}" ] && source "${f}"
+ done
+ unset f
+fi
+
+# These options should not be used globally, some
+# applications (like Firefox 49.0) crash.
+#export GDK_BACKEND=wayland
+#export QT_QPA_PLATFORM=wayland-egl
+#export SDL_VIDEODRIVER=wayland
+
+# Load WindowManager
+# XXX: use env has the added benefit of hooking in all of the
+# environmental variables set using startw(1).
+exec /usr/bin/env /usr/bin/sway -c "${CONFIG}"
diff --git a/man/startw.1 b/man/startw.1
new file mode 100644
index 0000000..15ace5b
--- /dev/null
+++ b/man/startw.1
@@ -0,0 +1,33 @@
+.\" Manpage for startw.
+.\" Contact hv15 AT hw.ac.uk to correct errors or typos.
+.TH startw 1 "19 Oct 2016" "1.1.0" "startw man page"
+.SH NAME
+startw \- initialise a Wayland session
+.SH SYNOPSIS
+startw [-h] [-v] [-c CONFIG] [-k KEYBOARDCONF]
+.SH DESCRIPTION
+The startw script is a front end to a Wayland shell (e.g. desktop manager) that provides a somewhat nicer user interface for running a single Wayland session. It is typically run without any arguments.
+
+Much of the configuration for the Wayland shell is done through a shell specific configuration file. However, some settings can only be given through command-line arguments and/or environmental variables.
+For instance, to configure the keyboard layout in most Wayland shells, the following environment variables need to be set: XKB_DEFAULT_RULES, XKB_DEFAULT_MODEL, XKB_DEFAULT_LAYOUT, XKB_DEFAULT_VARIANT, XKB_DEFAULT_OPTION. The startw script handles this through the \fB-k\fP option (see below on how to use it).
+
+The script is analogues to the startx(1) and xinit(1) commands used to initialise a X Window System session.
+.SH OPTIONS
+The arguments that are currently support by startx are:
+.IP \fB\-h\fP 3
+print out the usage message and exit.
+.IP \fB\-v\fP
+print out the version number and exit.
+.IP \fB\-c\fP
+specify a configuration file other than the default.
+.IP \fB\-k\fP
+specify the keyboard settings as a string formatted as "layout;model;variant;options", e.g. "us;;;ctrl:nocaps" for a US keyboard with no caps-lock. See xkeyboard-config(7) for more information.
+.SH FILES
+.IP \fB$(HOME)/.winitrc\fP 20
+Client to run. Typically a shell script which runs many programs in the background. (\fIDefault\fP)
+.SH SEE ALSO
+startx(1), xinit(1)
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Hans-Nikolai Viessmann (hv15@hw.ac.uk)
diff --git a/startw b/startw
new file mode 100755
index 0000000..7d407e1
--- /dev/null
+++ b/startw
@@ -0,0 +1,78 @@
+#!/bin/env bash
+
+# This file roughly emulates the `startx' command in that it setups up the
+# environment for a Wayland session based upon what is specificed in the
+# `~/.winitrc' file.
+
+VERSION=1.1.0
+CONFIG= # default is in .winitrc file
+
+# Keyboard Config String particulars
+# - it is assummed that the string will be of the format:
+# "layout;model;variant;options", e.g.
+# "us;;;ctrl:nocaps" for a US keyboard with no caps-lock
+DIVIDER=";" # this what we use to tokenise the string
+
+# Some helper functions
+error_log()
+{
+ echo "${@}" >&2
+}
+
+# FIXME We should not be flooding the environment like this, we should
+# be passing the tokens to the config file and let the user
+# decide how to interpret these.
+parse_keyboard_string()
+{
+ local keyboards="${1}"
+ local tokens=( $(echo "${keyboards}" | tr "${DIVIDER}" "\n") )
+ export XKB_DEFAULT_LAYOUT="${tokens[0]}"
+ export XKB_DEFAULT_MODEL="${tokens[1]}"
+ export XKB_DEFAULT_VARIANT="${tokens[2]}"
+ export XKB_DEFAULT_OPTIONS="${tokens[3]}"
+ unset keyboards
+ unset tokens
+}
+
+# Parse arguments
+while getopts ":hvc:k:" opt; do
+ case ${opt} in
+ h)
+ echo "Usage: ${0} [-h] [-v] [-c CONFIG] [-k KEYBOARDCONF]"
+ exit 0
+ ;;
+ v)
+ echo "${0} v. ${VERSION}"
+ exit 0
+ ;;
+ c)
+ CONFIG="${OPTARG}"
+ ;;
+ k)
+ parse_keyboard_string "${OPTARG}"
+ ;;
+ \?)
+ error_log "Invalid option: ${OPTARG}!"
+ exit -1
+ ;;
+ :)
+ error_log "Option -${OPTARG} requires an argument!"
+ exit -1
+ ;;
+ esac
+done
+
+# Sanity checks
+# - make sure we aren't in X/Wayland session
+VT="$(tty)"
+if [[ ${VT:5:1} != "t" ]]; then
+ error_log "Unable start as we are in a X/Wayland session or PTS!"
+ exit -1
+fi
+
+# execute the .winitrc file
+if [[ ! -z "$CONFIG" ]]; then
+ source "$CONFIG"
+else
+ source "${HOME}/.winitrc"
+fi