Skip to content

Commit 733a8f2

Browse files
committed
update labels display
1 parent 461b2d2 commit 733a8f2

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

src/wlr_layout_ui/displaywidget.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
from pyglet.text import Label
66

77
from .screens import Screen
8-
from .utils import Rect, brighten
8+
from .utils import Rect, brighten, simplify_model_name
99
from .widgets import Widget
1010

1111
ANIMATION_LENGTH = 8
1212

1313

14+
def limit_size(text):
15+
if len(text) > 17:
16+
return text[:14] + "..."
17+
return text
18+
19+
1420
class GuiScreen(Widget):
1521
def __repr__(self):
1622
return "<Screen %s (%s) - %s>" % (self.rect, self.color, self.screen.name)
@@ -117,7 +123,7 @@ def draw(self, cursor):
117123
# Render the screen uid as text
118124
tx, ty = self.rect.center
119125
Label(
120-
self.screen.uid,
126+
limit_size(simplify_model_name(self.screen.name)),
121127
anchor_x="center",
122128
anchor_y="center",
123129
x=tx,
@@ -129,9 +135,9 @@ def draw(self, cursor):
129135
# Second caption line
130136
if self.screen.active:
131137
assert self.screen.mode
132-
label = f"{self.screen.mode.width}x{self.screen.mode.height}"
138+
label = f"{self.screen.mode.width}x{self.screen.mode.height}@{self.screen.mode.freq}"
133139
Label(
134-
label,
140+
self.screen.uid,
135141
anchor_x="center",
136142
anchor_y="center",
137143
x=tx,
@@ -140,7 +146,7 @@ def draw(self, cursor):
140146
bold=self.screen.active,
141147
).draw()
142148
Label(
143-
f"{self.screen.mode.freq}Hz",
149+
label,
144150
anchor_x="center",
145151
anchor_y="center",
146152
x=tx,

src/wlr_layout_ui/gui.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .utils import (
2121
Rect,
2222
compute_bounding_box,
23+
simplify_model_name,
2324
config,
2425
find_matching_mode,
2526
make_command,
@@ -29,7 +30,6 @@
2930
)
3031
from .widgets import Button, Dropdown, HBox, Style, VBox, Widget, Spacer
3132

32-
hex_re = re.compile("^[0-9x]+$")
3333

3434
CONFIRM_DELAY = 20
3535

@@ -370,11 +370,7 @@ def get_status_text(self):
370370
if self.text_input is not None:
371371
return f'Press ENTER to validate "{self.text_input}"'
372372
elif self.selected_item:
373-
words = []
374-
for word in self.selected_item.screen.name.split():
375-
if not hex_re.match(word):
376-
words.append(word)
377-
return " ".join(words)
373+
return simplify_model_name(self.selected_item.screen.name)
378374
else:
379375
return "Select a monitor to edit its settings"
380376

src/wlr_layout_ui/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
import re
12
from dataclasses import dataclass
23

34
config = {"hyprland": False}
45

6+
hex_re = re.compile("^[0-9x]+$")
7+
8+
9+
def simplify_model_name(name):
10+
words = []
11+
for word in name.split():
12+
if not hex_re.match(word):
13+
words.append(word)
14+
return " ".join(words)
15+
516

617
def make_command(screens, rects, wayland=True):
718
if wayland and config.get("hyprland"):

0 commit comments

Comments
 (0)