Skip to content

Commit 83384b7

Browse files
committed
We need to supply the wanted resolution
1 parent a952212 commit 83384b7

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

controller.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from zeroconf import IPVersion, ServiceInfo, Zeroconf
2727

2828
wserver = Flask(__name__)
29-
dependencies = ["xrandr"]
29+
dependencies = []
3030
stream_sources = ["static-images", "v4l2", "vnc-browser"]
3131
cmds = {"clock" : "humanbeans_clock",
3232
"image_viewer" : "imv",
@@ -201,10 +201,10 @@ def create(self, uris):
201201
item["player"] = "mediaplayer"
202202
item["play_time_s"] = self.default_play_time_s
203203
elif uri.endswith(".svg"):
204-
download_file(uri.strip(), download_path)
204+
download_file(uri.strip(), self.download_path)
205205
file = uri.split("/")
206206
item["num"] = n
207-
item["uri"] = "file:///" + download_path + file[-1]
207+
item["uri"] = "file:///" + self.download_path + file[-1]
208208
item["player"] = "imageviewer"
209209
item["play_time_s"] = self.default_play_time_s
210210
elif uri.startswith("https://"):
@@ -646,12 +646,12 @@ def show_image(self, file, fullscreen=False):
646646

647647
class Display:
648648

649-
def __init__(self, address, port):
649+
def __init__(self, address, port, res_x=1280, res_y=1024):
650650
self.address = address
651651
self.port = port
652-
res = self.get_resolution().split("x")
653-
self.res_x = int(res[0])
654-
self.res_y = int(res[1])
652+
logging.info("Resolution: {}x{}".format(res_x, res_y))
653+
self.res_x = res_x
654+
self.res_y = res_y
655655
self.start_time = time.time()
656656
self.switching_windows = list()
657657
self.window_blacklist = list()
@@ -669,21 +669,6 @@ def __init__(self, address, port):
669669

670670
logging.info("Blacklisted {} windows".format(len(self.window_blacklist)))
671671

672-
def get_resolution(self):
673-
cmd = "xrandr -q | awk '/\*/ {print $1}' \
674-
| awk 'BEGIN{FS=\"x\";} NR==1 || \
675-
$1>max {line=$0; max=$1}; END {print line}'"
676-
677-
p = subprocess.Popen(cmd,
678-
shell=True,
679-
stdout=subprocess.PIPE,
680-
stderr=subprocess.PIPE,
681-
encoding="utf8")
682-
683-
res = p.communicate()[0]
684-
685-
return res
686-
687672
def get_windows_whitelist(self):
688673
windows = self.get_windows(self.window_blacklist)
689674
logging.info("display: {} windows in whitelist".format(len(windows)))
@@ -837,8 +822,8 @@ def __init__(self, threads):
837822
default=False)
838823
parser.add_argument('--uri',
839824
dest='uris',
840-
env_var='URL',
841-
help="The URL to open in a browser, can be supplied multiple times",
825+
env_var='URI',
826+
help="The URIs to open, can be supplied multiple times",
842827
type=str,
843828
action='append',
844829
required=True)

0 commit comments

Comments
 (0)