Wrapper to display a script output or a text file content on the desktop in sway or other wlroots-based compositors

Overview

nwg-wrapper

This program is a part of the nwg-shell project.

This program is a GTK3-based wrapper to display a script output, or a text file content on the desktop in sway or other wlroots-based compositors. It uses the gtk-layer-shell library to place the window on the bottom layer.

As well the script output, at the text file may be formatted with Pango Markup. The window appearance is defined with css styling. See sample files in the config folder. They also come preinstalled in your ~/.config/nwg-wrapper directory. You can find an example of use at the bottom of the page.

Packaging status

Dependencies

  • python (python3)
  • python-gobject
  • gtk3
  • gtk-layer-shell
  • python-setuptools
  • python-i3ipc: for use with sway WM
  • wlr-randr: for use with other wlroots-based Wayland compositors

To install

git clone https://github.com/nwg-piotr/nwg-wrapper.git
cd nwg-wrapper
sudo python3 setup.py install --optimize=1

To uninstall

rm -r /usr/lib/python3.9/site-packages/nwg_wrapper*
rm /usr/bin/nwg-wrapper

The path in the first line may be different, depending on your python version.

Running

$ nwg-wrapper -h
usage: nwg-wrapper [-h] [-s SCRIPT | -t TEXT] [-c CSS] [-o OUTPUT] [-p POSITION] [-a ALIGNMENT]
                   [-j JUSTIFY] [-mt MARGIN_TOP] [-mb MARGIN_BOTTOM] [-ml MARGIN_LEFT]
                   [-mr MARGIN_RIGHT] [-r REFRESH] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -s SCRIPT, --script SCRIPT
                        Path to the script whose output you want to display
  -t TEXT, --text TEXT  Path to the text file you want to display
  -c CSS, --css CSS     Path to the css file
  -o OUTPUT, --output OUTPUT
                        Output to place the window on, e.g. "eDP-1"
  -p POSITION, --position POSITION
                        Position: "left" or "right"; "center" if no value given
  -a ALIGNMENT, --alignment ALIGNMENT
                        Vertical alignment: "start" or "end"; "middle" if no value given
  -j JUSTIFY, --justify JUSTIFY
                        Text justification: "right" or "center"; "left" if no value given
  -mt MARGIN_TOP, --margin_top MARGIN_TOP
                        Top margin
  -mb MARGIN_BOTTOM, --margin_bottom MARGIN_BOTTOM
                        Bottom margin
  -ml MARGIN_LEFT, --margin_left MARGIN_LEFT
                        Left margin
  -mr MARGIN_RIGHT, --margin_right MARGIN_RIGHT
                        Right margin
  -r REFRESH, --refresh REFRESH
                        Refresh rate in milliseconds; 0 (no refresh) if no value given
  -v, --version         display version information

Sample usage

nwg-wrapper -s date-wttr.sh -r 1800000 -c date-wttr.css -p left -ml 200

2021-07-10-050045_screenshot.png

nwg-wrapper -t bindings.pango -c bindings.css -p left -ml 200

2021-07-11-003357_screenshot.png

nwg-wrapper -s timezones.sh -r 1000 -c timezones.css -p right -mr 50 -a start -mt 50 -j right

2021-07-10-050810_screenshot.png

Comments
  • Allow different layer for wraper

    Allow different layer for wraper

    Feature request : to have an option to show wrapper in bottom or top layer.

    infact having an option like waybar where you can send a custom signal to a module will be awesome. an id can be given to wraper window which can be used to toggle surface layer . It sounds a bit over the edge but will be an aweosme option to have

    opened by Iss-in 13
  • Display on top of swaylock?

    Display on top of swaylock?

    I use swaylock to display a random image while locked:

    swaylock --daemonize --image "$IMAGE" &
    

    Is there any way to have nwg-wrapper display some text 'on top of' that image. I tried --layer=2 but it does not display (until I unlock!).

    opened by bhepple 9
  • Add sig refresh

    Add sig refresh

    it would be useful to add custom signals for script refresh so the script can be triggered by signals instead of constantly polling/refreshing. This is useful for things like album cover update on music player's track/status changes. By the way, do you guys think using real-time signal would be better? i.e. RTMIN+No. Think those status bars mostly use that for triggering update.

    opened by hillyu 7
  • Config files

    Config files

    I want to able able to define a config for wrapper instance in .ini file, so that this (for example) very verbose string nwg-wrapper -s swaylock-time.sh -o eDP-1 -r 1000 -c timezones.css -p right -mr 50 -a start -mt 0 -j right -l 3 -sq 31 can become that nwg-wrapper ~/.config/nwg-wrapper/time.ini

    with config file being in that format

    [wrapper]
    script=swaylock-time.sh
    output=eDP-1
    refresh=1000
    css=timezones.css
    position=right
    margin_right=50
    margin_top=0
    justify=right
    layer=3
    sig_quit=31
    

    I can implement that feature.

    opened by warezgibzzz 4
  • Signalling 8 to refresh doesn't work

    Signalling 8 to refresh doesn't work

    As the title says, script doesn't refresh when I signal 8 with pkill. But instead, if I run nwg-wrapper with --sig_refresh 7 flag, it does work if I signal 7. I have no idea why. Also, 7 is just random and 8 is the default of nwg_wrapper. Any help appreciated. Thanks.

    opened by MelihDarcanxyz 3
  • Support specifying output by

    Support specifying output by "make model serial", not just name

    The output names (like eDP-1) are unpredictable, and depend on the order in which you connect your external monitors. So the established way of binding programs and settings to outputs is to address the monitors by "Make model serial" (for example, Goldstar Company Ltd LG IPS FULLHD 604NTDV33634) which are unique. This is how Sway and Kanshi do it, for example.

    Can you please add the support for this to nwg-wrapper? I'd like to be able to do nwg-wrapper -o 'Goldstar Company Ltd LG IPS FULLHD 604NTDV33634' and have the overlay drawn on the specified monitor.

    https://git.sr.ht/~emersion/kanshi/tree/eddaeac2/item/main.c#L25

    Here, you can find an example of how Kanshi implements the matching logic. (Maybe you could even borrow the code from there.)

    Ivan

    opened by gnull 2
  • Fix: Match documented behavior of --sig_layer

    Fix: Match documented behavior of --sig_layer

    Currently, signalling nwg-wrapper with the configured layer signal will alternate its layer between layer 1 (bottom) and 2 (top) instead of between the provided --layer and 3 (overlay). This updates nwg-wrapper's behavior to match the documentation.

    (Found this when pkill -10 nwg-wrapper; swaylock "$@"; pkill -10 nwg-wrapper didn't do what I expected.)

    opened by xPMo 0
  • Feature: spawn window instance invisible on launch

    Feature: spawn window instance invisible on launch

    In some cases i want to be able to spawn a wrapper window instance that is visibly hidden and show it only when i want, i.e. on nwg-panel executor left click. This feature does just that, it adds a boolean flag, that when it passed, wrapper spawns visibly hidden.

    opened by warezgibzzz 0
  • add example

    add example

    added some script I used. on top of a few modifications I made. Included signal refresh patch. 6f95224102633fb708837771f5afa9b2798ff72e quit if output is offline: 19a734952524b7e43a8a0e665fecbe4e1f384e53 anchor issue: 2ec3082957cd966dd153ba9e65d2cb6d6f0c6b52 examples: ca8ea7163c6686ae327b97135f6ed53db85263d4

    opened by hillyu 0
  • Upgrade to Python 3.10

    Upgrade to Python 3.10

    How can we make this happen? I upgraded python to 3.10 on my computer and NWG stopped working due to pygobject not being compiled to support python 3.9.

    I wanna help. :D

    opened by FromOopsToOps 2
  • I need to sleep 1

    I need to sleep 1

    I've found that if I 'sleep 0.5' after nwg-wrapper and before running swaylock/gtklock, it doesn't always display correctly. Increasing the sleep to 1 second fixes it. I daresay this depends on the CPU speed etc, but it might be a good idea to document it in the README

    opened by bhepple 2
  • Adding actions

    Adding actions

    Hi.

    I'd like to add some actions to a nwg-wrapper to use it as a real desktop widget. For example, open a web link when I clicks or to change workspace with mouse wheel via swaymsg, etc. Is it possible?

    Thanks for the code!

    opened by RiccardoPP 1
  • Outputting a continuously running script without interval

    Outputting a continuously running script without interval

    An example, running the following script currently doesn't output anything.

    #!/usr/bin/env sh
    dbus-monitor --session "interface='org.freedesktop.Notifications',member='Notify',type='method_call'" | grep "method call"
    
    opened by arafatamim 1
  • Sixel support

    Sixel support

    It is almost ready to be full-on conky support, but one crutial pice is missing - graphs. And this "renderer" being so rightfully unixway I don't see a justification to implement something like custom protocol, no, but I also see that there is no way to render output of programs that already can draw them. Therefore I ask for sixel suppopt, that would make it a lot easier. And you can also render regular images with it.

    opened by 0Karakurt0 3
Releases(v0.1.3)
  • v0.1.3(Sep 11, 2022)

  • v0.1.2(Jan 7, 2022)

    • added custom signals for script refresh #10 by @hillyu
    • added some cools example scripts #11 by @hillyu
    • added single instance mode:

    With the -si | --single_instance argument you may force single instance mode. The program on startup checks the pid file stored in /tmp/nwg-wrapper.pid and kills the appropriate process. You can use this only once, as always the same file is used.

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Jan 3, 2022)

  • v0.1.0(Nov 8, 2021)

    • Different layer switching: the signal specified with the --sig_layer argument will switch to the overlay layer, and back to what you selected with the --layer argument;
    • added the -sq | --sig_quit argument, which allows to define a custom signal to terminate a certain wrapper instance, w/o killing the others.
    Source code(tar.gz)
    Source code(zip)
  • v0.0.3(Nov 5, 2021)

  • v0.0.2(Jul 17, 2021)

  • v0.0.1(Jul 10, 2021)

Owner
Piotr Miller
After hours developer, Linux fan, Arch Linux user
Piotr Miller
Khandakar Muhtasim Ferdous Ruhan 1 Dec 30, 2021
Text editor on python tkinter to convert english text to other languages with the help of ployglot.

Transliterator Text Editor This is a simple transliteration program which is used to convert english word to phonetically matching word in another lan

Merin Rose Tom 1 Jan 16, 2022
Fixes mojibake and other glitches in Unicode text, after the fact.

ftfy: fixes text for you >>> print(fix_encoding("(ง'⌣')ง")) (ง'⌣')ง Full documentation: https://ftfy.readthedocs.org Testimonials “My life is li

Luminoso Technologies, Inc. 3.4k Dec 29, 2022
Fixes mojibake and other glitches in Unicode text, after the fact.

ftfy: fixes text for you >>> print(fix_encoding("(ง'⌣')ง")) (ง'⌣')ง Full documentation: https://ftfy.readthedocs.org Testimonials “My life is li

Luminoso Technologies, Inc. 2.9k Feb 17, 2021
Prithivida 690 Jan 4, 2023
Translate U is capable of translating the text present in an image from one language to the other.

Translate U is capable of translating the text present in an image from one language to the other. The app uses OCR and Google translate to identify and translate across 80+ languages.

Neelanjan Manna 1 Dec 22, 2021
Ptorch NLU, a Chinese text classification and sequence annotation toolkit, supports multi class and multi label classification tasks of Chinese long text and short text, and supports sequence annotation tasks such as Chinese named entity recognition, part of speech tagging and word segmentation.

Pytorch-NLU,一个中文文本分类、序列标注工具包,支持中文长文本、短文本的多类、多标签分类任务,支持中文命名实体识别、词性标注、分词等序列标注任务。 Ptorch NLU, a Chinese text classification and sequence annotation toolkit, supports multi class and multi label classification tasks of Chinese long text and short text, and supports sequence annotation tasks such as Chinese named entity recognition, part of speech tagging and word segmentation.

null 186 Dec 24, 2022
📔️ Generate a text-based journal from a template file.

JGen ??️ Generate a text-based journal from a template file. Contents Getting Started Example Overview Usage Details Reserved Keywords Gotchas Getting

Harrison Broadbent 21 Sep 25, 2022
PocketSphinx is a lightweight speech recognition engine, specifically tuned for handheld and mobile devices, though it works equally well on the desktop

PocketSphinx 5prealpha This is PocketSphinx, one of Carnegie Mellon University's open source large vocabulary, speaker-independent continuous speech r

null 3.2k Dec 28, 2022
A desktop GUI providing an audio interface for GPT3.

Jabberwocky neil_degrasse_tyson_with_audio.mp4 Project Description This GUI provides an audio interface to GPT-3. My main goal was to provide a conven

null 16 Nov 27, 2022
Yomichad - a Japanese pop-up dictionary that can display readings and English definitions of Japanese words

Yomichad is a Japanese pop-up dictionary that can display readings and English definitions of Japanese words, kanji, and optionally named entities. It is similar to yomichan, 10ten, and rikaikun in spirit, but targets qutebrowser.

Jonas Belouadi 7 Nov 7, 2022
C.J. Hutto 3.8k Dec 30, 2022
C.J. Hutto 2.8k Feb 18, 2021
Saptak Bhoumik 14 May 24, 2022
A Python wrapper for simple offline real-time dictation (speech-to-text) and speaker-recognition using Vosk.

Simple-Vosk A Python wrapper for simple offline real-time dictation (speech-to-text) and speaker-recognition using Vosk. Check out the official Vosk G

null 2 Jun 19, 2022
Unsupervised text tokenizer for Neural Network-based text generation.

SentencePiece SentencePiece is an unsupervised text tokenizer and detokenizer mainly for Neural Network-based text generation systems where the vocabu

Google 6.4k Jan 1, 2023
Unsupervised text tokenizer for Neural Network-based text generation.

SentencePiece SentencePiece is an unsupervised text tokenizer and detokenizer mainly for Neural Network-based text generation systems where the vocabu

Google 4.8k Feb 18, 2021