2022-05-05 19:50:40 +02:00
|
|
|
#!/bin/python
|
|
|
|
|
2022-05-23 16:19:48 +02:00
|
|
|
from functools import cache
|
2022-05-05 19:50:40 +02:00
|
|
|
import os
|
2022-05-23 16:19:48 +02:00
|
|
|
import random
|
|
|
|
#import ueberzug.lib.v0 as ueberzug
|
|
|
|
import subprocess
|
2022-05-13 23:49:27 +02:00
|
|
|
import time
|
2022-05-23 16:19:48 +02:00
|
|
|
import fnmatch
|
2022-05-13 23:49:27 +02:00
|
|
|
from curses.textpad import Textbox, rectangle
|
2022-05-05 19:50:40 +02:00
|
|
|
|
|
|
|
modpath = os.path.dirname(__file__)
|
|
|
|
cachefile = "/tmp/waifu.cache"
|
|
|
|
resolution = 256
|
|
|
|
center = True
|
|
|
|
lolcat = False
|
|
|
|
unameArg = "-sr"
|
|
|
|
uptimeArg = "--pretty"
|
|
|
|
terminal = os.get_terminal_size()
|
|
|
|
minTermW = 200
|
|
|
|
#unameColor = "\033[1;38;5;93m"
|
|
|
|
#uptimeColor = "\033[1;38;5;99m"
|
|
|
|
|
|
|
|
#print len([name for name in os.listdir(f'{modpath}/waifus') if os.path.isfile(name)])
|
|
|
|
DIR=modpath + '/waifus'
|
2022-05-13 23:49:27 +02:00
|
|
|
#print(len([name for name in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, name))]))
|
2022-05-05 19:50:40 +02:00
|
|
|
|
2022-05-23 16:19:48 +02:00
|
|
|
#filter waifus
|
|
|
|
waifulist = os.listdir(DIR)
|
|
|
|
waifus_raw = fnmatch.filter(waifulist, '*.256.png')
|
|
|
|
waifus = list(waifus_raw)
|
|
|
|
waifuindex = random.randint(1, len(waifus))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-13 23:49:27 +02:00
|
|
|
#print(modpath)
|
2022-05-05 19:50:40 +02:00
|
|
|
|
2022-05-23 16:19:48 +02:00
|
|
|
#######################
|
|
|
|
|
|
|
|
#If term Kitty
|
|
|
|
print(len(waifus))
|
|
|
|
|
|
|
|
if random.randint(0,1) == 0:
|
|
|
|
if os.path.getsize(cachefile) != 0:
|
|
|
|
f = open(cachefile, 'r')
|
|
|
|
waifuindex = f.read()
|
|
|
|
print(int(waifuindex))
|
|
|
|
#print(len(waifus))
|
|
|
|
#Else Add File
|
|
|
|
###############
|
|
|
|
if int(waifuindex) < len(waifus):
|
|
|
|
waifu = waifus[int(waifuindex)]
|
|
|
|
waifuindex = int(waifuindex) + 1
|
|
|
|
f = open(cachefile, 'w')
|
|
|
|
f.write(str(waifuindex))
|
|
|
|
else:
|
|
|
|
waifuindex = random.randint(1, len(waifus))
|
|
|
|
f = open(cachefile, 'w')
|
|
|
|
f.write(str(waifuindex))
|
|
|
|
waifu = waifus[int(waifuindex)]
|
|
|
|
else:
|
|
|
|
waifu = waifus[int(waifuindex)]
|
|
|
|
#######################
|
|
|
|
|
|
|
|
#Declare static methods
|
2022-05-13 23:49:27 +02:00
|
|
|
@staticmethod
|
|
|
|
def showImage():
|
2022-05-23 16:19:48 +02:00
|
|
|
subprocess.run(["/usr/bin/kitty", "icat", DIR+"/"+waifu])
|
2022-05-13 23:49:27 +02:00
|
|
|
|
|
|
|
def showUname(unameArg):
|
|
|
|
os.system("/usr/bin/uname " + unameArg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def showUptime(uptimeArg):
|
|
|
|
os.system("/usr/bin/uptime " + uptimeArg)
|
|
|
|
|
2022-05-23 16:19:48 +02:00
|
|
|
#def doLolcat():
|
|
|
|
# if __name__ == '__main__':
|
|
|
|
# showUname(unameArg)
|
|
|
|
# showUptime(uptimeArg)
|
2022-05-13 23:49:27 +02:00
|
|
|
|
2022-05-23 16:19:48 +02:00
|
|
|
showImage()
|