项目作者: filiparag

项目描述 :
wmrc is a shell utility for extending window manager capabilities using modules with dependency and error checking.
高级语言: Shell
项目地址: git://github.com/filiparag/wmrc.git
创建时间: 2020-03-19T21:25:12Z
项目社区:https://github.com/filiparag/wmrc

开源协议:MIT License

下载


About

wmrc is a shell script framework for extending window manager capabilities
using modules with dependency and error checking.

The goal of this utility is to help you maintain a set of concise and ergonomic
scripts (modules) for configuring and customizing various aspects of a custom
desktop environment. It comes with only a few batteries included, in order to
provide maximum portability and modularity across different operating systems,
window managers and init daemons.

Installation

Arch Linux (AUR)

  1. paru -S aur/wmrc

Generic instructions

  1. git clone 'https://github.com/filiparag/wmrc'
  2. cd ./wmrc
  3. sudo make install

Modules

Modules are groups of arbitrary POSIX-compliant shell scripts located in
$HOME/.config/wmrc/modules/<group>/<module>. Each module should be responsible
for one functionality of the desktop environment — for instance, module
polybar in group screen is tasked with configuring and running all bars.

Modules can invoke special libwmrc functions and access global
variables which are injected into them before execution. These functions
implement common functionality for interfacing with wmrc, logging and daemon
control. Their implementation can be overridden when necessary.

Each module can have WMRC_DEPENDENCIES global variable declaring needed system
executables and wmrc modules it calls. If multiple modules share functionality,
they can import custom wmrc libraries by declaring them in the WMRC_LIBRARIES
variable. These libraries are sources from $HOME/.config/wmrc/modules/libs.
Dependencies and libraries are checked before module execution, in order to
prevent errors and undefined behavior.

Example module

Module screen/vnc for controlling VNC server:

  1. #!/bin/sh
  2. export WMRC_DEPENDENCIES='x0vncserver'
  3. start() {
  4. if ! [ -f "$HOME/.vnc/passwd" ]; then
  5. error "Password for VNC server is not set!"
  6. return 1
  7. fi
  8. if daemon_get_pid; then
  9. error "VNC server is already running!"
  10. return 1
  11. fi
  12. x0vncserver --PasswordFile="$HOME/.vnc/passwd" >/dev/null &
  13. daemon_set_pid "$!"
  14. }

This module uses injected libwmrc functions for logging and control of the
spawned background process. Functionality for stopping and restarting module is
inherited and doesn’t need to be explicitly declared.

Service can be started implicitly as wmrc start screen/vnc
or explicitly as a method call: wmrc call screen/vnc start.

Implicit method calls are
available for functions start, stop, restart and status.

Configuration file

Configuration file is located at $HOME/.config/wmrc/rc.conf and contains
global variables and execution units.

Variables

Variables declared here are visible in all modules with WMRC_ prefix.
They can be assigned any constant value or shell expression.

Execution units

Execution unit is a sequence of method calls to wmrc modules.
Their purpose is to group execution of various methods which
should always be executed together.

Mehod calls in units are executed in parallel, but can be executed conditionally
in sequence using wait and crit flags.

Example configuration

  1. %LOCKSCREEN_COVER = '$HOME/Pictures/bliss.jpg'
  2. [lock]
  3. screen/lock::start crit
  4. screen/brightness::set(100%)
  5. audio/playerctl::pause

Now, hotkey daemon can call wmrc unit lock and the lock unit will be executed.