• Stars
    star
    198
  • Rank 196,898 (Top 4 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A text scroller for panels or terminals

Zscroll

https://github.com/noctuid/zscroll/actions/workflows/test.yml/badge.svg https://codecov.io/github/noctuid/zscroll/coverage.svg?branch=master https://img.shields.io/badge/code%20style-black-000000.svg

The most common use cases are described in this README. For complete information on every flag, please see the man page (or the help text for basic information on every flag).

Version 2.0 Breaking Changes

  • Long options are now hyphenated (e.g. --update-check)
  • All boolean options take an argument (e.g. --scroll false)
  • Newlines will be used by default (--newline defaults to true) as zscroll’s primary use case is for panels, and this behavior is necessary for scrolling to work with polybar and lemonbar.
  • -m / -M syntax has changed to eliminate the previous complicated rules
  • The -f and -c flags have been removed. I don’t see them as having a legitimate use case (the default behavior for handling fullwidth characters is much saner), but if anyone would like them back, feel free to make an issue. -c would count fullwidth characters as length 1, causing the scrolling text length to change. -f would convert all letters to fullwidth if any fullwidth letters were found.

Simple Example

Scroll the currently playing mpd song:

$ zscroll -b "⮕ " "$(mpc current)"
# or
$ mpc current | zscroll -b "⮕ "

By default, zscroll will add ” - ” between the end and start of scrolling text. This can be adjusted with the -p option. Here is a zoomed in example of the above command (with a 0.4 second update delay):

http://noctuid.github.io/zscroll/assets/example_bar.gif

Installation

Arch

Install zscroll-git from the AUR.

Nix

Nix is a distro-independent package manager.

$ nix-env -i zscroll

Manual

$ git clone https://github.com/noctuid/zscroll
$ cd zscroll
$ sudo python3 setup.py install

This program will not work with Python 2. For this reason you must install with Python 3. This can be done in Ubuntu with sudo python3 setup.py install and may be the same for other distributions. If this does not work for you, please consult your distribution’s documentation.

Note: asdf users might have to run asdf reshim command before using zscroll.

Dynamically Updating Text

Zscroll can now update its text by itself. This may be nice for panels that don’t allow for the user to conditionally start new processes. It also simplifies the logic necessary to change settings for the scrolling text and gets rid of the need for an ugly function to repeatedly kill and start the scroller.

A simple use case is where one might want to display the current window’s title. This can be done with the -u option, which will run zscroll’s positional argument as a shell command to check for changes:

zscroll -b "| " -a " |" -u true "xtitle"

Zscroll even supports more complex updates by searching for a regular expression in the output of a command to determine whether certain settings should be changed. As an example, this can be useful for displaying a pause icon and prevent scrolling when the current song is paused. The following command will take these actions when “paused” is found in the output of the shell command mpc status:

zscroll --before-text "♪ x" --delay 0.3 \
		--match-command "mpc status" \
		--match-text "playing" "--before-text 'î‚š '" \
		--match-text "paused" "--before-text 'î‚› ' --scroll 0" \
		--update-check true "mpc current"
# or shortopts
zscroll -b "♪ x" -d 0.3 \
		-M "mpc status" \
		-m "playing" "-b 'î‚š '" \
		-m "paused" "-b 'î‚› ' -s 0" \
		-u t "mpc current"

New options (and possibly new scroll-text) should be specified as the second argument to every -m. Options not specified with an -m will default to the user-specified values outside of the -m (or the base defaults). Any option can be altered when a -m search term is found (except for -m and -M, which will be ignored). Note that when multiple -m options happen to be matched, it is the last one that will take effect.

See the man page for more information.

Fullwidth Characters

Zscroll intelligently deals with fullwidth characters by default by counting them as twice the length of halfwidth characters (and phasing them in and out in two steps). This ensures that the actual visual length and speed of the scrolling text does not change. Here is a normal-sized gif of the above command that demonstrates this:

http://noctuid.github.io/zscroll/assets/music_scroll.gif

Use with Polybar

Here’s an example of using zscroll instead of polybar’s mpd module.

In polybar config:

[module/mpd]
type = custom/script
exec = /path/to/script
tail = true

label-foreground = ${colors.music}

In the script:

#!/usr/bin/env bash

zscroll --before-text "♪ x" --delay 0.3 \
		--match-command "mpc status" \
		--match-text "playing" "--before-text 'î‚š '" \
		--match-text "paused" "--before-text 'î‚› ' --scroll 0" \
		--update-check true "mpc current" &

wait

For an alternate method that does not use zscroll’s dynamic updating, see here.

Similar

Why

I was using benghaem’s scroller for a while. I didn’t like that the arguments were all positional, the lack of a right text padding option, and the lack of an option to change the scroll speed. I found skroll afterwards which is nicer since it has options and an actual man page and is in the AUR. However, it doesn’t have a left text padding option which was necessary for my bar script to work properly. Also, they are both written in C, which doesn’t seem practical to me for such a simple script and is the main reason I created zscroll instead of contributing.

Zscroll supports the features I liked from each. It has a speed option, adds an option for right padding text, will work on text as an argument or piped into it, handles fullwidth characters intelligently, and has other advanced features.

I called this zscroll because it’s the last scroller I’ll use… but more importantly because I couldn’t think of another name.

Contributing

Zscroll is using black and isort for automatic formatting and import sorting. flake8 and pylint, and pydocstyle are used for linting. pytest is used for testing.

Development dependencies can be installed with make deps or poetry installed (poetry must be installed first). If you want to make a PR, please write tests for any added or fixed functionality and make sure that the code passes make lint and make test.

To automatically format with black when committing and abort the commit if there are any flake8 errors, you can install pre-commit and run pre-commit install once in the repository root after cloning.

More Repositories

1

evil-guide

Draft of a guide for using emacs with evil
1,245
star
2

tdrop

A Glorified WM-Independent Dropdown Creator
Shell
1,103
star
3

general.el

More convenient key definitions in emacs
Emacs Lisp
985
star
4

dotfiles

Mouseless Workflow (WIP)
Shell
482
star
5

lispyville

lispy + evil = lispyville
Emacs Lisp
313
star
6

link-hint.el

Pentadactyl-like Link Hinting in Emacs with Avy
Emacs Lisp
159
star
7

mpv-webtorrent-hook

Stream torrents in mpv using webtorrent-cli
Lua
90
star
8

targets.el

Dead (will eventually be replaced by things.el)
Emacs Lisp
77
star
9

things.el

Extensions to thingatpt.el
Emacs Lisp
51
star
10

annalist.el

Record and display information such as keybindings
Emacs Lisp
36
star
11

vertigo.el

Jump lines using the home row
Emacs Lisp
30
star
12

emacs-sentence-navigation

(Broken) Better Sentence Movement Commands and Evil Text Objects
Emacs Lisp
29
star
13

parinfer-notes

My notes about parinfer
28
star
14

evil-textobj-anyblock

Expanded Port of the Vim textobj-anyblock Plugin (to be deprecated in favor of targets.el)
Emacs Lisp
28
star
15

framegroups.el

Workspaces for emacs using frames
Emacs Lisp
22
star
16

gallery-dl-view

Mpv integration with gallery-dl
Clojure
16
star
17

mpv-btfs-stream

Stream torrents in mpv using btfs
Lua
15
star
18

evil-textobj-column

Column Text Objects for Evil
Emacs Lisp
14
star
19

mpv-peerflix-hook

Stream magnet links in mpv with peerflix
Lua
7
star
20

chronicler.el

Track and Analyze Writing Statistics for Org Files in Emacs
Emacs Lisp
6
star
21

rect-ext.el

Adds commands to simulate widening and narrowing for rectangles
Emacs Lisp
5
star
22

with-gnu-utils

wrapper script for running Linux bash scripts on OSX/BSD
Shell
5
star
23

cl-chronicler

Track and analyze writing statistics for Org (and other markup) files
Common Lisp
4
star
24

osx-dotfiles

Shell
1
star
25

mac-wallpapers

1
star
26

noctuid.github.io

HTML
1
star