experiment 1
This commit is contained in:
parent
6667309c1a
commit
e4793ab107
|
@ -1,8 +1,8 @@
|
||||||
from multiprocessing import Process, Queue
|
from multiprocessing import Process, Queue
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from sys import argv
|
from sys import argv, stdout
|
||||||
from sys import stdout
|
|
||||||
from math import floor
|
from math import floor
|
||||||
|
from socket import gethostname
|
||||||
import datetime
|
import datetime
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -56,7 +56,10 @@ def filemodfactory(filename: str, modname: str):
|
||||||
|
|
||||||
def new_mail(queue, _):
|
def new_mail(queue, _):
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
dir_output = os.listdir("/home/usr/Mail/main/INBOX/new")
|
dir_output = os.listdir("/home/usr/Mail/main/INBOX/new")
|
||||||
|
except FileNotFoundError: # we're on the phone, no mail here
|
||||||
|
return
|
||||||
dir_output = len(dir_output)
|
dir_output = len(dir_output)
|
||||||
queue.put({
|
queue.put({
|
||||||
"module": "newmail",
|
"module": "newmail",
|
||||||
|
@ -69,7 +72,10 @@ def bspwm(queue, monitor):
|
||||||
socket.AF_UNIX,
|
socket.AF_UNIX,
|
||||||
socket.SOCK_STREAM
|
socket.SOCK_STREAM
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
client.connect("/tmp/bspwm_1_0-socket")
|
client.connect("/tmp/bspwm_1_0-socket")
|
||||||
|
except: # perhaps we're on the phone?
|
||||||
|
client.connect("/data/data/com.termux/files/usr/tmp/bspwm_1_0-socket")
|
||||||
|
|
||||||
message = "subscribe\0".encode()
|
message = "subscribe\0".encode()
|
||||||
client.send(message)
|
client.send(message)
|
||||||
|
@ -143,14 +149,8 @@ def render(modules) -> str:
|
||||||
print(output, end='')
|
print(output, end='')
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
|
|
||||||
def main():
|
def start_statusbars():
|
||||||
try:
|
# is there an actually good xrandr library?
|
||||||
os.mkdir("/home/usr/.cache/statusbar")
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if argv[1] == "start_statusbars":
|
|
||||||
# get the monitors
|
|
||||||
xrandr = subprocess.Popen(['xrandr'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
xrandr = subprocess.Popen(['xrandr'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
output = list(xrandr.stdout)
|
output = list(xrandr.stdout)
|
||||||
output = [i.decode("utf-8") for i in output if " connected" in i.decode("utf-8")]
|
output = [i.decode("utf-8") for i in output if " connected" in i.decode("utf-8")]
|
||||||
|
@ -173,7 +173,28 @@ def main():
|
||||||
*map(str, geometry_splitted),
|
*map(str, geometry_splitted),
|
||||||
displayname
|
displayname
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def main():
|
||||||
|
try:
|
||||||
|
os.mkdir("/home/usr/.cache/statusbar")
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if argv[1] == "start_statusbars":
|
||||||
|
hostname = gethostname()
|
||||||
|
|
||||||
|
print(hostname)
|
||||||
|
if not hostname == "localhost": # if we're not the phone
|
||||||
|
start_statusbars()
|
||||||
|
else:
|
||||||
|
# we are the phone
|
||||||
|
os.system("st -c statusbar -p -g {}x{}+{}+{} -e statusbar {} & disown".format(
|
||||||
|
1920, 100, 0, 980
|
||||||
|
"VNC-0"
|
||||||
|
))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
modules = [bspwm, clock, battery, batterystatus, sxhkdmode, new_mail]
|
modules = [bspwm, clock, battery, batterystatus, sxhkdmode, new_mail]
|
||||||
[Process(target=module, args=(queue, argv[1])).start() for module in modules]
|
[Process(target=module, args=(queue, argv[1])).start() for module in modules]
|
||||||
|
|
Loading…
Reference in New Issue