From a91ea4f87e7b56be559a1a0657d7552dc76789e0 Mon Sep 17 00:00:00 2001 From: swy7ch Date: Wed, 20 May 2020 18:34:34 +0200 Subject: [PATCH] feat: change neovim template plugin + update header of scripts --- .config/nvim/init.vim | 10 ++++++++-- .local/bin/AC_notify | 15 ++++++++++++--- .local/bin/arch_setup | 16 +++++++++++----- .local/bin/audio_notify | 14 +++++++++++--- .local/bin/backlight_notify | 14 +++++++++++--- .local/bin/bat_notify | 13 +++++++++++-- .local/bin/bibinput | 13 ++++++++++--- .local/bin/bibshow | 12 +++++++++--- .local/bin/colorblocks | 14 +++++++++++--- .local/bin/compiler | 22 ++++++++++++++-------- .local/bin/displayselect | 14 +++++++++----- .local/bin/dmenumount | 13 ++++++++----- .local/bin/dmenuopen | 12 ++++++++++-- .local/bin/dmenupass | 11 +++++++++-- .local/bin/dmenuprompt | 16 +++++++++++----- .local/bin/dmenuumount | 12 ++++++++---- .local/bin/dot | 12 ++++++++++-- .local/bin/dwmbar | 12 +++++++++--- .local/bin/fetch | 10 +++++++++- .local/bin/kbacklight | 13 +++++++++---- .local/bin/maker | 18 ++++++++++++------ .local/bin/mom | 14 ++++++++++++-- .local/bin/mommerge | 14 ++++++++++++++ .local/bin/refbar | 12 +++++++++--- .local/bin/sbacklight | 11 ++++++++++- .local/bin/setbg | 15 ++++++++++++--- .local/bin/texclear | 13 +++++++++---- .local/bin/texer | 13 +++++++++++-- .local/bin/webupdate | 12 ++++++++++-- 29 files changed, 299 insertions(+), 91 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 0150913..c05b351 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -28,7 +28,7 @@ Plug 'lifepillar/vim-colortemplate' Plug 'norcalli/nvim-colorizer.lua' " Templates -Plug 'aperezdc/vim-template' +Plug 'tibabit/vim-templates' " All Plugins must be added before the following line call plug#end() @@ -156,6 +156,11 @@ augroup statusline \ call RefreshStatusLine('inactive') augroup END +"" Misc +"""""""""""""""""""""""""""""""""""""""""""""""""" +" Templates location +let g:tmpl_search_paths=['$XDG_CONFIG_HOME/nvim/templates'] + "" Macros """""""""""""""""""""""""""""""""""""""""""""""""" " Source files @@ -187,4 +192,5 @@ noremap pu :PlugUpdate \| PlugUpgrade noremap cc :ColorizerToggle " Template -noremap t :Template +noremap ti :TemplateInit +noremap te :TemplateExpand diff --git a/.local/bin/AC_notify b/.local/bin/AC_notify index d8b9a76..01556be 100755 --- a/.local/bin/AC_notify +++ b/.local/bin/AC_notify @@ -1,6 +1,15 @@ -#! /bin/sh -# Sends a notification if AC is plugged in (or out) -# Also refreshes statusbar +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : AC_notify +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:51:45 CEST +# +# @description : send a notification when AC status change +# refresh statusbar +###################################################################### + new_state="$(cat /sys/class/power_supply/AC/online)" prev_state="$new_state" diff --git a/.local/bin/arch_setup b/.local/bin/arch_setup index 3309d0e..0ab51c3 100755 --- a/.local/bin/arch_setup +++ b/.local/bin/arch_setup @@ -1,8 +1,14 @@ -#! /bin/sh -# This script has three goals: -# 1. cloning personnal git repos -# 2. building tools (suckless' utilities) -# 3. enabling systemctl services +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : arch_setup +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:49:05 CEST +# +# @description : automate the setup of my arch installation +###################################################################### + #Lists of apps sorted by type and criticity base_list="dash xorg-server xorg-xinit xorg-xinput xsetroot sxhkd xss-lock zsh neovim gtk2 brave" diff --git a/.local/bin/audio_notify b/.local/bin/audio_notify index 1fc9d4b..e2e5890 100755 --- a/.local/bin/audio_notify +++ b/.local/bin/audio_notify @@ -1,6 +1,14 @@ -#! /bin/sh -# Is called when changing sound level -# Sends a notification with the current sound level +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : audio_notify +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:52:58 CEST +# +# @description : send a notification with sound level +###################################################################### + level=$(pamixer --get-volume) muted=$(pamixer --get-mute) diff --git a/.local/bin/backlight_notify b/.local/bin/backlight_notify index 47ab795..293c00f 100755 --- a/.local/bin/backlight_notify +++ b/.local/bin/backlight_notify @@ -1,6 +1,14 @@ -#! /bin/sh -# Is called when changing backlight value -# Sens a notification with the current xbaclight value +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : backlight_notify +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:53:36 CEST +# +# @description : send a notification with xbacklight value +###################################################################### + current=$(cat /sys/class/backlight/intel_backlight/brightness) max=$(cat /sys/class/backlight/intel_backlight/max_brightness) diff --git a/.local/bin/bat_notify b/.local/bin/bat_notify index 6d7335a..6ee92dd 100755 --- a/.local/bin/bat_notify +++ b/.local/bin/bat_notify @@ -1,5 +1,14 @@ -#! /bin/sh -# Checks the battery, sends a notification depending on the level +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : bat_notify +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:54:08 CEST +# +# @description : send a notification with charge level +###################################################################### + notify() { \ for x in /sys/class/power_supply/BAT?/capacity; diff --git a/.local/bin/bibinput b/.local/bin/bibinput index d774779..31acb90 100755 --- a/.local/bin/bibinput +++ b/.local/bin/bibinput @@ -1,7 +1,14 @@ -#! /bin/sh +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : bibinput +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:57:47 CEST +# +# @description : create a bibliography entry through dmenu +###################################################################### -# Create an entry in $HOME/documents/bibliographies/selected_bibliography.bib -# Interactive script, dialog via dmenu parse(){ if [ "$1" = "@" ]; then diff --git a/.local/bin/bibshow b/.local/bin/bibshow index c6ac2c5..68184c1 100755 --- a/.local/bin/bibshow +++ b/.local/bin/bibshow @@ -1,8 +1,14 @@ -#! /bin/sh +#!/bin/sh -# Show the reference of a .bib entry +###################################################################### +# @author : swytch +# @file : bibshow +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:58:14 CEST +# +# @description : interactively display the infos in a .bib entry +###################################################################### -# User inputs informations, this will show the content of an entry through dmenu file="$(find $HOME/documents/bibliographies/ -type f -not -path '*/\.*' | dmenu -l 20 -p "[bibshow] which bibliography?")" # the -not -path allows find to ignore hidden files diff --git a/.local/bin/colorblocks b/.local/bin/colorblocks index 0c64a10..d009148 100755 --- a/.local/bin/colorblocks +++ b/.local/bin/colorblocks @@ -1,6 +1,14 @@ -#!/bin/bash -# This script will show the terminal colourscheme as blocks -# All credits to u/deepjyoti30 on GitHub +#!/bin/sh + +###################################################################### +# @author : swytch (based on u/deepjyoti30 on GitHub) +# @file : colorblocks +# @license : GPLv3 +# @created : Wednesday May 20, 2020 17:59:44 CEST +# +# @description : display terminal colors as big blocks +###################################################################### + f=3 b=4 for j in f b; do diff --git a/.local/bin/compiler b/.local/bin/compiler index dac8469..0a8a4f9 100755 --- a/.local/bin/compiler +++ b/.local/bin/compiler @@ -1,12 +1,18 @@ -#! /bin/sh -# This script will compile or run another finishing operation on a document -# It is meant to be run via vim/neovim -# Adapted form the work of Luke Smith (lukesmith.xyz) +#!/bin/sh + +###################################################################### +# @author : swytch (adapted from Luke Smith - lukesmith.xyz) +# @file : compiler +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:00:51 CEST +# +# @description : compile or run another finishing operation on a file +# groff-mom : compile via pdfmom to a pdf document +# c : compile via gcc +# config.def.h (suckless) recompile, install +# tex : compile via pdflatex (bibtex if needed) +###################################################################### -# groff-mom files : Compiles via pdfmom to a pdf document -# c files : Compiles via gcc -# config.def.h (-> suckless) recompiles and install the program -# tex files : Compiles via pdflatex (biblatex if needed) file=$(readlink -f "$1") dir=$(dirname "$file") diff --git a/.local/bin/displayselect b/.local/bin/displayselect index 29cff50..1afdf21 100755 --- a/.local/bin/displayselect +++ b/.local/bin/displayselect @@ -1,10 +1,14 @@ -#! /bin/sh +#!/bin/sh -# All credits to Luke Smith (lukesmith.xyz) +###################################################################### +# @author : swytch (adapted from Luke Smith - lukesmith.xyz) +# @file : displayselect +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:04:01 CEST +# +# @description : detect displays and select an organisation +###################################################################### -# A UI for detecting and selecting all displays. Probes xrandr for connected -# displays and lets user select one to use. User may also select "manual -# selection" which opens arandr. twoscreen() { # If multi-monitor is selected and there are two screens. mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount index ed3d778..de82247 100755 --- a/.local/bin/dmenumount +++ b/.local/bin/dmenumount @@ -1,11 +1,14 @@ #!/bin/sh -# Gives a dmenu prompt to mount unmounted drives. If they're in /etc/fstab -# they'll be mounted automatically. Otherwise, you'll be prompted to give -# a mountpoint from already existsing directories. If you input a novel -# directory, it will prompt you to create that directory. +###################################################################### +# @author : swytch (adapted from Luke Smith - lukesmith.xyz) +# @file : dmenumount +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:05:31 CEST +# +# @description : dmenu prompt to mount unmounted drives +###################################################################### -# Adapted form the work of Luke Smith (lukesmith.xyz) getmount() { \ [ -z "$chosen" ] && exit 1 diff --git a/.local/bin/dmenuopen b/.local/bin/dmenuopen index 93bb835..1fa513f 100755 --- a/.local/bin/dmenuopen +++ b/.local/bin/dmenuopen @@ -1,6 +1,14 @@ -#! /bin/sh +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : dmenuopen +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:08:05 CEST +# +# @description : find a file, open it with appropriate application +###################################################################### -# Fuzzy-find a file and open it with appropriate application filetypes=".pdf .png .jpg .txt .mom .tex .mkv" # could be augmented filetype=$(printf "$filetypes" | sed "s| |\n|g" | dmenu -i -p "type of the file?") diff --git a/.local/bin/dmenupass b/.local/bin/dmenupass index 2f08736..c2d02c2 100755 --- a/.local/bin/dmenupass +++ b/.local/bin/dmenupass @@ -1,7 +1,14 @@ #!/bin/sh -# This script is the SUDO_ASKPASS variable, meaning that it will be used as a -# password prompt if needed. +###################################################################### +# @author : swytch (adapted from Luke Smith - lukesmith.xyz) +# @file : dmenupass +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:08:50 CEST +# +# @description : [sudo] prompt (SUDO_ASKPASS variable) +###################################################################### + col_yellow="#ffeca3" col_black="#1d2021" diff --git a/.local/bin/dmenuprompt b/.local/bin/dmenuprompt index ab7e6ea..10902f8 100755 --- a/.local/bin/dmenuprompt +++ b/.local/bin/dmenuprompt @@ -1,8 +1,14 @@ -#! /bin/sh -# A dmenu binary prompt script. -# Gives a dmenu prompt labeled with $1 to perform command $2. -# For example: -# `./prompt "Do you want to shutdown?" "shutdown -h now"` +#!/bin/sh + +###################################################################### +# @author : swytch (adapted from Luke Smith - lukesmith.xyz) +# @file : dmenuprompt +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:10:13 CEST +# +# @description : dmenu prompt ($1) to perform a command ($2) +###################################################################### + col_darkred="#9d0006" col_red="#cc241d" diff --git a/.local/bin/dmenuumount b/.local/bin/dmenuumount index dd25fb5..964bb74 100755 --- a/.local/bin/dmenuumount +++ b/.local/bin/dmenuumount @@ -1,10 +1,14 @@ #!/bin/sh -# A dmenu prompt to unmount drives. -# Provides you with mounted partitions, select one to unmount. -# Drives mounted at /, /boot and /home will not be options to unmount. +###################################################################### +# @author : swytch (adapted form Luke Smith - lukesmith.xyz) +# @file : dmenuumount +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:11:17 CEST +# +# @description : dmenu prompt to unmount drives +###################################################################### -# Adapted from the work of Luke Smith (lukesmith.xyz) unmountusb() { chosen=$(echo "$usbdrives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}') diff --git a/.local/bin/dot b/.local/bin/dot index 454c59e..ba3850b 100755 --- a/.local/bin/dot +++ b/.local/bin/dot @@ -1,6 +1,14 @@ -#!/bin/bash +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : dot +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:13:05 CEST +# +# @description : git wrapper for dotfiles management +###################################################################### -## Wrapper for my dotfiles git="/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME" cmd="$git status" # by default, give the status diff --git a/.local/bin/dwmbar b/.local/bin/dwmbar index 0ae069a..4f4189e 100755 --- a/.local/bin/dwmbar +++ b/.local/bin/dwmbar @@ -1,9 +1,15 @@ #!/bin/sh -# This script sets the statusbar with the xsetroot command at the end. Have it -# started by ~/.xinitrc or ~/.xprofile. +###################################################################### +# @author : swytch (adapted from Luke Smith - lukesmith.xyz) +# @file : dwmbar +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:14:14 CEST +# +# @description : set the statusbar in `dwm` +# @dependencies: `xsetroot` +###################################################################### -# Adapted form the work of Luke Smith (lukesmith.xyz) # Handle SIGTRAP signals sent by refbar to update the status bar immediately. trap 'update' 5 diff --git a/.local/bin/fetch b/.local/bin/fetch index 4e6e9d3..98507a9 100755 --- a/.local/bin/fetch +++ b/.local/bin/fetch @@ -1,6 +1,14 @@ #!/bin/sh -# based on ufetch - https://gitlab.com/jschx/ufetch/ +###################################################################### +# @author : swytch +# @file : fetch +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:16:09 CEST +# +# @description : display system infos +###################################################################### + ## INFO diff --git a/.local/bin/kbacklight b/.local/bin/kbacklight index 68c81bf..f409683 100755 --- a/.local/bin/kbacklight +++ b/.local/bin/kbacklight @@ -1,10 +1,15 @@ #!/bin/sh -## Control keyboard brightness - ## level goes up at each call - ## goes back to 0 after reaching maximum brightness +###################################################################### +# @author : swytch +# @file : kbacklight +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:17:03 CEST +# +# @description : control keyboard brightness +# @dependencies: `upower` +###################################################################### -## You need `upower` package to make it work max=$(cat /sys/class/leds/tpacpi::kbd_backlight/max_brightness) current=$(cat /sys/class/leds/tpacpi::kbd_backlight/brightness) diff --git a/.local/bin/maker b/.local/bin/maker index f36b7cf..6892a0f 100755 --- a/.local/bin/maker +++ b/.local/bin/maker @@ -1,9 +1,15 @@ -#! /bin/sh -# Detect if the directory is a c/c++ project -# Create a makefile with existing c/c++ files in directory -# Rules are basic (i.e. module.o : module.c) -# variables are generic -# Exit by opening makefile with neovim +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : maker +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:18:53 CEST +# +# @description : create a makefile for current project (if c/c++) +# open it with (neo)vim +###################################################################### + headers_list="$(ls | grep '.h$')" sources_list="$(ls | grep '.cp*$')" diff --git a/.local/bin/mom b/.local/bin/mom index 37d6f35..033065c 100755 --- a/.local/bin/mom +++ b/.local/bin/mom @@ -1,5 +1,15 @@ -#! /bin/sh -# Creates a groff/mom document with generic metadata, opens it with neovim (or vim as a fallback) +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : mom +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:19:56 CEST +# +# @description : create a groff doc with genereic metadata +# open it with (neo)vim +###################################################################### + if [ -z ""$1"" ]; then echo "Please provide a name for your file" diff --git a/.local/bin/mommerge b/.local/bin/mommerge index 1dc83be..20c0c20 100755 --- a/.local/bin/mommerge +++ b/.local/bin/mommerge @@ -1,3 +1,17 @@ +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : mommerge +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:20:23 CEST +# +# @description : merge mom files from current dir +# compile it with `compiler` script +# @dependencies: `compiler` script +###################################################################### + + #! /bin/sh # Gather the mom files from current dir and compile them into ONE pdf file, using my compiler script # /!\ files must be names 0_file0, 1_file1... in order to be processed correctly diff --git a/.local/bin/refbar b/.local/bin/refbar index bbc1379..ae5098c 100755 --- a/.local/bin/refbar +++ b/.local/bin/refbar @@ -1,8 +1,14 @@ -#! /bin/sh +#!/bin/sh -#refresh dwmbar by killing the "sleep" command in the dwmbar process +###################################################################### +# @author : swytch (adapted form Luke Smith - lukesmith.xyz) +# @file : refbar +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:21:19 CEST +# +# @description : refresh dwmbar +###################################################################### -# Adapted form the work of Luke Smith (lukesmith.xyz) # Send SIGTRAP signal to dwmbar script, which will handle it with a trap. pkill -SIGTRAP dwmbar diff --git a/.local/bin/sbacklight b/.local/bin/sbacklight index 29c8b22..bb467c2 100755 --- a/.local/bin/sbacklight +++ b/.local/bin/sbacklight @@ -1,6 +1,15 @@ #!/bin/sh -## Change the backlight value +###################################################################### +# @author : swytch +# @file : sbacklight +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:22:36 CEST +# +# @description : control screen brightness +###################################################################### + + ## You need write privileges on /sys/.../brightness ## This can be achieved via a `udev` rule (see ~/.config/root) diff --git a/.local/bin/setbg b/.local/bin/setbg index bc0ec91..43567e0 100755 --- a/.local/bin/setbg +++ b/.local/bin/setbg @@ -1,9 +1,18 @@ -#! /bin/sh +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : setbg +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:23:50 CEST +# +# @description : set the wallpaper +# @dependencies: `xwallpaper` +###################################################################### + -# This script sets the wallpaper # If given an argument # if $1 is a png file, set it as a wallpaper - # if $1 is a jpg/jpeg file, convert it to png and set it as a wallpaper # if $1 is a directory, choose a randomized image in it, set it as wallpaper [ -f "$1" ] && cp $1 "$XDG_CONFIG_HOME/wall.png" && dunstify -u "low" "Wallpaper changed" diff --git a/.local/bin/texclear b/.local/bin/texclear index b87abdb..b3e8249 100755 --- a/.local/bin/texclear +++ b/.local/bin/texclear @@ -1,9 +1,14 @@ -#!/usr/bin/env sh +#!/bin/sh -# All credits to Luke Smith (lukesmith.xyz) +###################################################################### +# @author : swytch (adapted form Luke Smith - lukesmith.xyz) +# @file : texclear +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:24:59 CEST +# +# @description : clear the build files of LaTeX build +###################################################################### -# Clears the build files of a LaTeX/XeLaTeX build. -# I have vim run this file whenever I exit a .tex file. case "$1" in *.tex) diff --git a/.local/bin/texer b/.local/bin/texer index 4cd9f2f..e702a4a 100755 --- a/.local/bin/texer +++ b/.local/bin/texer @@ -1,6 +1,15 @@ -#! /bin/sh +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : texer +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:26:30 CEST +# +# @description : create a LaTeX doc with generic metadata +# open it with (neo)vim +###################################################################### -# Create a LaTeX document with genereic metadata, then open it with neovim (or vim as a fallback) if [ -z "$1" ]; then echo "Please provide a name for your file" diff --git a/.local/bin/webupdate b/.local/bin/webupdate index 3affe8d..0113a51 100755 --- a/.local/bin/webupdate +++ b/.local/bin/webupdate @@ -1,5 +1,13 @@ -#! /bin/sh +#!/bin/sh + +###################################################################### +# @author : swytch +# @file : webupdate +# @license : GPLv3 +# @created : Wednesday May 20, 2020 18:27:35 CEST +# +# @description : update my website with $HOME/public_html +###################################################################### -# Little script to update my website rsync -avrP --rsh='ssh' $HOME/public_html swytch@davidjulien.xyz:~/ && notify-send 'davidjulien.xyz' 'website updated'