mirror of
https://github.com/ben-grande/qusal.git
synced 2024-10-01 02:35:49 -04:00
224312ed42
Make shell a little bit safer with: - add-default-case - check-extra-masked-returns - check-set-e-suppressed - quote-safe-variables - check-unassigned-uppercase Although there are some stylistic decisions for uniformity: - avoid-nullary-conditions - deprecated-which - require-variable-braces
40 lines
1.2 KiB
Bash
Executable File
40 lines
1.2 KiB
Bash
Executable File
#!/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"
|
|
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 >/dev/null; then
|
|
kdialog --title "Activity: ${name}" --passivepopup "Switched Activities" 3
|
|
elif command -v notify-send >/dev/null; then
|
|
notify-send -u normal -t 3000 "Activity: ${name}" "Switched activities"
|
|
fi
|
|
done
|