How to print the name of the current kde activity alone? The activity bar displays all activities, highlighting the current one. I would find useful an unobtrusive widget to print the current activity name only.
thank you
p.
How to print the name of the current kde activity alone? The activity bar displays all activities, highlighting the current one. I would find useful an unobtrusive widget to print the current activity name only.
thank you
p.
Using a widget (verbose instructions for future readers):
In Plasma Desktop's default panel (the bar at the bottom of the desktop), right-click on a free area and select "Add Widgets"; in the Widgets panel, search for "Activities"; drag the Activities widget to the panel. It is a relatively unobtrusive widget that shows the name of the current activity and opens the activity manager when clicked on.
Using D-Bus (noting that the question's first revision explicitly mentioned it):
CurrentActivity=$(dbus-send --session --dest=org.kde.ActivityManager \
--type=method_call --print-reply=literal /ActivityManager/Activities \
org.kde.ActivityManager.Activities.CurrentActivity | tr -d "[:blank:]")
dbus-send --session --dest=org.kde.ActivityManager --type=method_call \
--print-reply /ActivityManager/Activities \
org.kde.ActivityManager.Activities.ActivityInformation \
"string:$CurrentActivity"
You may want to use -print-reply=literal instead of -print-reply to reduce the amount of output. It can then be filtered, piping it through something like awk 'NR==2 {print $2}' to get the current activity's name only. Note, though, that activity names can include white spaces, tabs and double quotes, making dbus-send's output hard, if not impossible, to parse reliably in the general case.