43 lines
1.4 KiB
Bash
Executable File
43 lines
1.4 KiB
Bash
Executable File
#!/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.
|
||
|
||
set -e
|
||
|
||
# check if $LOG_DIR is set, if it isn’t, provide a default
|
||
if test -z "$LOG_DIR"; then
|
||
LOG_DIR="$HOME/.var/log/sway"
|
||
fi
|
||
|
||
# create log directory
|
||
mkdir -p "$LOG_DIR"
|
||
|
||
# move the previous log to “latest” log
|
||
mv "$LOG_DIR/sway.log" "$LOG_DIR/sway.log.latest"
|
||
|
||
# print date and time information at the top of the log file
|
||
date '+%Y-%m-%dT%T %Z' >"$LOG_DIR/sway.log"
|
||
|
||
# count the number of previous log files
|
||
count=0
|
||
for file in "$LOG_DIR"/sway.log.*; do
|
||
count="$(printf "%s+1\n" "$count" | bc)"
|
||
done
|
||
|
||
# move the previous log to the log count number
|
||
mv "$LOG_DIR/sway.log.latest" "$LOG_DIR/sway.log.$count"
|
||
|
||
# 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
|