Giter Site home page Giter Site logo

h1romas4 / zellij-datetime Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 2.0 1.32 MB

This plugin adds a date and time pane to [Zellij](https://zellij.dev/), a terminal workspace.

Home Page: https://another.maple4ever.net/archives/3271/

License: MIT License

Rust 100.00%
zellij zellij-plugin webassemby rust wasi wasmer

zellij-datetime's Introduction

zellij-datetime

This plugin adds a date and time pane to Zellij, a terminal workspace.

zellij-08.png

Zellij's plugin system leverages WebAssembly/WASI, and this plugin will also work with both amd64 and Arm in the same binary.

Require

  • Zellij 0.38.0 or later
$ zellij -V
zellij 0.38.0

Setup

Preparation of Plug-in deployment destination:

# create configuration directory
mkdir -p ~/.config/zellij/layouts/
mkdir -p ~/.config/zellij/plugins/
# If you have already created a layout file, you do not need to do the following.
# export default layout (Be careful not to overwrite your settings)
zellij setup --dump-layout default > ~/.config/zellij/layouts/default.kdl

Download zellij-datetime.wasm:

cd ~/.config/zellij/plugins/
# download datetime plugin
wget -O zellij-datetime.wasm \
    https://github.com/h1romas4/zellij-datetime/releases/latest/download/zellij-datetime.wasm

Set the full path to zellij-datetime.wasm in the ~/.config/zellij/layouts/default.kdl layouts file.

vi ~/.config/zellij/layouts/default.kdl
layout {
    pane size=1 borderless=true {
        plugin location="file:/home/hiromasa/.config/zellij/plugins/zellij-datetime.wasm"
    }
    pane size=1 borderless=true {
        plugin location="zellij:tab-bar"
    }
    pane
    pane size=2 borderless=true {
        plugin location="zellij:status-bar"
    }
}

Usage

  • Timezone can be selected by left mouse click or scrolling.
  • Insert a date/time string into current pane with a right mouse click. (Require enable_right_click true plugin setting)
zellij-06.mp4

Plugin settings

layout {
    pane size=1 borderless=true {
        plugin location="file:/home/hiromasa/.config/zellij/plugins/zellij-datetime.wasm" {
            timezone1 "PDT/-9"
            timezone2 "UTC/0"
            timezone3 "CEST/+2"
            timezone4 "JST/+9"
            timezone5 "NPT/+5.75"
            default_timezone "JST"
            background_color "#0080a0"
            foreground_color "#ffffff"
            pane_color "#1e1e1e"
            enable_right_click false
            arrow_separator1 ""
            arrow_separator2 ""
            arrow_separator3 ""
            padding_adjust 0
            text_align "right"
        }
    }
}
Key Format Default Note
timezone1 "name/offset" "UTC/0"
timezone[2-9] "name/offset" -
default_timezone "name" "UTC"
background_color "#color" "#0080a0"
foreground_color "#color" "#ffffff" It may be adjusted automatically depending on the background_color.
pane_color "#color" "#1e1e1e"
enable_right_click bool false Right-clicking on the clock outputs the string format to stdin; Allow PermissionType::WriteToStdin permission when starting the plugin.
arrow_separator1 "string" "" Delimiter string on line. Only the first character.
arrow_separator2 "string" "" 📅 Only the first character.
arrow_separator3 "string" "" ⌚ Only the first character.
padding_adjust i32 0 It can be used to adjust left-justified padding. For example, adjusting the separator width if it is off by full-width.
text_align "string" "right" right or left or center

Build

Development

# If you don't have Zellij installed already
cargo install --locked zellij
# Git clone
git clone https://github.com/h1romas4/zellij-datetime
cd zellij-datetime
# Building the plugin
cargo build
# Running in Zellij
zellij -l plugin.kdl

Production

# Install wasm-snip
cargo install wasm-snip
# Build
cargo build --release
# Remove debug symbols and replaces unreachable.
wasm-snip target/wasm32-wasi/release/zellij-datetime.wasm -o target/wasm32-wasi/release/zellij-datetime-snip.wasm
# Deploy plugin directory
cp -p target/wasm32-wasi/release/zellij-datetime-snip.wasm ~/.config/zellij/plugins/zellij-datetime.wasm
# Running in Zellij
zellij

Development on Ubuntu 22.04 with container

  • It can be tested on the main branch of Zellij.
  • There is no confusion with the current Zellij session.
  • You can test the operation of the plugin authority from the initial state.
git clone https://github.com/zellij-org/zellij.git
git clone https://github.com/h1romas4/zellij-datetime
# build Zellij (A newer version of protobuf-compiler is required)
cd zellij
cargo xtask build --release
# build zellij-datetime
cd ../zellij-datetime
cargo build
# Run with container (podman or docker)
podman run \
    --name zellij-datetime \
    --env SHELL=/usr/bin/bash \
    -v ../zellij/target/release/:/opt/zellij \
    -v .:/opt/zellij-datetime \
    -w /opt/zellij-datetime \
    -it --rm \
    mcr.microsoft.com/devcontainers/base:ubuntu-22.04 \
    /opt/zellij/zellij -l plugin.kb

License

MIT License

WIP

  • Support for changing timezone by click or scroll on a pane.
  • Support for timezone definition files.
  • Binary size reduction.
  • Improved parsing of configuration files.
  • Support for background color specification.
  • When a Zellij session is detached and reattached, the plugin stops without getting drawing and timer events. #2575
  • Unnecessary borderlines appear when this plugin is placed at the bottom of the workspace with borderless=true.
  • Display is disturbed when the screen width is smaller than the display string.
  • Separate control of the line from control of datetime string generation. Support for Zellij UI components. Rendering a UI - Zellij User Guide

Note

Operation log in riscv64

At this time, RISC-V is not yet supported in Wasmer 3.1.1 used by Zellij. RISC-V has been supported since Wasmer 3.2.

$ uname -a
Linux lpi4a 5.10.113-gbb4691fe5572 # riscv64 GNU/Linux
$ arch
riscv64
$ rustc -V
rustc 1.65.0 #riscv64gc-unknown-linux-gnu
$ zellij -V
zellij 0.36.0
$ zellij
Error occurred in server:

  × Thread 'async-std/runtime' panicked.
  ├─▶ At /home/sipeed/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-compiler-cranelift-2.3.0/src/config.rs:73:45
  ╰─▶ construct Cranelift ISA for triple: Unsupported
  help: If you are seeing this message, it means that something went wrong.

        -> To get additional information, check the log at: /tmp/zellij-1001/zellij-log/zellij.log
        -> To see a backtrace next time, reproduce the error with: RUST_BACKTRACE=1 zellij [...]
        -> To help us fix this, please open an issue: https://github.com/zellij-org/zellij/issues

zellij-datetime's People

Contributors

h1romas4 avatar rajil1213 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

isgasho rajil1213

zellij-datetime's Issues

Allow reading config from "well known" location

At the moment reading the config file from the startup directory is a) unexpected and b) annoying.

Suggest to add functionality to also look for the file in $HOME/.config/zellij and/or $ZELLIJ_CONFIG_DIR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.