From 31f60be7f472fbf9c2c4730b16ab86e52f3fc51a Mon Sep 17 00:00:00 2001 From: Plom Heller Date: Sat, 19 Sep 2026 00:15:11 +0200 Subject: [PATCH] Add wl-paste, to installs and to status bar. --- home/user/.config/sway/status.py | 35 ++++++++++++++++++++++++++++---- to_install/t490s | 5 ++++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/home/user/.config/sway/status.py b/home/user/.config/sway/status.py index 2e390e4..d29a5b5 100755 --- a/home/user/.config/sway/status.py +++ b/home/user/.config/sway/status.py @@ -13,6 +13,10 @@ from pactl import pactl_info_default_dev METADATA = {'version': 1} +CMD_PASTE = 'wl-paste' +CLIP_LEN_MAX = 32 +MSG_CLIPBOARD_EMPTY = 'Nothing is copied' + AUDIO_DEVS_LABELS = (('sink', 'vol'), ('source', '--mic')) @@ -37,6 +41,28 @@ def int_at_path( return int(stripped_text) +def info_clipboard( + ) -> tuple[str, ...]: + 'Produce clipboard contents summary.' + texts = [] + args: tuple[str, ...] + for args in (tuple(), ('--primary',)): + proc = subprocess_run((CMD_PASTE,) + args, + check=False, capture_output=True) + if proc.returncode: + stderr = proc.stderr.decode('utf8', 'replace').strip() + clip = '(empty)' if stderr == MSG_CLIPBOARD_EMPTY else '(error)' + else: + try: + clip = proc.stdout.decode('utf8').replace('\n', ' ').strip() + except UnicodeDecodeError: + clip = '(binary)' + if len(clip) > CLIP_LEN_MAX: + clip = clip[:CLIP_LEN_MAX] + '…' + texts += [f'{(args[0] if args else CMD_PASTE)}: [{clip}]'] + return tuple(texts) + + def info_audio( ) -> str: "Produce audio devices' volume, muteness." @@ -143,9 +169,10 @@ if __name__ == '__main__': print('[', end='') while True: print(json_dumps([{'full_text': text} - for text in info_network() + (info_battery(), - info_thermal(), - info_datetime(), - info_audio())]), + for text in info_clipboard() + info_network() + ( + info_battery(), + info_thermal(), + info_datetime(), + info_audio())]), end=',\n', flush=True) sleep(1) diff --git a/to_install/t490s b/to_install/t490s index e13553d..33263a6 100644 --- a/to_install/t490s +++ b/to_install/t490s @@ -3,12 +3,14 @@ # # basic helpers ack -ccrypt chrony git man-db python3 sudo +# for secrets +ccrypt +pmount # battery management tlp # networking @@ -19,6 +21,7 @@ firefox-esr foot vim-gtk3 sway +wl-clipboard wmenu xwayland # multimedia -- 2.30.2