PastyMF

Activity Defaults Changer

Jun 16th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #!/bin/bash
  2. # SPDX-License-Identifier: MIT
  3. # SPDX-FileCopyrightText: 2018 Oded Arbel <[email protected]>
  4. # SPDX-FileCopyrightText: 2025 Vasil Tsalta <[email protected]>
  5.  
  6. function readconf {
  7. kreadconfig6 --file ~/.config/kdeglobals --group General --key BrowserApplication
  8. kreadconfig6 --file ~/.config/kdeglobals --group General --key MailApplication
  9. }
  10.  
  11. function writeconf {
  12. kwriteconfig6 --file ~/.config/kdeglobals --group General --key BrowserApplication "$1"
  13. # Additional configuration changes to support GNOME and others
  14. # as discussed in the comments
  15. xdg-settings set default-web-browser “$1”
  16. xdg-mime default "$1" x-scheme-handler/https
  17. xdg-mime default "$1" x-scheme-handler/http
  18. xdg-mime default "$1" text/html
  19. kwriteconfig6 --file ~/.config/kdeglobals --group General --key MailApplication "$2"
  20. xdg-mime default "$2" x-scheme-handler/mailto
  21. }
  22.  
  23. service=org.kde.ActivityManager
  24. interface=$service.Activities
  25. path=/ActivityManager/Activities
  26. signal=CurrentActivityChanged
  27. dbus-monitor --profile "type=signal,path=$path,interface=$interface,member=$signal" |
  28. while read type timestamp serial sender destination path interface member; do
  29. [ "$member" == "$signal" ] || continue
  30. curact=$(qdbus $service $path $interface.CurrentActivity)
  31. name="$(qdbus $service $path $interface.ActivityName $curact)"
  32. echo "Switched to activity $name"
  33. echo "Previous browser was $(readconf)"
  34. case "$name" in
  35. Home)
  36. writeconf Firefox.desktop KMail.desktop
  37. plasma-apply-lookandfeel -a org.nobara41.desktop
  38. ;;
  39. Work)
  40. writeconf Edge.desktop Sedna.desktop
  41. plasma-apply-lookandfeel -a org.kde.breezeclassic.desktop
  42. ;;
  43. *) # default in case a new activity is created
  44. writeconf Firefox.desktop KMail.desktop
  45. plasma-apply-lookandfeel -a org.nobara41.desktop
  46. ;;
  47. esac
  48. browser=$(kreadconfig6 --file ~/.config/kdeglobals --group General --key BrowserApplication)
  49. mail=$(kreadconfig6 --file ~/.config/kdeglobals --group General --key MailApplication)
  50. notify-send -a Activities -i preferences-desktop-activities ... "Activity is $name\nBrowser is $browser\nMail Client is $mail"
  51. done
  52.  
Advertisement
Add Comment
Please, Sign In to add comment