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
Write Python in Urdu - اردو میں کوڈ لکھیں

UrduPython Write simple Python in Urdu. How to Use Write Urdu code in سامپل۔پے The mappings are as following: "۔": ".", "،":

Saad A. Bazaz 26 Nov 27, 2022
Turkish Stop Words Türkçe Dolgu Sözcükleri

trstop Turkish Stop Words Türkçe Dolgu Sözcükleri In this repository I put Turkish stop words that is contained in the first 10 thousand words with th

Ahmet Aksoy 103 Nov 12, 2022
2021 2학기 데이터크롤링 기말프로젝트

공지 주제 웹 크롤링을 이용한 취업 공고 스케줄러 스케줄 주제 정하기 코딩하기 핵심 코드 설명 + 피피티 구조 구상 // 12/4 토 피피티 + 스크립트(대본) 제작 + 녹화 // ~ 12/10 ~ 12/11 금~토 영상 편집 // ~12/11 토 웹크롤러 사람인_평균

Choi Eun Jeong 2 Aug 16, 2022
A framework for implementing federated learning

This is partly the reproduction of the paper of [Privacy-Preserving Federated Learning in Fog Computing](DOI: 10.1109/JIOT.2020.2987958. 2020)

DavidChen 46 Sep 23, 2022
Code for our ACL 2021 paper - ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer

ConSERT Code for our ACL 2021 paper - ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer Requirements torch==1.6.0

Yan Yuanmeng 478 Dec 25, 2022
Product-Review-Summarizer - Created a product review summarizer which clustered thousands of product reviews and summarized them into a maximum of 500 characters, saving precious time of customers and helping them make a wise buying decision.

Product-Review-Summarizer - Created a product review summarizer which clustered thousands of product reviews and summarized them into a maximum of 500 characters, saving precious time of customers an

Parv Bhatt 1 Jan 01, 2022
A simple Streamlit App to classify swahili news into different categories.

Swahili News Classifier Streamlit App A simple app to classify swahili news into different categories. Installation Install all streamlit requirements

Davis David 4 May 01, 2022
2021语言与智能技术竞赛:机器阅读理解任务

LICS2021 MRC 1. 项目&任务介绍 本项目基于官方给定的baseline(DuReader-Checklist-BASELINE)进行二次改造,对整个代码框架做了简单的重构,对核心网络结构添加了注释,解耦了数据读取的模块,并添加了阈值确认的功能,一些小的细节也做了改进。 本次任务为202

roar 29 Dec 05, 2022
Speech to text streamlit app

Speech to text Streamlit-app! 👄 This speech to text recognition is powered by t

Charly Wargnier 9 Jan 01, 2023
The official implementation of "BERT is to NLP what AlexNet is to CV: Can Pre-Trained Language Models Identify Analogies?, ACL 2021 main conference"

BERT is to NLP what AlexNet is to CV This is the official implementation of BERT is to NLP what AlexNet is to CV: Can Pre-Trained Language Models Iden

Asahi Ushio 20 Nov 03, 2022
🤗🖼️ HuggingPics: Fine-tune Vision Transformers for anything using images found on the web.

🤗 🖼️ HuggingPics Fine-tune Vision Transformers for anything using images found on the web. Check out the video below for a walkthrough of this proje

Nathan Raw 185 Dec 21, 2022
Official code for Spoken ObjectNet: A Bias-Controlled Spoken Caption Dataset

Official code for our Interspeech 2021 - Spoken ObjectNet: A Bias-Controlled Spoken Caption Dataset [1]*. Visually-grounded spoken language datasets c

Ian Palmer 3 Jan 26, 2022
Asr abc - Automatic speech recognition(ASR),中文语音识别

语音识别的简单示例,主要在课堂演示使用 创建python虚拟环境 在linux 和macos 上验证通过 # 如果已经有pyhon3.6 环境,跳过该步骤,使用

LIyong.Guo 8 Nov 11, 2022
Mycroft Core, the Mycroft Artificial Intelligence platform.

Mycroft Mycroft is a hackable open source voice assistant. Table of Contents Getting Started Running Mycroft Using Mycroft Home Device and Account Man

Mycroft 6.1k Jan 09, 2023
Deep learning for NLP crash course at ABBYY.

Deep NLP Course at ABBYY Deep learning for NLP crash course at ABBYY. Suggested textbook: Neural Network Methods in Natural Language Processing by Yoa

Dan Anastasyev 597 Dec 18, 2022
The following links explain a bit the idea of semantic search and how search mechanisms work by doing retrieve and rerank

Main Idea The following links explain a bit the idea of semantic search and how search mechanisms work by doing retrieve and rerank Semantic Search Re

Sergio Arnaud Gomez 2 Jan 28, 2022
Coreference resolution for English, French, German and Polish, optimised for limited training data and easily extensible for further languages

Coreferee Author: Richard Paul Hudson, Explosion AI 1. Introduction 1.1 The basic idea 1.2 Getting started 1.2.1 English 1.2.2 French 1.2.3 German 1.2

Explosion 70 Dec 12, 2022
Smart discord chatbot integrated with Dialogflow to manage different classrooms and assist in teaching!

smart-school-chatbot Smart discord chatbot integrated with Dialogflow to interact with students naturally and manage different classes in a school. De

Tom Huynh 5 Oct 24, 2022
Simple multilingual lemmatizer for Python, especially useful for speed and efficiency

Simplemma: a simple multilingual lemmatizer for Python Purpose Lemmatization is the process of grouping together the inflected forms of a word so they

Adrien Barbaresi 70 Dec 29, 2022
a chinese segment base on crf

Genius Genius是一个开源的python中文分词组件,采用 CRF(Conditional Random Field)条件随机场算法。 Feature 支持python2.x、python3.x以及pypy2.x。 支持简单的pinyin分词 支持用户自定义break 支持用户自定义合并词

duanhongyi 237 Nov 04, 2022