2023-11-13 14:33:28 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# SPDX-FileCopyrightText: 2018 Oded Arbel <https://geek.co.li>
|
|
|
|
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
## 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"
|
2024-07-10 14:36:05 +02:00
|
|
|
interface="${service}.Activities"
|
2023-11-13 14:33:28 +00:00
|
|
|
path="/ActivityManager/Activities"
|
|
|
|
signal="CurrentActivityChanged"
|
|
|
|
|
|
|
|
dbus-monitor --profile \
|
2024-07-10 14:36:05 +02:00
|
|
|
"type=signal,path=${path},interface=${interface},member=${signal}" | \
|
2023-11-13 14:33:28 +00:00
|
|
|
while read -r _ _ _ _ _ path interface member; do
|
2024-07-10 14:36:05 +02:00
|
|
|
test "${member}" = "${signal}" || continue
|
|
|
|
id="$(qdbus "${service}" "${path}" "${interface}.CurrentActivity")"
|
|
|
|
name="$(qdbus "${service}" "${path}" "${interface}.ActivityName" "${id}")"
|
2023-11-13 14:33:28 +00:00
|
|
|
if command -v kdialog >/dev/null; then
|
2024-07-10 14:36:05 +02:00
|
|
|
kdialog --title "Activity: ${name}" --passivepopup "Switched Activities" 3
|
2023-11-13 14:33:28 +00:00
|
|
|
elif command -v notify-send >/dev/null; then
|
2024-07-10 14:36:05 +02:00
|
|
|
notify-send -u normal -t 3000 "Activity: ${name}" "Switched activities"
|
2023-11-13 14:33:28 +00:00
|
|
|
fi
|
|
|
|
done
|