浏览代码

change pause to play/pause

mahi97 8 年之前
父节点
当前提交
96d57dc33e
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      plugins/osx/osx.plugin.zsh

+ 8 - 2
plugins/osx/osx.plugin.zsh

@@ -335,8 +335,14 @@ function spotify() {
         break ;;
 
       "pause"    )
-        cecho "Pausing Spotify.";
-        osascript -e 'tell application "Spotify" to pause';
+        state=$(osascript -e 'tell application "Spotify" to player state as string');
+        if [ "$state" = "playing" ]; then
+          cecho "Pausing Spotify.";
+        else
+          cecho "Playing Spotify.";
+        fi
+
+        osascript -e 'tell application "Spotify" to playpause';
         break ;;
 
       "quit"    )