Merge branch '74-theme-changing-using-standardized-base16-color-schemes' into 'master'

Resolve "Theme Changing using standardized base16 color schemes"

Closes #74

See merge request marty-oehme/dotfiles!27
This commit is contained in:
Marty Oehme 2020-02-01 10:08:19 +00:00
commit 7308828c67
17 changed files with 268 additions and 114 deletions

6
.gitignore vendored
View file

@ -44,3 +44,9 @@ tags
.vim .vim
# End of https://www.gitignore.io/api/vim,linux # End of https://www.gitignore.io/api/vim,linux
# Ignore dynamic colorschemes set by styler
colorscheme.vim
colorscheme
colorscheme.py
colorscheme.rasi

View file

@ -1,12 +1,15 @@
# dotfiles Read-Me and Roadmap # dotfiles Read-Me and Roadmap
## What's in these dotfiles ## What's in these dotfiles
* [x] vim configuration for simple programming tasks (especially go/typescript/python/bash) and prose * [x] vim configuration for simple programming tasks (especially go/typescript/python/bash) and prose
* [x] academic workflow tools, to allow quick citation, pdf compilation, and preview * [x] academic workflow tools, to allow quick citation, pdf compilation, and preview
* [x] simple, efficient polybar with package update notification, and spotify integration * [x] simple, efficient polybar with package update notification, and spotify (mpris) integration
* [x] tmux session management through `tm` and `tl` tools * [x] tmux session management through `tm` and `tl` tools
* [x] quick terminal-wide color management through `sd`/`sD`/`sl`/`sL` commands, allowing two light and dark color-schemes * [x] tmux fuzzy-searching of terminal sessions to switch to with hot-key (`<C-A><C-j>`)
* [x] many vim color-schemes with quick light/dark switching (`F8`) and theme switch (`<Space>+F8`) * [x] system-wide color management (terminals, vim, qutebrowser, polybar, xresources) through `styler` command using [base16](http://chriskempson.com/projects/base16/) themes
* [x] quick theme switching by activating `styler` and fuzzy-searching themes with hot-key (`<Super>+F8`)
* [x] many vim color-schemes with quick light/dark switching (`F8`) and individual theme switch (`<Space>+F8`)
* [x] quick directory jumping using z, with fzf integration * [x] quick directory jumping using z, with fzf integration
* [x] fzf integrations for bibtex citation, vim buffer management, most recently used switching, shell command history, and more * [x] fzf integrations for bibtex citation, vim buffer management, most recently used switching, shell command history, and more

View file

@ -1,12 +0,0 @@
! ~/.Xresources
! Setting up commonly changed vars
#define myfontsize 11
#define myfont Fira Code
#define myOpacity 90
! Set up URxvt
#include ".config/Xresources/urxvt.Xresources"
! Add Nord theme to every terminal emulator respecting Xresources
#include ".config/Xresources/nord.Xresources"

View file

@ -1 +0,0 @@
colo nord

View file

@ -47,6 +47,13 @@ endif
" set truecolor (neovim) " set truecolor (neovim)
set termguicolors set termguicolors
" load colorscheme from dynamic file
" first one is here to make airline behave correctly without reload
runtime colorscheme.vim
" this one is here to override anything set by default in colorscheme plugin
" loading
autocmd VimEnter * runtime colorscheme.vim
" sets tabs to be 2 characters, expanded into spaces, but still removable with " sets tabs to be 2 characters, expanded into spaces, but still removable with
" one press of backspace. " one press of backspace.
" great explanation: http://vimcasts.org/transcripts/2/en/ " great explanation: http://vimcasts.org/transcripts/2/en/

View file

@ -18,14 +18,14 @@
[colors] [colors]
;background = ${xrdb:color0:#222} ;background = ${xrdb:color0:#222}
background = #222 background = ${xrdb:background}
background-alt = #444 background-alt = ${xrdb:color8}
;foreground = ${xrdb:color7:#222} ;foreground = ${xrdb:color7:#222}
foreground = #dfdfdf foreground = ${xrdb:foreground}
foreground-alt = #555 foreground-alt = ${xrdb:color3}
primary = #ffb52a primary = ${xrdb:color1}
secondary = #e60053 secondary = ${xrdb:color4}
alert = #bd2c40 alert = ${xrdb:color2}
[settings] [settings]
; The throttle settings lets the eventloop swallow up til X events ; The throttle settings lets the eventloop swallow up til X events

View file

@ -61,8 +61,8 @@ c.tabs.title.format = '{index} {audio}{perc}{current_title}'
c.tabs.position = "right" c.tabs.position = "right"
c.tabs.width = "15%" c.tabs.width = "15%"
# give the browser nice nord theme colors # give the browser nice theme colors
config.source('themes/base16-gruvbox-dark.py') config.source('colorscheme.py')
# Status bar # Status bar
# should be visible to prevent 'jumping' bug, see https://github.com/qutebrowser/qutebrowser/issues/2236 # should be visible to prevent 'jumping' bug, see https://github.com/qutebrowser/qutebrowser/issues/2236

View file

@ -22,6 +22,7 @@
#listview { #listview {
spacing: 5px; spacing: 5px;
lines: 100; lines: 100;
border: 0px;
} }
#entry { #entry {

View file

@ -10,6 +10,7 @@
* but try to keep the two separated as much as possible, so we can adjust global options easily from here * but try to keep the two separated as much as possible, so we can adjust global options easily from here
*/ */
//default import
@import "colorschemes/gruvbox-dark.rasi" @import "colorschemes/gruvbox-dark.rasi"
* { * {

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ ! "$DISPLAY" ] && [ "$XDG_VTNR" -eq 1 ]; then if [ ! "$DISPLAY" ] && [ "$XDG_VTNR" -eq 1 ]; then
exec startx ~/.xinitrc exec startx "$XDG_CONFIG_HOME"/xresources/xinitrc
fi fi

212
styler/.local/bin/styler Executable file
View file

@ -0,0 +1,212 @@
#!/usr/bin/env bash
readonly BASE_PATH="${STYLER_DATA_PATH:-${XDG_DATA_HOME:-$HOME/.local/share}/styler}"
readonly PACKAGE_PATH="$BASE_PATH/packages"
readonly PROCESSOR_PATH="$BASE_PATH/processors"
readonly VERSION="0.3.0"
main() {
local cmd=""
local ret=0
case "$1" in
-t | --theme | theme)
cmd="switch_theme"
;;
-s | --set | set)
cmd="set_theme"
;;
-l | --list | list)
cmd="list"
;;
-d | --download | download)
cmd="download"
;;
-v | --version | version)
printf "Program theming script.\n\n©Marty Oehme\n\nVersion: %s\n" "$VERSION"
exit 0
;;
-h | --help | help | *)
cmd="usage"
;;
esac
shift
$cmd "$1"
ret=$((ret + $?))
exit $ret
}
usage() {
printf "%s\n" \
"" \
" styler - Quickly switch your linux style." \
" Uses base16 themes to quickly set them for a variety of applications." \
"" \
" Usage: styler [-hv | set base16-themename]" \
"" \
" Options:" \
"" \
" -t | theme Temporarily switch theme. Use any valid base16 theme name (without base16- prefix)." \
" Theme will be lost upon restart, or application restarts." \
"" \
" -s | set Set the theme. Use any valid base16 theme name (without base16- prefix)." \
" Same as 'theme' option, but changes will be made permanent." \
"" \
" -d | download Download a base16 template into the package directory or download a processor16" \
" into the processor directory. Use user/repo format to automatically pull from github." \
"" \
" -h | help Print out this help." \
"" \
" -v | version Print out program information." \
"" \
""
}
# base directory should always exist
base_dir_exists_or_create() {
[[ -d "$BASE_PATH" ]] || mkdir "$BASE_PATH"
[[ -d "$PACKAGE_PATH" ]] || mkdir "$PACKAGE_PATH"
[[ -d "$PROCESSOR_PATH" ]] || mkdir "$BASE_PATH"
}
# retrieves all relevant packages from BASE_PATH/packages
# 'relevant' here means they follow github pattern of author/repository
get_packages() {
for author in "$PACKAGE_PATH"/*; do
# TODO should eventually be used to either distinguish between author/pkg and pkg packages
# or to spit out a warning if they should not be used.
# if grep -q -e '^base16-' <<<"$(basename -- "$author")"; then
# echo ERROR
# fi
for package in "$author"/*; do
[[ -e "$author" ]] || break
[[ -d "$package" ]] || break
printf "%s/%s\n" "$(basename -- "$author")" "$(basename -- "$package")"
done
done
}
# retrieves all processors from BASE_PATH/processors
# 'relevant' here means they follow github pattern of author/repository
get_processors() {
for author in "$PROCESSOR_PATH"/*; do
for package in "$author"/*; do
for processor in "$package"/*; do
[[ -e "$processor" ]] || break
[[ -f "$processor" ]] || break
if grep -q -e '/theme_[[:alnum:]]\{1,\}$' <<<"$processor"; then
printf "%s\n" "$(basename -- "$processor")"
fi
done
done
done
}
# retrieves all installed themes from all packages, appends applications they exist for
get_themes() {
local themes
themes=$(find "$PACKAGE_PATH" -type f -name 'base16-*')
echo "$themes" | sed "s/.*\\/base16-//" | sed "s/\\..*//" | sort | uniq
}
# temporarily switch theme, same thing as setting, only with permanence flag turned off for processors
switch_theme() {
set_theme "$1" "false"
}
# call processors for all installed packages
set_theme() {
local theme="$1"
local permanent="${2:-true}"
local packages
packages="$(get_packages)"
if [[ -z "$packages" ]]; then
printf "ERROR: No base16 packages installed. Please install at least 1 base16 package in %s/.\n" "$PACKAGE_PATH" >&2
exit 1
fi
local processors
processors="$(get_processors)"
if [[ -z "$processors" ]]; then
printf "ERROR: No application processors installed. Please install at least one processor in %s/.\n" "$PROCESSOR_PATH" >&2
exit 1
fi
for pkg in $packages; do
local appext
# filter the application a package targets, since base16 packages
# carry standard names this removes everything before base16-
# the result is the application it targets
# shellcheck disable=SC2001
appext=$(sed "s|^[[:alnum:]]\{1,\}/base16-||" <<<"$pkg")
# Compares application extension with existing processors and runs the appropriate processor if found
processor=$(find "$PROCESSOR_PATH" -type f -name "theme_$appext")
if [[ -f "$processor" ]]; then
"$processor" "$PACKAGE_PATH" "$pkg" "$theme" "$permanent"
else
printf "WARN: No processor found for application %s in %s. Make sure you install a processor for the application.\n" "$appext" "$PROCESSOR_PATH/" >&2
fi
done
}
list() {
local selected="$1"
case "$selected" in
packages)
get_packages
;;
processors)
get_processors
;;
themes)
get_themes
;;
*)
echo "Please select one of packages | processors | themes to list."
;;
esac
}
download() {
local pkg="$1"
local page="https://github.com"
local repo="$page/$pkg"
[[ -z "$pkg" ]] && {
echo "No package to download passed in. Please provide a package to download in the form user/repository."
exit 1
}
type git >/dev/null 2>&1 || {
echo "git is required to clone base16 package. Please install git."
exit 1
}
base_dir_exists_or_create
if ! git ls-remote --exit-code -h "$repo" >/dev/null; then
echo "Repository $repo not found."
exit 1
fi
# if package has patter name/base16-program, put it in packages; if name/process16-program put it in processors
# if none of the above, assume it's a processor but warn the user
if grep -q -e '^[0-9A-Za-z-]\{1,\}/base16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then
git clone "$repo" "$PACKAGE_PATH/$pkg"
elif grep -q -e '^[0-9A-Za-z-]\{1,\}/process16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then
git clone "$repo" "$PROCESSOR_PATH/$pkg"
else
echo "Package does not fit default naming scheme of packages/processors. Assuming it is a processor but please check manually."
git clone "$repo" "$PROCESSOR_PATH/$pkg"
fi
}
main "$@"

View file

@ -30,6 +30,10 @@ super + x
super + BackSpace super + BackSpace
rofi -modi "powermenu:~/.config/rofi/modes/powermenu" -show powermenu -theme themes/powermenu rofi -modi "powermenu:~/.config/rofi/modes/powermenu" -show powermenu -theme themes/powermenu
# quick-switching of theme using styler
super + F8
styler set $(styler list themes | rofi -dmenu -theme /themes/dmenu -matching fuzzy)
# enable function (/media) key functionality # enable function (/media) key functionality
# TODO: set up next song, previous song, pause, etc # TODO: set up next song, previous song, pause, etc
# see: https://www.reddit.com/r/i3wm/comments/3a6nh3/help_how_to_use_function_keys_in_i3_config/ # see: https://www.reddit.com/r/i3wm/comments/3a6nh3/help_how_to_use_function_keys_in_i3_config/

View file

@ -0,0 +1,11 @@
! ~/.Xresources
! Setting up commonly changed vars
#define myfontsize 11
#define myfont Iosevka Mono
#define myOpacity 90
! Font settings
#include "Xresources.d/fonts"
! Colorscheme

View file

@ -0,0 +1,7 @@
Xft.antialias: 1
Xft.autohint: 0
Xft.dpi: 92
Xft.hinting: true
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault
Xft.rgba: rgb

View file

@ -1,48 +0,0 @@
! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! title Nord XResources +
! project nord-xresources +
! version 0.1.0 +
! repository https://github.com/arcticicestudio/nord-xresources +
! author Arctic Ice Studio +
! email development@arcticicestudio.com +
! copyright Copyright (C) 2016 +
! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define nord0 #2E3440
#define nord1 #3B4252
#define nord2 #434C5E
#define nord3 #4C566A
#define nord4 #D8DEE9
#define nord5 #E5E9F0
#define nord6 #ECEFF4
#define nord7 #8FBCBB
#define nord8 #88C0D0
#define nord9 #81A1C1
#define nord10 #5E81AC
#define nord11 #BF616A
#define nord12 #D08770
#define nord13 #EBCB8B
#define nord14 #A3BE8C
#define nord15 #B48EAD
*.foreground: nord4
*.background: [myOpacity]nord0
*.cursorColor: nord4
*fading: 0
*fadeColor: nord3
*.color0: nord1
*.color1: nord11
*.color2: nord14
*.color3: nord13
*.color4: nord9
*.color5: nord15
*.color6: nord8
*.color7: nord5
*.color8: nord3
*.color9: nord11
*.color10: nord14
*.color11: nord13
*.color12: nord9
*.color13: nord15
*.color14: nord7
*.color15: nord6

View file

@ -1,37 +0,0 @@
!Font
URxvt.font: xft:myfont:size=myfontsize,style=medium
URxvt.boldFont: xft:myfont:size=myfontsize,style=bold
URxvt.italicFont: xft:myfont:size=myfontsize,style=italic
URxvt.boldItalicFont: xft:myfont:size=myfontsize,style=bold,italic
URxvt.letterSpace: -1
!UI
URxvt.scrollBar: false
URxvt.borderless: true
URxvt.saveLines: 20000
URxvt.dynamicColors: true
URxvt.fading: 25
!Sane utility defaults
URxvt.loginShell: true
URxvt.scrollTtyKeypress: true
URxvt.scrollTtyOutput: false
URxvt.scrollWithBuffer: false
URxvt.skipScroll: true
!Extensions
!Tabbing disabled by default (TMUX used for tabbed terminals)
!to enable tabbing comment the bottom line and uncomment the one above.
!URxvt.perl-ext-common: default,matcher,tabbed
URxvt.perl-ext-common: default,matcher
! Link Clicking
URxvt.url-launcher: /usr/bin/xdg-open
URxvt.matcher.button: 1
URxvt.matcher.rend.0: Uline Bold fg5
!Tab Styling
URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 3
URxvt.tabbed.tab-bg: 0

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
userresources=$HOME/.Xresources userresources=$XDG_CONFIG_HOME/xresources/Xresources
usermodmap=$HOME/.Xmodmap usermodmap=$XDG_CONFIG_HOME/xresources/Xmodmap
sysresources=/etc/X11/xinit/.Xresources sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap sysmodmap=/etc/X11/xinit/.Xmodmap
@ -37,7 +37,7 @@ fi
setxkbmap -option ctrl:nocaps setxkbmap -option ctrl:nocaps
# sets default to EURkey layout, with possibility to switch to german # sets default to EURkey layout, with possibility to switch to german
# sets german layout to be default for the only pc I have with a german keyboard # sets german layout to be default for the only pc I have with a german keyboard
if [[ $HOST == "marty-desk" ]] || [[ $HOSTNAME == "marty-desk" ]]; then if [ "$HOST" = "marty-desk" ] || [ "$HOSTNAME" = "marty-desk" ]; then
setxkbmap -layout de,eu setxkbmap -layout de,eu
else else
setxkbmap -layout eu,de setxkbmap -layout eu,de