File indexing completed on 2024-12-15 05:03:51

0001 #! /bin/bash
0002 #
0003 # next-activity.sh
0004 # SPDX-FileCopyrightText: 2016 Ivan Čukić <ivan.cukic(at)kde.org>
0005 #
0006 # SPDX-License-Identifier: MIT
0007 #
0008 
0009 current_activity=($(qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity))
0010 activities=($(qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities))
0011 found="0"
0012 
0013 for ((i=0; i < ${#activities[@]}; ++i)); do
0014     if [ "$current_activity" = "${activities[$i]}" ]; then
0015         found="1"
0016     else
0017         if [ "$found" == "1" ]; then
0018             echo "Switching to ${activities[$i]}"
0019             qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity ${activities[$i]}
0020             found="0"
0021         fi
0022     fi
0023 done
0024 
0025 if [ "$found" == "1" ]; then
0026     echo "Switching to ${activities[0]}"
0027     qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity ${activities[0]}
0028 fi
0029 
0030