-1

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.

1
  • Welcome on U&L! Are you looking for a way to get the Activity name programmatically, e.g. for using it in a script? Or for a way to see the current Activity's name somewhere in the desktop area? Please, edit this information into your question. Commented Apr 3, 2021 at 15:52

1 Answer 1

0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.