dotfiles/dot_config/polybar/scripts/executable_camera.py

52 lines
1.2 KiB
Python

#!/usr/bin/python
import subprocess
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--color-running', default='#cc6666')
parser.add_argument('--color-zero', default='#777777')
args = parser.parse_args()
def camera_plugged():
output = subprocess.check_output('lsusb | rg "ID 05a3:9331" | wc -l',
shell=True)
return int(output.decode('UTF-8')) > 0
def get_color(plugged):
if plugged:
return '%{F' + args.color_running + '}'
return '%{F' + args.color_zero + '}'
print(get_color(camera_plugged()) + '')
palette = {
"background": "#232c31",
"foreground": "#c5c8c6",
"selection": "#425059",
"line": "#2d3c46",
"comment": "#777777",
"red": "#cc6666",
"orange": "#de935f",
"yellow": "#f0c674",
"green": "#b5bd68",
"aqua": "#8abeb7",
"blue": "#81a2be",
"purple": "#b294bb",
"window": "#303030",
"darkcolumn": "#1c1c1c",
"addbg": "#5F875F",
"addfg": "#d7ffaf",
"changebg": "#5F5F87",
"changefg": "#d7d7ff",
"delbg": "#cc6666",
"darkblue": "#00005f",
"darkcyan": "#005f5f",
"darkred": "#5f0000",
"darkpurple": "#5f005f",
}