From 499d375791ca79fad10053c4599a10f9f7acde49 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Sep 2019 11:00:28 +0000 Subject: [PATCH] Add basic dimswitch Prints out current version number and simple usage instructions on invocation with -h, --help, -v, --version. Displays used configuration file when invoked with -i/--info. Adds simple toggle ability script, used by simply invoking `dimswitch` from the .local/bin/ directory. In this dotfile configuration that directory is added to the path, so can be invoked from anywhere. Invoked without any options it will look for a line which specifies a theme with a `-light` or `-dark` option appended, and switch them out. Does not change the vim colorscheme or background, and can not change the theme in alacritty itself. The extent of this script is still limited, if it should be expanded python seems more suited. For further discussion, see its original Merge Request !18. --- .config/alacritty/alacritty.yml | 7 +- .local/bin/dimswitch | 197 +++++++++++++++++++++++ .local/bin/test/dimswitch.bats | 63 ++++++++ .local/bin/test/files/alacritty_conf.yml | 0 4 files changed, 263 insertions(+), 4 deletions(-) create mode 100755 .local/bin/dimswitch create mode 100644 .local/bin/test/dimswitch.bats create mode 100644 .local/bin/test/files/alacritty_conf.yml diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml index 01a6630..e0f6acd 100644 --- a/.config/alacritty/alacritty.yml +++ b/.config/alacritty/alacritty.yml @@ -171,7 +171,7 @@ font: draw_bold_text_with_bright_colors: false # Colors (Gruvbox light) -gruvboxlight: &gruvboxlight +gruvboxlight: &gruvbox-light # Default colors primary: # hard contrast: background = '0xf9f5d7' @@ -202,7 +202,7 @@ gruvboxlight: &gruvboxlight white: '0x3c3836' # Colors (Gruvbox dark) -gruvboxdark: &gruvboxdark +gruvboxdark: &gruvbox-dark # Default colors primary: # hard contrast: background = '0x1d2021' @@ -232,8 +232,7 @@ gruvboxdark: &gruvboxdark cyan: '0x8ec07c' white: '0xebdbb2' -colors: - *gruvboxdark +colors: *gruvbox-dark # Visual Bell # diff --git a/.local/bin/dimswitch b/.local/bin/dimswitch new file mode 100755 index 0000000..59f6902 --- /dev/null +++ b/.local/bin/dimswitch @@ -0,0 +1,197 @@ +#!/usr/bin/env bash +# +#============================================================================== +# FILE: dimswitch +# USAGE: dimswitch [-v] [-h] [-i [application]] [-t theme name] dark/light +# +# DESCRIPTION: +# Toggle alacritty terminal, and between dark +# or light mode (if correctly set up in the alacritty.yml file), see REQUIREMENTS +# The default action is to toggle between light and dark mode. +# +# OPTIONS: see function ’usage’ below +# +# REQUIREMENTS: +# The alacritty.yml file needs to have the various color-schemes set up as yaml +# anchors. The script itself will then switch the referenced anchor in the actual +# `color` key of the file. For an example alacritty.yml refer to its wiki, or +# this file: https://gitlab.com/marty-oehme/dotfiles/blob/master/.config/alacritty/alacritty.yml +# +# NOTES: This script is in active development and its functionality and options +# are very much undergoing changes. For now, do not rely on its options +# staying stable. +# +# AUTHOR: +# Marty Oehme +# +# VERSION: +ld_version="0.1.1" +#============================================================================== + +#=== environment variables ==================================================== +# DESCRIPTION: Environment variables to configure the script +#============================================================================== + +# Sets the programs to be dimmed +if [ -z "$DIM_PROGRAMS" ]; then DIM_PROGRAMS=(alacritty); fi + +# Sets the path(s) to the alacritty configuration file +if [ -z "$DIM_ALACRITTY_CONF" ]; then DIM_ALACRITTY_CONF="$HOME/.config/alacritty/alacritty.yml:$HOME/.alacritty.yml"; fi + +#=== main function ============================================================ +# NAME: main +# DESCRIPTION: Display usage information for this script. +# PARAMETERS: see usage function +#============================================================================== +main() { + local cmd="" + local ret=0 + + case "$1" in + -v | --version) + cmd="version" + ;; + -h | --help) + cmd="usage" + ;; + -i | --info) + cmd="printinfo" + ;; + "") + cmd="toggle" + ;; + esac + shift + + $cmd "$@" + ret=$((ret + $?)) + exit $ret +} + +#=== usage function =========================================================== +# NAME: usage +# DESCRIPTION: Display usage information for this script. +#============================================================================== +usage() { + local name + name=$(basename "$0") + cat <