added script for automatically creating wallpapers

This commit is contained in:
paul-loedige
2020-12-13 03:39:32 +01:00
parent b503ae2e27
commit 9585964496
2 changed files with 51 additions and 18 deletions
+22 -18
View File
@@ -2,6 +2,7 @@ import re
import os
import subprocess
import psutil
from PIL import Image, ImageDraw, ImageFont
from libqtile import layout, bar, widget
from libqtile.config import Key, Drag, Click, Group, Screen
@@ -105,26 +106,26 @@ mouse = [
#endregion
#region Groups
group_names = [("", 'h',{'layout': 'monadtall'}),
("", 'c',{'layout': 'monadtall'}),
("", 'f',{'layout': 'monadtall'}),
("", 'm',{'layout': 'monadtall'}),
("", 's',{'layout': 'monadtall'}),
("", 'w',{'layout': 'monadtall'}),
("", 'v',{'layout': 'monadtall'}),
("", 'l',{'layout': 'monadtall'}),
("", 'd',{'layout': 'monadtall'}),
("", 'o',{'layout': 'monadtall'}),
("", 'g',{'layout': 'monadtall'})]
group_names = [("","Home", 'h',{'layout': 'monadtall'}),
("","Coding", 'c',{'layout': 'monadtall'}),
("","Browser", 'f',{'layout': 'monadtall'}),
("","Mail", 'm',{'layout': 'monadtall'}),
("","Music", 's',{'layout': 'monadtall'}),
("","Chat", 'w',{'layout': 'monadtall'}),
("","Video", 'v',{'layout': 'monadtall'}),
("","Documents", 'l',{'layout': 'monadtall'}),
("","Discord", 'd',{'layout': 'monadtall'}),
("","VM's", 'o',{'layout': 'monadtall'}),
("","Gaming", 'g',{'layout': 'monadtall'})]
groups = [Group(name, **kwargs) for name, key, kwargs in group_names]
groups = [Group(icon, **kwargs) for icon, name, key, kwargs in group_names]
for (name,key, kwargs) in group_names:
for (icon,name,key, kwargs) in group_names:
keys.extend([
Key(["mod1","control"], str(key), lazy.group[name].toscreen(),
Key(["mod1","control"], str(key), lazy.group[icon].toscreen(),
desc="Switch to group {}".format(name)),
Key(['mod1','control', "shift"], str(key), lazy.window.togroup(name),
Key(['mod1','control', "shift"], str(key), lazy.window.togroup(icon),
desc="move focused window to group {}".format(name)),
])
#endregion
@@ -584,7 +585,9 @@ cursor_warp = False
auto_fullscreen = True
focus_on_window_activation = "smart"
#export keys into textfile
#region Hotkey_Wallpaper
#create hotkey textfile
if os.path.isfile(hotkey_file):
os.remove(hotkey_file)
with open(hotkey_file,'w') as file:
@@ -595,8 +598,9 @@ with open(hotkey_file,'w') as file:
modifiers += '{:^7}'.format(
str(modifier).replace("mod1","Alt").replace("mod4","Super").replace("shift","Shift").replace("control","Ctrl")
) + "+"
file.write('{:30}'.format(modifiers+' '+str(key.key).upper())+"=>\t"+key.desc)
file.write('\n')
file.write('{:30}'.format(modifiers+' '+str(key.key).upper())+"=> "+key.desc)
file.write('\n\n')
#endregion
# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
# string besides java UI toolkits; you can see several discussions on the
+29
View File
@@ -0,0 +1,29 @@
from PIL import Image, ImageDraw, ImageFont
import os
import time
hotkey_file='/home/paul/Hotkeys'
hotkey_picture='/home/paul/Hotkeys.png'
with open(hotkey_file) as file:
lines = [line.rstrip() for line in file]
text1=''
for line in lines[len(lines)//2:]:
text1+=line +"\n"
text2=''
for line in lines[:len(lines)//2]:
text2+=line +"\n"
if os.path.isfile(hotkey_picture):
os.remove(hotkey_picture)
image = Image.new(mode = "RGB", size = (1440,900), color=(43,46,59))
ImageDraw.Draw(image).text((10,10), text1, font=ImageFont.truetype('/usr/share/fonts/ubuntu/UbuntuMono-R.ttf',15), fill='#ffffff')
image.save(hotkey_picture)
image = Image.open(hotkey_picture)
ImageDraw.Draw(image).text((750,10), text2, font=ImageFont.truetype('/usr/share/fonts/ubuntu/UbuntuMono-R.ttf',15), fill='#ffffff')
image.save(hotkey_picture)
image.show()