startsway/startsway

43 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2023-03-29 22:28:42 +00:00
#!/bin/sh
# Copyright (c) 2023 Emma Tebibyte
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and this
# notice are preserved. This file is offered as-is, without any warranty.
2023-03-29 23:55:35 +00:00
set -e
2023-03-29 22:28:42 +00:00
# check if $LOG_DIR is set, if it isnt, provide a default
if test -z "$LOG_DIR"; then
2023-04-03 17:32:49 +00:00
LOG_DIR="$HOME/.var/log/sway"
2023-03-29 22:28:42 +00:00
fi
# create log directory
2023-03-31 03:08:29 +00:00
mkdir -p "$LOG_DIR"
2023-03-29 22:28:42 +00:00
# move the previous log to “latest” log
2023-03-31 03:08:29 +00:00
mv "$LOG_DIR/sway.log" "$LOG_DIR/sway.log.latest"
2023-03-29 22:28:42 +00:00
# print date and time information at the top of the log file
2023-04-02 05:20:08 +00:00
date '+%Y-%m-%dT%T %Z' >"$LOG_DIR/sway.log"
2023-03-29 22:28:42 +00:00
# count the number of previous log files
2023-04-03 17:32:49 +00:00
count=0
for file in "$LOG_DIR"/sway.log.*; do
2023-03-29 22:28:42 +00:00
count="$(printf "%s+1\n" "$count" | bc)"
done
# move the previous log to the log count number
2023-03-31 03:08:29 +00:00
mv "$LOG_DIR/sway.log.latest" "$LOG_DIR/sway.log.$count"
2023-03-29 22:28:42 +00:00
# run the sway desktop with KDE set as the current desktop to allow the Plasma
# xdg_desktop_portal implementation run as the provider of file choosers and the
# like, but set it also to sway to run the xdg_desktop_portal implementation for
# wlroots so streaming is possible
#
# run dbus-run-session-sway so that sway is run with dbus support, and redirect
# all output to the sway log file
XDG_CURRENT_DESKTOP="sway:KDE" dbus-run-session sway >>"$LOG_DIR/sway.log" 2>&1