-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsong_status.py
More file actions
34 lines (26 loc) · 894 Bytes
/
song_status.py
File metadata and controls
34 lines (26 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sublime, sublime_plugin
import os
import re
import subprocess
import sys
class SongStatus:
def load(self):
SongStatus.active = False
SongStatus.loop()
def loop(self):
if SongStatus.active == True:
sublime.status_message(self.current_status())
sublime.set_timeout(lambda:self.loop(), 3000)
def start(self):
SongStatus.active = True
def stop(self):
SongStatus.active = False
def current_status(self):
return re.sub("\\\\n", "", re.sub("'", "", re.sub("^b", "", str(subprocess.Popen(["/usr/bin/env", "ruby", os.path.expanduser("~/bin/current_song.rb")], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]))))
SongStatus = SongStatus()
SongStatus.load()
class SongStatusEventHandler(sublime_plugin.EventListener):
def on_activated(self, view):
SongStatus.start()
def on_deactivated(self, view):
SongStatus.stop()