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
Korean Sentence Embedding Repository

Korean-Sentence-Embedding 🍭 Korean sentence embedding repository. You can download the pre-trained models and inference right away, also it provides

80 Jan 02, 2023
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 classifi

186 Dec 24, 2022
To create a deep learning model which can explain the content of an image in the form of speech through caption generation with attention mechanism on Flickr8K dataset.

To create a deep learning model which can explain the content of an image in the form of speech through caption generation with attention mechanism on Flickr8K dataset.

Ragesh Hajela 0 Feb 08, 2022
Datasets of Automatic Keyphrase Extraction

This repository contains 20 annotated datasets of Automatic Keyphrase Extraction made available by the research community. Following are the datasets and the original papers that proposed them. If yo

LIAAD - Laboratory of Artificial Intelligence and Decision Support 163 Dec 23, 2022
Awesome-NLP-Research (ANLP)

Awesome-NLP-Research (ANLP)

Language, Information, and Learning at Yale 72 Dec 19, 2022
Sentiment Classification using WSD, Maximum Entropy & Naive Bayes Classifiers

Sentiment Classification using WSD, Maximum Entropy & Naive Bayes Classifiers

Pulkit Kathuria 173 Jan 04, 2023
Pipeline for fast building text classification TF-IDF + LogReg baselines.

Text Classification Baseline Pipeline for fast building text classification TF-IDF + LogReg baselines. Usage Instead of writing custom code for specif

Dani El-Ayyass 57 Dec 07, 2022
Large-scale open domain KNOwledge grounded conVERsation system based on PaddlePaddle

Knover Knover is a toolkit for knowledge grounded dialogue generation based on PaddlePaddle. Knover allows researchers and developers to carry out eff

606 Dec 28, 2022
A list of NLP(Natural Language Processing) tutorials built on Tensorflow 2.0.

A list of NLP(Natural Language Processing) tutorials built on Tensorflow 2.0.

Won Joon Yoo 335 Jan 04, 2023
ACL'22: Structured Pruning Learns Compact and Accurate Models

☕ CoFiPruning: Structured Pruning Learns Compact and Accurate Models This repository contains the code and pruned models for our ACL'22 paper Structur

Princeton Natural Language Processing 130 Jan 04, 2023
Japanese Long-Unit-Word Tokenizer with RemBertTokenizerFast of Transformers

Japanese-LUW-Tokenizer Japanese Long-Unit-Word (国語研長単位) Tokenizer for Transformers based on 青空文庫 Basic Usage from transformers import RemBertToken

Koichi Yasuoka 3 Dec 22, 2021
A Practitioner's Guide to Natural Language Processing

Learn how to process, classify, cluster, summarize, understand syntax, semantics and sentiment of text data with the power of Python! This repository contains code and datasets used in my book, Text

Dipanjan (DJ) Sarkar 1.5k Jan 03, 2023
Python functions for summarizing and improving voice dictation input.

Helpmespeak Help me speak uses Python functions for summarizing and improving voice dictation input. Get started with OpenAI gpt-3 OpenAI is a amazing

Margarita Humanitarian Foundation 6 Dec 17, 2022
In this project, we aim to achieve the task of predicting emojis from tweets. We aim to investigate the relationship between words and emojis.

Making Emojis More Predictable by Karan Abrol, Karanjot Singh and Pritish Wadhwa, Natural Language Processing (CSE546) under the guidance of Dr. Shad

Karanjot Singh 2 Jan 17, 2022
text to speech toolkit. 好用的中文语音合成工具箱,包含语音编码器、语音合成器、声码器和可视化模块。

ttskit Text To Speech Toolkit: 语音合成工具箱。 安装 pip install -U ttskit 注意 可能需另外安装的依赖包:torch,版本要求torch=1.6.0,=1.7.1,根据自己的实际环境安装合适cuda或cpu版本的torch。 ttskit的

KDD 483 Jan 04, 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 6.4k Jan 01, 2023
Reproduction process of BERT on SST2 dataset

BERT-SST2-Prod Reproduction process of BERT on SST2 dataset 安装说明 下载代码库 git clone https://github.com/JunnYu/BERT-SST2-Prod 进入文件夹,安装requirements pip ins

yujun 1 Nov 18, 2021
An implementation of model parallel GPT-3-like models on GPUs, based on the DeepSpeed library. Designed to be able to train models in the hundreds of billions of parameters or larger.

GPT-NeoX An implementation of model parallel GPT-3-like models on GPUs, based on the DeepSpeed library. Designed to be able to train models in the hun

EleutherAI 3.1k Jan 08, 2023
The (extremely) naive sentiment classification function based on NBSVM trained on wisesight_sentiment

thai_sentiment The naive sentiment classification function based on NBSVM trained on wisesight_sentiment วิธีติดตั้ง pip install thai_sentiment==0.1.3

Charin 7 Dec 08, 2022
Code for the paper "BERT Loses Patience: Fast and Robust Inference with Early Exit".

Patience-based Early Exit Code for the paper "BERT Loses Patience: Fast and Robust Inference with Early Exit". NEWS: We now have a better and tidier i

Kevin Canwen Xu 54 Jan 04, 2023