Warning, /frameworks/kactivities/contrib/zsh/kamd-functions is written in an unsupported language. File is not indexed.

0001 # Module: KDE Aliases
0002 # Priority: 10
0003 
0004 autoload -U colors
0005 colors
0006 
0007 # Defining aliases for common kamd dbus objects
0008 alias kamd_dbus="qdbus org.kde.ActivityManager"
0009 
0010 alias kamd_activities="qdbus org.kde.ActivityManager /ActivityManager/Activities"
0011 alias kamd_resources="qdbus org.kde.ActivityManager /ActivityManager/Resources"
0012 alias kamd_resources_linking="qdbus org.kde.ActivityManager /ActivityManager/Resources/Linking"
0013 alias kamd_features="qdbus org.kde.ActivityManager /ActivityManager/Features"
0014 
0015 alias kamd_addactivity="qdbus org.kde.ActivityManager /ActivityManager/Activities AddActivity"
0016 alias kamd_removeactivity="qdbus org.kde.ActivityManager /ActivityManager/Activities RemoveActivity"
0017 
0018 # Open the KAMD database
0019 alias kamd_database="sqlite3 ~/.local/share/kactivitymanagerd/resources/database"
0020 
0021 # Lists the existing activities, along with their state
0022 function kamd_listactivities() {
0023     echo -n "Service version: "
0024     qdbus org.kde.ActivityManager /ActivityManager serviceVersion
0025 
0026     CURRENT_ACTIVITY=`qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity`
0027 
0028     for activity in `qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities`; do
0029 
0030         STATE=""
0031 
0032         if [ "$CURRENT_ACTIVITY" = "$activity" ]; then
0033             STATE="$fg[green][CURRENT]"
0034 
0035         else
0036             STATE=`qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityState $activity`
0037 
0038             case "state$STATE" in
0039                 state0)
0040                     STATE="$fg[red]$bg[black][INVALID]"
0041                     ;;
0042                 state2)
0043                     STATE="$fg[blue][RUNNING]"
0044                     ;;
0045                 state3)
0046                     STATE="$fg[red]$bg[black][STARTING]"
0047                     ;;
0048                 state4)
0049                     STATE="$fg[black][STOPPED]"
0050                     ;;
0051                 state5)
0052                     STATE="$fg[red]$bg[black][STOPPING]"
0053                     ;;
0054             esac
0055         fi
0056 
0057         echo -n "$STATE$reset_color $activity "
0058 
0059         ACTIVITY_NAME=`qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName $activity`
0060         ACTIVITY_DESC=`qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityDescription $activity`
0061         ACTIVITY_ICON=`qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityIcon $activity`
0062 
0063         if [ -n "$ACTIVITY_DESC" ]; then
0064             echo "$ACTIVITY_NAME ($ACTIVITY_DESC, $ACTIVITY_ICON)"
0065         else
0066             echo "$ACTIVITY_NAME ($ACTIVITY_ICON)"
0067         fi
0068     done
0069 }
0070 
0071 # Shows the information about the current activity
0072 function kamd_currentactivity() {
0073     for activity in `qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity`; do
0074         STATE=`qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityState $activity`
0075 
0076         case "state$STATE" in
0077             state0)
0078                 STATE="[INVALID] "
0079                 ;;
0080             state2)
0081                 STATE="[RUNNING] "
0082                 ;;
0083             state3)
0084                 STATE="[STARTING]"
0085                 ;;
0086             state4)
0087                 STATE="[STOPPED] "
0088                 ;;
0089             state5)
0090                 STATE="[STOPPING]"
0091                 ;;
0092         esac
0093 
0094         echo -n "$STATE $activity "
0095         qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName $activity
0096     done
0097 }
0098 
0099 # Returns the current activity ID
0100 function kamd_get_currentactivity_id() {
0101     qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity
0102 }
0103 
0104 # Returns the current activity name
0105 function kamd_get_currentactivity_name() {
0106     CURRENT_ACTIVITY_ID=$(kamd_get_currentactivity_id)
0107     qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName $CURRENT_ACTIVITY_ID
0108 }
0109 
0110 # Returns the current activity name
0111 function kamd_get_currentactivity_name_normalized() {
0112     CURRENT_ACTIVITY_NAME=$(kamd_get_currentactivity_name)
0113     echo $CURRENT_ACTIVITY_NAME | tr '[:upper:] ' '[:lower:]-'
0114 }
0115 
0116 # Returns the current activity ID
0117 function kamd_STOP_ALL_BUT_CURRENT() {
0118     CURRENT_ACTIVITY_ID=$(kamd_get_currentactivity_id)
0119 
0120     for activity in `qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities`; do
0121         if [ "$activity" != "$CURRENT_ACTIVITY_ID" ]; then
0122             echo "Stop: $activity"
0123             qdbus org.kde.ActivityManager /ActivityManager/Activities StopActivity $activity
0124             sleep 1
0125         fi
0126     done
0127 }
0128 
0129 # Returns the current activity ID
0130 function kamd_REMOVE_ALL_BUT_CURRENT() {
0131     CURRENT_ACTIVITY_ID=$(kamd_get_currentactivity_id)
0132 
0133     for activity in `qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities`; do
0134         if [ "$activity" != "$CURRENT_ACTIVITY_ID" ]; then
0135             echo "Remove: $activity"
0136             qdbus org.kde.ActivityManager /ActivityManager/Activities RemoveActivity $activity
0137             sleep 1
0138         fi
0139     done
0140 }
0141