summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchqn <chandler@cock.li>2024-01-03 13:12:48 -0600
committerchqn <chandler@cock.li>2024-01-03 13:12:48 -0600
commit007e7076c7404c86180ff3aa6ea3fe15024a87c3 (patch)
treeaa56c60b2d9911b7e7af30c7881021fee4b62d73 /src
parent350bb4aa798c9c8939b4b7c91dbee9e08f73edc4 (diff)
Refactored function signatures and added some TODOs
Diffstat (limited to 'src')
-rw-r--r--src/color_engine.py10
-rw-r--r--src/get_args.py2
-rw-r--r--src/update_i3.py4
-rw-r--r--src/update_polybar.py4
-rw-r--r--src/update_rofi.py2
-rw-r--r--src/user_interface.py6
6 files changed, 17 insertions, 11 deletions
diff --git a/src/color_engine.py b/src/color_engine.py
index f86b2e7..6d5c90a 100644
--- a/src/color_engine.py
+++ b/src/color_engine.py
@@ -14,11 +14,13 @@ def grabColors(img_path: str, num_colors: int) -> list():
# scale image down by factor of 10 to decrease computation time
dim = (int(len(img[0])/10), int(len(img)/10))
img = cv.resize(img, dim, interpolation= cv.INTER_AREA)
+ # TODO: implement KMeans clustering from scratch to
+ # improve program modularity
clt = KMeans(n_clusters=num_colors, n_init='auto')
clt.fit(img.reshape(-1, 3))
return clt.cluster_centers_
-def rgbToHex(input_values: list):
+def rgbToHex(input_values: list) -> list:
"""
Takes in a list of RBG color values and returns a list of those same colors as hex values
"""
@@ -30,11 +32,11 @@ def rgbToHex(input_values: list):
hex_list.append('#{:02x}{:02x}{:02x}'.format(red, green, blue))
return hex_list
-def hexToRGB(hex_value: str):
+def hexToRGB(hex_value: str) -> tuple:
hex_value = hex_value.lstrip('#')
return tuple(int(hex_value[i:i+2], 16) for i in (0, 2, 4))
-def compColors(color_list: list):
+def compColors(color_list: list) -> list:
"""
given a list of colors, generate complimentary colors to contrast the prominent colors.
return a list of these colors.
@@ -43,7 +45,7 @@ def compColors(color_list: list):
for color in color_list:
curr_hex = color[1:] # slice off the # from the hex code
rgb = (curr_hex[0:2], curr_hex[2:4], curr_hex[4:6])
- comp = ['%02X' % (255 - int(a, 16)) for a in rgb]
+ comp = ['%02X' % (255 - int(a, 16)) for a in rgb] # magic :D
compliments.append('#' + ''.join(comp))
return compliments
diff --git a/src/get_args.py b/src/get_args.py
index e38ee90..6be2ab9 100644
--- a/src/get_args.py
+++ b/src/get_args.py
@@ -1,6 +1,6 @@
import user_interface
import os
-def get_args(args):
+def get_args(args) -> tuple:
dmenu = False
nolock = False
diff --git a/src/update_i3.py b/src/update_i3.py
index 6430f6e..55509c9 100644
--- a/src/update_i3.py
+++ b/src/update_i3.py
@@ -5,7 +5,7 @@ import os
from rich import print
from paths import Paths
-def updatei3Theme(config_path: str, img_path: str, colors: list, compliments: list, lock: bool, dmenu: bool):
+def updatei3Theme(config_path: str, img_path: str, colors: list, compliments: list, lock: bool, dmenu: bool) -> None:
print('[bold red]Updating i3 color scheme')
data = ''
with open(config_path, 'r') as file:
@@ -49,7 +49,7 @@ def updatei3Theme(config_path: str, img_path: str, colors: list, compliments: li
os.system("i3 restart")
-def getScreenResolution():
+def getScreenResolution() -> tuple:
output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
resolution = output.split()[0].split(b'x')
width = int(resolution[0].decode('UTF-8'))
diff --git a/src/update_polybar.py b/src/update_polybar.py
index 2ea16af..2c1a3e0 100644
--- a/src/update_polybar.py
+++ b/src/update_polybar.py
@@ -1,6 +1,6 @@
-def updatePolybarTheme(config_path: str, colors: list, compliments: list):
+def updatePolybarTheme(config_path: str, colors: list, compliments: list) -> None:
print('[bold red]Updating polybar color scheme')
data = ''
with open(config_path, 'r') as file:
@@ -22,3 +22,5 @@ def updatePolybarTheme(config_path: str, colors: list, compliments: list):
with open(config_path, 'w') as file:
file.writelines(data)
+def initializePolybarConfig(config_path: str) -> None:
+ pass
diff --git a/src/update_rofi.py b/src/update_rofi.py
index a7d3aa6..88e3289 100644
--- a/src/update_rofi.py
+++ b/src/update_rofi.py
@@ -1,6 +1,6 @@
import color_engine
-def updateRofiTheme(config_path: str, colors: list, compliments: list):
+def updateRofiTheme(config_path: str, colors: list, compliments: list) -> None:
print('[bold red]Updating Rofi color scheme')
data = ''
with open(config_path, 'r') as file:
diff --git a/src/user_interface.py b/src/user_interface.py
index 32abf60..99eb524 100644
--- a/src/user_interface.py
+++ b/src/user_interface.py
@@ -5,7 +5,7 @@ import color_engine
from rich import print
-def colorPickerUI(img_path: str):
+def colorPickerUI(img_path: str) -> tuple:
#display the selected color scheme and ask user if they like it or want to generate a new color scheme
confirmed = False
while not confirmed:
@@ -36,10 +36,12 @@ def colorPickerUI(img_path: str):
confirmed = True
return hex_colors, hex_compliments
-def pickRandomWallpaper():
+def pickRandomWallpaper() -> str:
confirmed = False
while not confirmed:
wallpaper = Paths['wallpapers'] + random.choice(os.listdir(Paths['wallpapers']))
+ # TODO: Replace image preview with something native to python
+ # (Currently borrowing viu module from Rust)
os.system(f'viu {wallpaper}')
print(f'picked wallpaper: {wallpaper}')
print('[bold](a)ccept (r)etry')