51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
import re
|
|
import subprocess
|
|
from libqtile import widget, bar
|
|
from libqtile.widget.check_updates import CheckUpdates
|
|
|
|
|
|
def is_running(process):
|
|
s = subprocess.Popen(["ps", "axuw"], stdout=subprocess.PIPE)
|
|
for x in s.stdout:
|
|
if re.search(process, x.decode('utf-8')):
|
|
return True
|
|
return False
|
|
|
|
|
|
def execute(process):
|
|
return subprocess.Popen(process.split())
|
|
|
|
|
|
def execute_once(process):
|
|
if not is_running(process):
|
|
return subprocess.Popen(process.split())
|
|
|
|
|
|
def get_screen_count():
|
|
try:
|
|
output = subprocess.check_output("xrandr -q".split()).decode('utf-8')
|
|
output = [x for x in output.split("\n") if " connected" in x]
|
|
except subprocess.CalledProcessError:
|
|
return 1
|
|
|
|
if output:
|
|
return len(output)
|
|
else:
|
|
return 1
|
|
|
|
|
|
def bar_separator(config):
|
|
return widget.Sep(foreground=config.get('colour_spacer_background', '#777777'),
|
|
linewidth=config.get('width_spacer', 1),
|
|
padding=config.get('padding_spacer', 4),
|
|
)
|
|
|
|
|
|
class CheckUpdatesYaourt(CheckUpdates):
|
|
def __init__(self, **config):
|
|
super(CheckUpdatesYaourt, self).__init__(**config)
|
|
# Override command and output with yaourt command
|
|
self.cmd = "yaourt -Qua".split()
|
|
self.subtr = 0
|
|
|