automated screen detection
This commit is contained in:
@@ -1,10 +1,38 @@
|
||||
import subprocess
|
||||
import re
|
||||
import numpy as np
|
||||
|
||||
from libqtile.config import Screen
|
||||
|
||||
from Bars import top_bar, left_bar, main_bar,laptop_bar
|
||||
from Bars import top_bar, left_bar, main_bar,laptop_bar, secondary_bar
|
||||
from defines import main_screen_res, top_screen_res
|
||||
|
||||
screens = [
|
||||
# Screen(bottom=top_bar),
|
||||
# Screen(top=left_bar),
|
||||
# Screen(top=main_bar),
|
||||
Screen(top=laptop_bar)
|
||||
]
|
||||
# Screen(top=laptop_bar)
|
||||
]
|
||||
|
||||
|
||||
cmd = ['xrandr']
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
resolution_string, junk = p.communicate()
|
||||
p.stdout.close()
|
||||
screen_resolutions = [np.array(screen_res.split('x')).astype(np.int) for screen_res in re.findall('[0-9]+x[0-9]+(?=[^\\\\n]*\*)',str(resolution_string))]
|
||||
number_of_screens = len(screen_resolutions)
|
||||
max_width = max(screen_resolutions, key=lambda res: res[0])[0]
|
||||
defined_main_window = False
|
||||
for width, height in screen_resolutions:
|
||||
if width == main_screen_res[0] and height == main_screen_res[1]:
|
||||
screens.append(Screen(top=main_bar))
|
||||
defined_main_window = True
|
||||
elif width == top_screen_res[0] and height == top_screen_res[1]:
|
||||
screens.append(Screen(bottom=top_bar))
|
||||
elif width < height:
|
||||
screens.append(Screen(top=left_bar))
|
||||
elif width == max_width and not defined_main_window:
|
||||
screens.append(Screen(top=laptop_bar))
|
||||
defined_main_window = True
|
||||
else:
|
||||
screens.append(Screen(top=secondary_bar))
|
||||
Reference in New Issue
Block a user