polybar: Add config and scripts. Ignored from other than working machine

This commit is contained in:
inkch
2024-01-15 00:09:25 +09:00
parent c5b3bc4cb3
commit 470afa3ec8
12 changed files with 577 additions and 0 deletions

View File

@ -0,0 +1,11 @@
#!/usr/bin/python
import subprocess
# res = subprocess.check_output('xset -q', shell=True).decode('UTF-8')
res = subprocess.check_output(
'cat /tmp/caffeine_status', shell=True).decode('UTF-8')
caffeined = "xidlehook is KILLED" in res
color = '#ffffff' if caffeined else '#777777'
print('%{F' + color + '}' + '')

View File

@ -0,0 +1,11 @@
#!/usr/bin/python
import os
import subprocess
res = subprocess.check_output('xset -q', shell=True).decode('UTF-8')
caffeined = "DPMS is Disabled" in res
if caffeined:
os.system('xset dpms 600 600 600')
else:
os.system('xset -dpms')

View File

@ -0,0 +1,51 @@
#!/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",
}

View File

@ -0,0 +1,6 @@
#!/usr/bin/dash
if test -f /tmp/.clicker.pid; then
echo ' '
else
echo ''
fi

View File

@ -0,0 +1,32 @@
#!/usr/bin/python
import subprocess
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--color-enabled', default='#ffffff')
# parser.add_argument('--color-enabled', default='#32bbc2')
# parser.add_argument('--color-disabled', default='#d64937')
parser.add_argument('--color-disabled', default='#777777')
args = parser.parse_args()
def is_enabled():
try:
res1 = subprocess.check_output(
'ip address show dev enp34s0 | rg inet6 | wc -l', shell=True)
return int(res1) != 0
except subprocess.CalledProcessError:
# when openpyn is inactive, pgrep return exit status 1
return False
else:
return True
if is_enabled():
print('%{F' + args.color_enabled + '}' + 'IPv6')
else:
print('%{F' + args.color_disabled + '}' + 'IPv6')
# print('%{F' + args.color_disabled + '}' + '')

View File

@ -0,0 +1,51 @@
#!/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 mic():
output = subprocess.check_output('lsusb | rg "ID 1235:8012" | 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(mic()) + '')
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",
}

View File

@ -0,0 +1,34 @@
#!/usr/bin/python
import subprocess
res = subprocess.check_output('', shell=True).decode('UTF-8')
running = subprocess.check_output(
'pueue status | rg Running | wc -l', shell=True).decode('UTF-8')
queued = subprocess.check_output(
'pueue status | rg Queued | wc -l', shell=True).decode('UTF-8')
failed = subprocess.check_output(
'pueue status | rg "(Failed|Killed)" | wc -l', shell=True).decode('UTF-8')
def printer(r, q, f):
bright = '#cccccc'
red = '#cc6666'
dim = '#777777'
def color(n):
return bright if n > 0 else dim
def color_red(n):
return red if n > 0 else dim
r, q, f = int(r), int(q), int(f)
line = ''
line += '%{F' + color(r) + '}' + str(r) + '%{F' + dim + '}/'
line += '%{F' + color(q) + '}' + str(q) + '%{F' + dim + '}/'
line += '%{F' + color_red(f) + '}' + str(f) + '%{F' + dim + '}'
print(line)
printer(running, queued, failed)

View File

@ -0,0 +1,62 @@
#!/usr/bin/python
import subprocess
import argparse
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",
}
parser = argparse.ArgumentParser()
parser.add_argument('--color-running', default='#9f78e1')
parser.add_argument('--color-zero', default='#777777')
args = parser.parse_args()
def count_running_vm():
# For VirtualBox
# output = subprocess.check_output('VBoxManage list runningvms | wc -l',
# shell=True)
# return int(output.decode('UTF-8'))
# For libvirt
output = subprocess.check_output('doas virsh list | wc -l', shell=True)
libvirt_cnt = int(output.decode('UTF-8')) - 3
output = subprocess.check_output('vboxmanage list runningvms | wc -l', shell=True)
vbox_cnt = int(output.decode('UTF_8'))
return f"{libvirt_cnt} {vbox_cnt}"
def get_color(num_str):
if num_str != "0 0":
return '%{F' + args.color_running + '}'
return '%{F' + args.color_zero + '}'
num = count_running_vm()
print(get_color(num) + '' + num)

View File

@ -0,0 +1,35 @@
#!/usr/bin/python
import subprocess
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--color-enabled', default='#32bbc2')
# parser.add_argument('--color-disabled', default='#d64937')
parser.add_argument('--color-disabled', default='#777777')
args = parser.parse_args()
def is_enabled():
try:
subprocess.check_output(
'systemctl is-active openpyn', shell=True)
l = subprocess.check_output(
'cat /etc/resolv.conf | wc -l', shell=True)
if int(l) != 3:
return False
except subprocess.CalledProcessError:
# when openpyn is inactive, pgrep return exit status 1
return False
else:
return True
if is_enabled():
# openpyn is running
print('%{F' + args.color_enabled + '}' + '')
else:
# openpyn is NOT running
print('%{F' + args.color_disabled + '}' + '')
# print('%{F' + args.color_disabled + '}' + '')