Skip to content

Commit 52e15eb

Browse files
authored
Merge branch 'dev' into hyprlock-keybinding
2 parents 171aa69 + 7eb1208 commit 52e15eb

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

Configs/.config/menus/applications.menu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
3-
"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd">
3+
"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
44

55
<Menu>
66
<Name>Applications</Name>

Configs/.local/lib/hyde/globalcontrol.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ get_rofi_pos() {
439439
#? handle pasting
440440
paste_string() {
441441
if ! command -v wtype >/dev/null; then exit 0; fi
442-
if [ -t 0 ] || [ -t 1 ]; then return 0; fi
442+
if [ -t 1 ]; then return 0; fi
443443
ignore_paste_file="$HYDE_STATE_HOME/ignore.paste"
444444

445445
if [[ ! -e "${ignore_paste_file}" ]]; then

Configs/.local/lib/hyde/mediaplayer.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,41 @@ def create_tooltip_text(
7171

7272
return tooltip
7373

74-
75-
def write_output(track, artist, playing, player, tooltip_text):
76-
logger.info("Writing output")
77-
74+
def format_artist_track(artist, track, playing, max_length):
7875
# Use the appropriate prefix based on playback status
7976
prefix = prefix_playing if playing else prefix_paused
80-
max_length = max_length_module
81-
82-
# Calculate the total length and truncate track if necessary
83-
total_length = len(track) + len(artist)
84-
if total_length > max_length:
85-
available_length = max(0, max_length - len(artist))
86-
track = (
87-
f"{track[:available_length]}…" if len(track) > available_length else track
88-
)
77+
prefix_separator = "  "
78+
separator = "  "
79+
full_length = len(artist + track)
8980

90-
# Generate the "text" based on the presence of track and artist
9181
if track and not artist:
92-
output_text = f"{prefix}  <b>{track}</b>"
82+
if len(track) != track[:max_length]:
83+
track = track[:max_length].rstrip() + "…"
84+
output_text = f"{prefix}{prefix_separator}<b>{track}</b>"
9385
elif track and artist:
94-
output_text = f"{prefix}  <i>{artist}</i>  <b>{track}</b>"
86+
if full_length > max_length:
87+
# proportion how to share max length between track and artist
88+
artist_weight = 0.65
89+
track_weight = 1 - artist_weight
90+
artist_limit = int(max_length * artist_weight)
91+
track_limit = int(max_length * track_weight)
92+
93+
if len(artist) != artist[:artist_limit]:
94+
artist = artist[:artist_limit].rstrip() + "…"
95+
if len(track) != track[:track_limit]:
96+
track = track[:track_limit].rstrip() + "…"
97+
98+
output_text = f"{prefix}{prefix_separator}<i>{artist}</i>{separator}<b>{track}</b>"
9599
else:
96100
output_text = "<b>Nothing playing</b>"
101+
return output_text
102+
103+
104+
def write_output(track, artist, playing, player, tooltip_text):
105+
logger.info("Writing output")
97106

98107
output_data = {
99-
"text": output_text,
108+
"text": format_artist_track(artist, track, playing, max_length_module),
100109
"class": "custom-" + player.props.player_name,
101110
"alt": player.props.player_name,
102111
"tooltip": tooltip_text,

0 commit comments

Comments
 (0)