qusal/qusal/dom0/files/autostart-scripts/kde-activity-changed-notifier
Ben Grande f733dbf75f
test
2023-10-30 09:31:16 +00:00

39 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
# SPDX-FileCopyrightText: 2018 Oded Arbel <https://geek.co.li>
# SPDX-FileCopyrightText: 2023 Qusal contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later
## Credits: https://geek.co.il/2018/07/30/script-day-different-default-browser-per-kde-activity
set -eu
if ! command -v notify-send >/dev/null &&
! command -v kdialog >/dev/null; then
exit 1
fi
command -v qdbus >/dev/null || exit 1
case "${XDG_SESSION_DESKTOP:-}" in
KDE|plasma) ;;
*) exit 1;;
esac
service="org.kde.ActivityManager"
interface="$service.Activities"
path="/ActivityManager/Activities"
signal="CurrentActivityChanged"
dbus-monitor --profile \
"type=signal,path=$path,interface=$interface,member=$signal" | \
while read -r _ _ _ _ _ path interface member; do
test "$member" = "$signal" || continue
id="$(qdbus "$service" "$path" "$interface.CurrentActivity")"
name="$(qdbus "$service" "$path" "$interface.ActivityName" "$id")"
if command -v kdialog; then
kdialog --title "Activity: $name" --passivepopup "Switched Activities" 3
elif command -v notify-send; then
notify-send -u normal -t 3000 "Activity: $name" "Switched activities"
fi
done