--- /dev/null
+#!/usr/bin/env bash
+
+cd "$(dirname "$(realpath -Pe "${0}")")"
+find . -name '*.desktop' -delete
+
+setup_screens=
+
+while (( ${#} )); do
+ if [[ -x "${1}" ]]; then
+ if [[ "${setup_screens}" ]]; then
+ echo "Error: script path set twice" >&2
+ exit 1
+ fi
+ setup_screens="$(realpath -Pe "${1}")"
+ fi
+ shift
+done
+
+if [[ -z "${setup_screens}" || ! -x "${setup_screens}" ]]; then
+ echo "Error: script path not set or does not exist" >&2
+ exit 1
+fi
+
+get_icon_config() {
+ local svg_file="$(dirname "${setup_screens}")/laptop-${REPLY,,}.svg"
+ if [[ -e "${svg_file}" ]]; then
+ echo "Icon=${svg_file}"
+ else
+ echo "#Icon=${svg_file}"
+ fi
+}
+
+while read -r -d $'\n'; do
+ cat >"${REPLY}.desktop" <<EOF
+[Desktop Entry]
+Type=Application
+Exec=${setup_screens} --wait-for-keypress --load-saved ${REPLY}
+$(get_icon_config "${RPELY}")
+
+Name=Restore saved monitor settings ${REPLY}
+Terminal=true
+EOF
+done < <(lxqt-config-monitor --list-saved 2>/dev/null)
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
+ <defs id="defs3051">
+ <style type="text/css" id="current-color-scheme">.ColorScheme-Text { color: #fcfcfc; } </style>
+ </defs>
+ <path style="fill:currentColor;fill-opacity:1;stroke:none" d="m 2,3 0,1 0,8.1 0,1 4,5 1,0 14.8,0 1,0 -4,-5 0,-1 0,-8.1 0,-1 -1,0 -14.8,0 -1,0 z m 1,1 14.8,0 0,8.1 -14.8,0 0,-8.1 z m 0,8.1 0,1 14.8,0 3.2,4 -14.8,0 -3.2,-4 z" id="rect4211" class="ColorScheme-Text"/>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
+ <defs id="defs3051">
+ <style type="text/css" id="current-color-scheme">.ColorScheme-Text { color: #fcfcfc; } </style>
+ </defs>
+ <path style="fill:currentColor;fill-opacity:1;stroke:none" d="m 2,3 0,1 0,8.1 0,1 4,5 1,0 14.4,0 1,0 -4,-5 0,-1 0,-8.1 0,-1 -1,0 -14.4,0 -1,0 z m 1,1 14.4,0 0,8.1 -14.4,0 0,-8.1 z" id="rect4211" class="ColorScheme-Text"/>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
+ <defs id="defs3051">
+ <style type="text/css" id="current-color-scheme">.ColorScheme-Text { color: #fcfcfc; } </style>
+ </defs>
+ <!--
+ <path style="fill:currentColor;fill-opacity:1;stroke:none" d="m 3,4 0,1 0,14.4 0,1 2,0 4,5 1,0 14.8,0 1,0 -4,-5 2,0 0,-1 0,14.4 0,-1 -1,0 -15.75,0 -1,0 z" id="rect4211" class="ColorScheme-Text"/>
+ -->
+ <path style="fill:currentColor;fill-opacity:1;stroke:none" d="m 0.5,1 0,1 0,14.4 0,1 1,0 0.475,0 4,5 14.8,0 -4,-5 0.475,0 1,0 0,-1 0,-14.4 0,-1 -1,0 -15.75,0 -1,0 z m 1,1 7.5,0 0,14.4 -7.5,0 0,-14.4 z m 8.25,0 7.5,0 0,14.4 -7.5,0 0,-14.4 z" id="rect4211" class="ColorScheme-Text"/>
+</svg>
--- /dev/null
+#!/bin/bash
+
+kernel_pkg_ver() {
+ pacman -Qi linux | sed -rn 's/^Version\s*:\s*(.*)$/\1/p'
+}
+
+kernel_running_ver() {
+ uname -r | sed -r 's/-/./'
+}
+
+try_finding_stylus() {
+ local found=0
+ if [[ "$(kernel_pkg_ver)" != "$(kernel_running_ver)" ]]; then
+ echo "Warning: Kernel was updated: You need a reboot!" >&2
+ fi
+ echo "Tip with the stylus on monitor ${1}"
+ for (( i = 0; i < 16; i++ )); do
+ sleep 1
+ if grep -Fq "${2}" < <(xinput list --name-only); then
+ found=1
+ break
+ fi
+ done
+ if (( !found )); then
+ echo "Error: Stylus was not found: ${2}" >&2
+ return 1
+ fi
+
+}
+
+setup_styluses() {
+ local -A styluses=(
+ [eDP-1]="ELAN9008:00 04F3:425B Stylus Pen (0)"
+ [eDP-2]="ELAN9009:00 04F3:425A Stylus Pen (0)"
+ )
+ local mon stylus
+ for mon in "${!styluses[@]}"; do
+ stylus="${styluses[${mon}]}"
+ xinput disable "${stylus}"
+ if grep -q "${mon}" < <(xrandr --listactivemonitors); then
+ if ! grep -Fq "${stylus}" < <(xinput list --name-only); then
+ try_finding_stylus "${mon}" "${stylus}" || return 1
+ fi
+ xinput enable "${stylus}"
+ xinput --map-to-output "${stylus}" "${mon}"
+ echo "$(date) mapped stylus pen ${stylus%% *} to ${mon}" >&2
+ else
+ echo "$(date) disabled stylus pen ${stylus%% *}" >&2
+ fi
+ done
+}
+
+setup_touchpads() {
+ local touchpads=(
+ "ELAN9008:00 04F3:425B"
+ "ELAN9008:00 04F3:425B Touchpad"
+ "ELAN9009:00 04F3:425A"
+ "ELAN9009:00 04F3:425A Touchpad"
+ )
+ local touchpad
+ for touchpad in "${touchpads[@]}"; do
+ xinput disable "${touchpad}"
+ done
+}
+
+check_config () {
+ local config
+ for config in "${configs[@]}"; do
+ if [[ "${1}" == "${config}" ]]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+exit_script() {
+ local ret="${?}"
+ if (( wait_for_keypress )); then
+ echo "Press a key!"
+ read -n1
+ fi
+ echo exit "${1:-${ret}}"
+}
+
+help() {
+ echo "TODO: help text"
+ exit 0
+}
+
+wait_for_keypress=0
+load_saved=
+configs=()
+
+if ! output="$(lxqt-config-monitor --list-saved 2>/dev/null)"; then
+ lxqt-config-monitor --list-saved
+ exit_script
+elif [[ "${output}" ]]; then
+ mapfile -d $'\n' -t configs < <(printf '%s\n' "${output}")
+fi
+unset output
+list_saved_failed="${?}"
+while (( ${#} )); do
+ case "${1}" in
+ --wait-for-keypress)
+ wait_for_keypress=1
+ ;;
+ --load-saved)
+ load_saved="${2}"
+ shift
+ ;;
+ --help)
+ help
+ ;;
+ *)
+ echo "Error: unknown argument: ${1}" >&2
+ exit_script 1
+ ;;
+ esac
+ shift
+done
+
+if [[ "${load_saved}" ]]; then
+ (( list_saved_failed )) && exit "${list_saved_failed}"
+ if check_config "${load_saved}"; then
+ lxqt-config-monitor --load-saved "${load_saved}" || exit 1
+ sleep .4
+ else
+ echo "Error: no such saved config: ${load_saved}" >&2
+ exit_script 1
+ fi
+fi
+
+setup_touchpads
+setup_styluses
+
+exit_script