HELL COMMIT

Just get it all updated. make shelly a thing
This commit is contained in:
Robert Morrison 2024-02-19 17:08:26 +00:00
commit 9eb9dd90f7
Signed by: robert
GPG Key ID: 73E012EB3F4EC696
13 changed files with 317 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
overrides.d/bemenu
overrides.d/Path/*.sh
overrides.d/XDG/*.sh
overrides.d/program_config/*.sh
overrides.d/programs/*.sh
overrides.d/Other/*.sh

33
Bemenu_defaults.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/sh
###########################
# BEMENU
###########################
# - bemenu is a replacement for dmenu.
# - It does things in a similar manner however, it works on wayland
# - It also allows you to set default settings with environment variables.
# - I have deconstructed the variable into multiple variables that can be easier edited.
BEMENU_FONT='--fn "monospace Light 10"'
BEMENU_LINE_HEIGHT='--line-height 26'
BEMENU_NORMAL_BACKGROUND='--nb #282828'
BEMENU_NORMAL_FOREGROUND='--nf #ebdbb2'
BEMENU_ALT_BACKGROUND='--ab #3c3836'
BEMENU_ALT_FOREGROUND='--af #fbf1c7'
BEMENU_TITLE_BACKGROUND='--tb #8ec07c'
BEMENU_TITLE_FOREGROUND='--tf #1d2021'
BEMENU_FILTER_BACKGROUND='--fb #1d2021'
BEMENU_FILTER_FOREGROUND='--ff #689d6a'
BEMENU_SCROLL_BACKGROUND='--scb #1d2021'
BEMENU_SCROLL_FOREGROUND='--scf #689d6a'
BEMENU_HIGHLIGHT_BACKGROUND='--hb #b26282'
BEMENU_HIGHLIGHT_FOREGROUND='--hf #ebdbb2'
BEMENU_SELECTED_BACKGROUND='--sb #b8bb26'
BEMENU_SELECTED_FOREGROUND='--sf #282828'
BEMENU_BORDER_COLOR='--bdr #b16286'
## Construct the variable from the parts
BEMENU_OPTS="${BEMENU_FONT} ${BEMENU_LINE_HEIGHT} ${BEMENU_NORMAL_FOREGROUND} ${BEMENU_NORMAL_BACKGROUND} ${BEMENU_ALT_FOREGROUND} ${BEMENU_ALT_BACKGROUND} ${BEMENU_TITLE_FOREGROUND} ${BEMENU_TITLE_BACKGROUND} ${BEMENU_FILTER_BACKGROUND} ${BEMENU_FILTER_FOREGROUND} ${BEMENU_SCROLL_FOREGROUND} ${BEMENU_SCROLL_BACKGROUND} ${BEMENU_HIGHLIGHT_BACKGROUND} ${BEMENU_HIGHLIGHT_FOREGROUND} ${BEMENU_SELECTED_BACKGROUND} ${BEMENU_SELECTED_FOREGROUND} ${BEMENU_BORDER_COLOR}"
# Unset the parts to ensure that they aren't pulled into the users environment
unset BEMENU_FONT BEMENU_LINE_HEIGHT BEMENU_NORMAL_BACKGROUND BEMENU_NORMAL_FOREGROUND BEMENU_ALT_BACKGROUND BEMENU_ALT_FOREGROUND BEMENU_TITLE_BACKGROUND BEMENU_TITLE_FOREGROUND BEMENU_FILTER_BACKGROUND BEMENU_FILTER_FOREGROUND BEMENU_SCROLL_BACKGROUND BEMENU_SCROLL_FOREGROUND BEMENU_HIGHLIGHT_BACKGROUND BEMENU_HIGHLIGHT_FOREGROUND BEMENU_SELECTED_BACKGROUND BEMENU_SELECTED_FOREGROUND BEMENU_BORDER_COLOR
export BEMENU_OPTS

57
Path.sh Normal file
View File

@ -0,0 +1,57 @@
#!/bin/sh
# This file is gonna be hell, we need to make sure that we don't duplicate
# items on path.
# This includes resolving symlinks at the /bin level for merged-usr systems.
## PATH UPDATE FUNCTION
updatepath() {
front=$1
new="$(realpath "$2" 2>/dev/null)"
if [ ! -d "$new" ]; then
return
fi
case ":${PATH:=$new}:" in
*:"$new":*) ;;
*)
if [ "$front" -eq 1 ]; then
PATH="$new:$PATH"
else
PATH="$PATH:$new"
fi
;;
esac
}
## Use the function to make changes to path.
## ensure the base path is there
updatepath 0 '/bin'
updatepath 0 '/sbin'
updatepath 0 '/usr/bin'
updatepath 0 '/usr/sbin'
updatepath 0 '/usr/local/bin'
updatepath 0 '/usr/local/sbin'
updatepath 0 '/snap/bin' # Because sometimes people use snap
## THIS MUST BE SOURCED AFTER XDG_SHENANIGANS FOR THIS TO WORK
updatepath 0 "$GOPATH/bin"
updatepath 0 "$GEM_HOME/bin"
updatepath 1 "$HOME/perl5/bin"
updatepath 0 "$DOTNET_ROOT/bin"
updatepath 0 "$DOTNET_ROOT/tools"
updatepath 0 "$CARGO_HOME/bin"
updatepath 1 "${XDG_DATA_HOME}/neovim/bin"
updatepath 0 "$HOME/.dotnet/tools"
## NOW WE ADD ~/.local/bin
## THIS IS SPECIAL SINCE IT ALLOWS FOR YOU ADD ALL SUB-DIRECTORIES TOO
## ALSO DIRECTLY MODIFIES PATH
if [ -d "${HOME}/.local/bin" ]; then
Local=$(find -L "$HOME"/.local/bin -type d -not -path '*/.git*' -printf "%p:")
PATH="${Local}${PATH}"
fi
export PATH

47
Readme.md Normal file
View File

@ -0,0 +1,47 @@
# Shelly
A helpful tool to make managing shell environments a little easier.
With some magic defaults and an simple mechanism for overriding them.
## Usage
To just use it you set the environment variable `$SHELLY` to the directory
that shelly is and source it. It is important to realise that shelly is
resposible for configuring `$XDG_CONFIG_HOME` so I would recommend you only
use `${HOME}` to reference your home directory and enter the rest of the
path verbatim.
### Example
```bash
export SHELLY="${HOME}/.config/shelly"
source "${SHELLY}/shelly.sh"
```
## Configuration
The git repo for shelly is configured to ignore most of what is in
overrides.d, keeping just the directory structure.
Files will be loaded in the following manner:
First it loads the default program choices, You can inspect this file to
see what choices I make.
To override them you can add files to `overrides.d/programs` All files
must have the extension `.sh` to be detected.
After this the XDG shenanigans are performed, again inspect the file to
see what it does.
Overrides go in `overrides.d/XDG`
Next is program_config, same rules.
Then Bemenu, again same rules.
Next is Path. Path is a little more fun, to make path somewhat
idempotent a function called `updatepath` is defined.
In your override files you should use this function to add to your
path.
The function is called like this `updatepath <TOP> <PATHENTRY>` where `TOP` should be
either 1 or 0, 1 meaning add the new `PATHENTRY` at the front of the
path. Otherwise it adds it to the bottom.
The function _only_ adds a new entry to `PATH` if it isn't already
there, this ensures that session in sessions don't get more path
entries than they need.

86
XDG_shenanigans.sh Normal file
View File

@ -0,0 +1,86 @@
#!/bin/sh
###########################
# XDG shenanigans
###########################
# - The XDG basedirs standard sets out where programs should put their
# - files. Unfortunately there are programs that ignore this and just dump shit
# - inside your home directory. This SUCKS so bad.
# - Luckily you can actually configure a lot of those programs with Environment variables
# - Here I do the best I can for what I have installed. (you may want to change things here)
# - You can use the tool xdg-ninja https://github.com/b3nj5m1n/xdg-ninja to scan your home folder
# - and find things to add here.
# XDG Folders.
# - First we need to explicitly place where these folders are on our system
# - They can go anywhere (in your home directory). but these are the standard paths.
export XDG_CONFIG_HOME="$HOME"/.config
export XDG_DATA_HOME="$HOME"/.local/share
export XDG_CACHE_HOME="$HOME"/.cache
export XDG_STATE_HOME="$HOME"/.local/state
# Applications
# - This section is likely to be _VERY_ ugly looking.
# - Generally the only comment will be saying what is being moved.
# - I will also attempt to keep this in alphabetical order
# android-studio
export ANDROID_HOME="$XDG_DATA_HOME"/android
export ANDROID_USER_HOME="$ANDROID_HOME"
export ANDROID_AVD_HOME="$ANDROID_HOME/avd"
# Cabal
export CABAL_CONFIG="$XDG_CONFIG_HOME"/cabal/config
export CABAL_DIR="$XDG_DATA_HOME"/cabal
# cargo
export CARGO_HOME="$XDG_DATA_HOME"/cargo
# Cuda cache
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
# dotnet snap - this might be a me-only thing?
## Provided by PORTAGE
# export DOTNET_ROOT="$HOME/.local/opt/dotnet"
# gem cache
export GEM_SPEC_CACHE="${XDG_CACHE_HOME}"/gem
# gem
export GEM_HOME="${XDG_DATA_HOME}"/gem
# GHCUP
export GHCUP_USE_XDG_DIRS=1
# GNUPG
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
# go
export GOPATH="$XDG_DATA_HOME"/go
# Gradle
export GRADLE_USER_HOME="$XDG_DATA_HOME"/gradle
# GTK 2
export GTK2_RC_FILES="$XDG_CONFIG_HOME"/gtk-2.0/gtkrc
# jupyter
export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME"/jupyter
# kde
export KDEHOME="$XDG_DATA_HOME"/kde
# Kodi
export KODI_DATA="$XDG_DATA_HOME"/kodi
# Less History
export LESSHISTFILE="$XDG_CACHE_HOME"/less/history
# npm
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc
# NuGet
export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages
# OPAM
export OPAMROOT="$XDG_DATA_HOME/opam"
# Parallel
export PARALLEL_HOME="$XDG_CONFIG_HOME"/parallel
# Pass
export PASSWORD_STORE_DIR="$XDG_DATA_HOME"/pass
# pylint
export PYLINTHOME="${XDG_CACHE_HOME}"/pylint
# Python history
export PYTHONSTARTUP="${XDG_CONFIG_HOME}/python/pythonrc"
# Rustup
export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
# Stack
export STACK_ROOT="$XDG_DATA_HOME"/stack
# TERMINFO
export TERMINFO="$XDG_DATA_HOME"/terminfo
export TERMINFO_DIRS="$XDG_DATA_HOME"/terminfo:/usr/share/terminfo
# wine
export WINEPREFIX="$XDG_DATA_HOME"/wine
# XCURSOR
export XCURSOR_PATH=/usr/share/icons:${XDG_DATA_HOME}/icons

0
overrides.d/.gitkeep Normal file
View File

View File

0
overrides.d/XDG/.gitkeep Normal file
View File

View File

View File

5
program_config.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
# General one line exports for some program configurations
export QT_QPA_PLATFORMTHEME="qt5ct"
export MOZ_ENABLE_WAYLAND=1 # force firefox to use wayland

31
programs.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
## Choose Default Programs
## These variables are used by both my own scripts and other programs
## when deciding what program to use for certain purposes.
## I will endeavour to provide a description for each variable
EDITOR='nvim'
# - Traditionally EDITOR is used to choose a line based file editor
# however, since line based editors are rather uncommon I instead
# set it to be a screen based editor.
VISUAL=$EDITOR
# - VISUAL is used for screen based file editors, so named because
# you use them to work on a whole screen of text at a time.
# Here I set it to the value of EDITOR
TERMINAL='foot'
# - TERMINAL sets the graphical terminal emulator that you want to use.
# for the moment I use foot but you might wish to use something else
BROWSER='msedge'
# - BROWSER sets what is used to handle URLs in theory you could set
# this to a script that loads different programs based on what the URL
# is, but most people just set it to a web browser.
export EDITOR VISUAL TERMINAL BROWSER

52
shelly.sh Normal file
View File

@ -0,0 +1,52 @@
#!/bin/sh
# This file is only designed to load the other parts of shell.d
if [ -z "${SHELLY}" ]; then
echo "\$SHELLY is not set!" >&2
return
fi
. "${SHELLY}/programs.sh"
if [ -d "${SHELLY}/overrides.d/programs" ]; then
for file in "${SHELLY}"/overrides.d/programs/*.sh ; do
# shellcheck disable=SC1090
[ -f "$file" ] && . "$file"
done
fi
. "${SHELLY}/XDG_shenanigans.sh"
if [ -d "${SHELLY}/overrides.d/XDG" ]; then
for file in "${SHELLY}"/overrides.d/XDG/*.sh ; do
# shellcheck disable=SC1090
[ -f "$file" ] && . "$file"
done
fi
. "${SHELLY}/program_config.sh"
if [ -d "${SHELLY}/overrides.d/program_config" ]; then
for file in "${SHELLY}"/overrides.d/program_config/*.sh ; do
# shellcheck disable=SC1090
[ -f "$file" ] && . "$file"
done
fi
. "${SHELLY}/Bemenu_defaults.sh"
if [ -f "${SHELLY}/overrides.d/bemenu" ]; then
. "${SHELLY}/overrides.d/bemenu"
fi
. "${SHELLY}/Path.sh"
if [ -d "${SHELLY}/overrides.d/Path" ]; then
for file in "${SHELLY}"/overrides.d/Path/*.sh ; do
# shellcheck disable=SC1090
[ -f "$file" ] && . "$file"
done
fi
if [ -d "${SHELLY}/overrides.d/Other" ]; then
for file in "${SHELLY}"/overrides.d/Other/*.sh ; do
# shellcheck disable=SC1090
[ -f "$file" ] && . "$file"
done
fi