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
NLP command-line assistant powered by OpenAI

NLP command-line assistant powered by OpenAI

Axel 16 Dec 09, 2022
Stuff related to Ben Eater's 8bit breadboard computer

8bit breadboard computer simulator This is an assembler + simulator/emulator of Ben Eater's 8bit breadboard computer. For a version with its RAM upgra

Marijn van Vliet 29 Dec 29, 2022
Associated Repository for "Translation between Molecules and Natural Language"

MolT5: Translation between Molecules and Natural Language Associated repository for "Translation between Molecules and Natural Language". Table of Con

67 Dec 15, 2022
A simple word search made in python

Word Search Puzzle A simple word search made in python Usage $ python3 main.py -h usage: main.py [-h] [-c] [-f FILE] Generates a word s

Magoninho 16 Mar 10, 2022
A python wrapper around the ZPar parser for English.

NOTE This project is no longer under active development since there are now really nice pure Python parsers such as Stanza and Spacy. The repository w

ETS 49 Sep 12, 2022
Kerberoast with ACL abuse capabilities

targetedKerberoast targetedKerberoast is a Python script that can, like many others (e.g. GetUserSPNs.py), print "kerberoast" hashes for user accounts

Shutdown 213 Dec 22, 2022
Winner system (DAMO-NLP) of SemEval 2022 MultiCoNER shared task over 10 out of 13 tracks.

KB-NER: a Knowledge-based System for Multilingual Complex Named Entity Recognition The code is for the winner system (DAMO-NLP) of SemEval 2022 MultiC

116 Dec 27, 2022
ZUNIT - Toward Zero-Shot Unsupervised Image-to-Image Translation

ZUNIT Dependencies you can install all the dependencies by pip install -r requirements.txt Datasets Download CUB dataset. Unzip the birds.zip at ./da

Chen Yuanqi 9 Jun 24, 2022
Implementation of some unbalanced loss like focal_loss, dice_loss, DSC Loss, GHM Loss et.al

Implementation of some unbalanced loss for NLP task like focal_loss, dice_loss, DSC Loss, GHM Loss et.al Summary Here is a loss implementation reposit

121 Jan 01, 2023
Open-Source Toolkit for End-to-End Speech Recognition leveraging PyTorch-Lightning and Hydra.

OpenSpeech provides reference implementations of various ASR modeling papers and three languages recipe to perform tasks on automatic speech recogniti

Soohwan Kim 26 Dec 14, 2022
WIT (Wikipedia-based Image Text) Dataset is a large multimodal multilingual dataset comprising 37M+ image-text sets with 11M+ unique images across 100+ languages.

WIT (Wikipedia-based Image Text) Dataset is a large multimodal multilingual dataset comprising 37M+ image-text sets with 11M+ unique images across 100+ languages.

Google Research Datasets 740 Dec 24, 2022
code for modular summarization work published in ACL2021 by Krishna et al

This repository contains the code for running modular summarization pipelines as described in the publication Krishna K, Khosla K, Bigham J, Lipton ZC

Approximately Correct Machine Intelligence (ACMI) Lab 21 Nov 24, 2022
Vad-sli-asr - A Python scripts for a speech processing pipeline with Voice Activity Detection (VAD)

VAD-SLI-ASR Python scripts for a speech processing pipeline with Voice Activity

Dynamics of Language 14 Dec 09, 2022
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context

Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context This repository contains the code in both PyTorch and TensorFlow for our paper

Zhilin Yang 3.3k Dec 28, 2022
This repository contains examples of Task-Informed Meta-Learning

Task-Informed Meta-Learning This repository contains examples of Task-Informed Meta-Learning (paper). We consider two tasks: Crop Type Classification

10 Dec 19, 2022
A Facebook Messenger Chatbot using NLP

A Facebook Messenger Chatbot using NLP This project is about creating a messenger chatbot using basic NLP techniques and models like Logistic Regressi

6 Nov 20, 2022
Active learning for text classification in Python

Active Learning allows you to efficiently label training data in a small-data scenario.

Webis 375 Dec 28, 2022
BROS: A Pre-trained Language Model Focusing on Text and Layout for Better Key Information Extraction from Documents

BROS (BERT Relying On Spatiality) is a pre-trained language model focusing on text and layout for better key information extraction from documents. Given the OCR results of the document image, which

Clova AI Research 94 Dec 30, 2022
Unsupervised Document Expansion for Information Retrieval with Stochastic Text Generation

Unsupervised Document Expansion for Information Retrieval with Stochastic Text Generation Official Code Repository for the paper "Unsupervised Documen

NLP*CL Laboratory 2 Oct 26, 2021