1
0
Fork 0

virtualbox detection

This commit is contained in:
Massaki Archambault 2018-11-08 22:05:10 +00:00
parent ffb87c7928
commit 0ff5dd9523
1 changed files with 7 additions and 2 deletions

View File

@ -24,20 +24,23 @@
# 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more
# details.
import subprocess
import sys
import json
from subprocess import check_output
def get_song_name():
""" Get the name of the currently playing song """
try:
j = json.loads(subprocess.check_output(['mpv-ipc', 'get_property_string', 'media-title']))
j = json.loads(check_output(['mpv-ipc', 'get_property_string', 'media-title']))
if j['data']:
return '' + j['data']
except:
pass
return ''
def is_virtualbox():
return check_output(['lspci']).find(b"VirtualBox") != -1
def print_line(message):
""" Non-buffered printing to stdout. """
sys.stdout.write(message + '\n')
@ -74,5 +77,7 @@ if __name__ == '__main__':
song_name = get_song_name()
if song_name:
j.insert(0, {'full_text' : '%s' % song_name, 'name' : 'music'})
if is_virtualbox():
j = [b for b in j if b["name"] not in ("wireless", "battery", "path_exists") or b["instance"] == "/"]
# and echo back new encoded json
print_line(prefix+json.dumps(j))