Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # SPDX-License-Identifier: MIT
- # SPDX-FileCopyrightText: 2018 Oded Arbel <[email protected]>
- # SPDX-FileCopyrightText: 2025 Vasil Tsalta <[email protected]>
- function readconf {
- kreadconfig6 --file ~/.config/kdeglobals --group General --key BrowserApplication
- kreadconfig6 --file ~/.config/kdeglobals --group General --key MailApplication
- }
- function writeconf {
- kwriteconfig6 --file ~/.config/kdeglobals --group General --key BrowserApplication "$1"
- # Additional configuration changes to support GNOME and others
- # as discussed in the comments
- xdg-settings set default-web-browser “$1”
- xdg-mime default "$1" x-scheme-handler/https
- xdg-mime default "$1" x-scheme-handler/http
- xdg-mime default "$1" text/html
- kwriteconfig6 --file ~/.config/kdeglobals --group General --key MailApplication "$2"
- xdg-mime default "$2" x-scheme-handler/mailto
- }
- 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 type timestamp serial sender destination path interface member; do
- [ "$member" == "$signal" ] || continue
- curact=$(qdbus $service $path $interface.CurrentActivity)
- name="$(qdbus $service $path $interface.ActivityName $curact)"
- echo "Switched to activity $name"
- echo "Previous browser was $(readconf)"
- case "$name" in
- Home)
- writeconf Firefox.desktop KMail.desktop
- plasma-apply-lookandfeel -a org.nobara41.desktop
- ;;
- Work)
- writeconf Edge.desktop Sedna.desktop
- plasma-apply-lookandfeel -a org.kde.breezeclassic.desktop
- ;;
- *) # default in case a new activity is created
- writeconf Firefox.desktop KMail.desktop
- plasma-apply-lookandfeel -a org.nobara41.desktop
- ;;
- esac
- browser=$(kreadconfig6 --file ~/.config/kdeglobals --group General --key BrowserApplication)
- mail=$(kreadconfig6 --file ~/.config/kdeglobals --group General --key MailApplication)
- notify-send -a Activities -i preferences-desktop-activities ... "Activity is $name\nBrowser is $browser\nMail Client is $mail"
- done
Advertisement
Add Comment
Please, Sign In to add comment