diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-01-20 03:41:29 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-01-20 03:41:29 -0500 |
commit | d49c79933e7b85a24238f6f373261de1d71d7072 (patch) | |
tree | 677bebe3b68c1c31125be064ba1a746f44c7a52f | |
parent | 06185bde8c8beadecab629eaff51835244ff748a (diff) |
Wallpapers from lf + fix shortcutgen
-rwxr-xr-x | .config/lf/lfrc | 24 | ||||
-rw-r--r-- | .config/shortcutrc | 55 | ||||
-rwxr-xr-x | .local/bin/makewall | 21 | ||||
-rwxr-xr-x | .local/bin/setbg | 28 | ||||
-rwxr-xr-x | .local/bin/shortcutgen | 68 |
5 files changed, 83 insertions, 113 deletions
diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 20d396e..93c9029 100755 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -121,7 +121,7 @@ map J $lf -remote "send $id cd $(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' map D delete map <c-n> push :mkdir<space> map <c-r> reload -map <c-s> set hidden! +map . set hidden! map <enter> shell map x $$f map X !$f @@ -141,26 +141,8 @@ map <c-y> up map V push :!nvim<space> map W $setsid -f $TERMINAL >/dev/null 2>&1 - map Y $printf "%s" "$fx" | xclip -selection clipboard +map E $dropbox-cli exclude add "%s" | notify-send "Dropbox" "Excluded %s from syncing." # Source Bookmarks -# source "~/.config/lf/shortcutrc" - -# TODO: Automate this -map gcf cd ~/.config -map gbx cd ~/Dropbox -map gom cd ~/Dropbox/org -map gdl cd ~/Downloads -map gwp cd ~/Pictures/wallpapers -map gdb cd ~/Dropbox -map gvi cd ~/.config/nvim -map gvdi cd ~/Workspace/vdi -map gws cd ~/Workspace -map gwb cd ~/Workspace/website -map gsc cd ~/.local/bin -map gcp cd ~/.local/src -map gsx cd ~/.config/sxhkd -map gimg cd ~/Dropbox/A/Personnal/Photos/unsorted -map gsf cd ~/Dropbox/A/scholar/sherbrooke/24-01 -map gcmp cd ~/.local/src +source "~/.config/lf/shortcuts" diff --git a/.config/shortcutrc b/.config/shortcutrc index 141bde4..4dec5e6 100644 --- a/.config/shortcutrc +++ b/.config/shortcutrc @@ -1,30 +1,37 @@ # _____ _ _ _ -# / ____| | | | | | +# / ____| | | | | \ # | (___ | |__ ___ _ __| |_ ___ _ _| |_ _ __ ___ -# \___ \| '_ \ / _ \| '__| __/ __| | | | __| '__/ __| +# \___ \| '_ \ / _ \| '__| __/ __| | | | __| '__/ __\ # ____) | | | | (_) | | | || (__| |_| | |_| | | (__ -# |_____/|_| |_|\___/|_| \__\___|\__,_|\__|_| \___| +# |_____/|_| |_|\___/|_| \__\___|\__,_|\__|_| \___\ # - - - # #---Universal Shortcut Configuration File---# # -# First column should have the directory's Label -# Second column should contain the shortcut itself -# (without the modifier) -# Third column should contain the directory itself -# (It can contain environmental variables) +# This file aims to provide a simple way to configure +# universal shortcuts for your system. Treat it in the +# following way: +# - Lines starting with '#' and empty are ignored +# - Everything else is treated as a 3 column comma separated csv +# - Commas can be escaped with a backslash +# - columns 2 and 3 should not contain spaces +# Columns are as follows (left to right): +# 1. Name of the shortcut (for display purposes in certain programs) +# 2. The shortcut itself +# 3. The path to the directory +# Here are examples of how I use this file with my shell: +# - uppercase shortcuts prepended by 'G' are ENV variables to these paths +# - lowercase shortcuts prepended by 'g' are aliases to these paths +# Here are examples of how I use this file with my file manager (lf): +# - lowercase shortcuts prepended by 'g' go to these paths +# - lowercase shortcuts prepended by 'y' copies selected files to these paths +# - lowercase shortcuts prepended by 'm' moves selected files to these paths -|----------------+-----+--------------------------------------------------| -| Config | cf | $HOME/.config | -| Downloads | dl | $HOME/Downloads | -| Wallpaper | wp | $HOME/Pictures/wallpapers | -| Dropbox | db | $HOME/Dropbox | -| Music | ms | $HOME/Music | -| Neovim | vi | $HOME/.config/nvim | -| Scripts | sc | $HOME/.local/bin | -| Hotkeys | sx | $HOME/.config/sxhkd | -| Images | img | $HOME/Dropbox/A/Personnal/Photos/unsorted | -| School | sf | $HOME/Dropbox/A/scholar/sherbrooke/24-01 | -| Compilation | cp | $HOME/.local/src | -|----------------+-----+--------------------------------------------------| +Config, cf, ~/.config +Neovim, vi, ~/.config/nvim +School, sf, ~/Dropbox/A/scholar/sherbrooke/24-01 +Images, img, ~/Dropbox/A/Personnal/Photos/unsorted +Scripts, sc, ~/.local/bin +Hotkeys, sx, ~/.config/sxhkd +Dropbox, bx, ~/Dropbox +Downloads, dl, ~/Downloads +Wallpapers, wp, ~/Pictures/wallpapers +Compilation, cp, ~/.local/src diff --git a/.local/bin/makewall b/.local/bin/makewall index f0fc854..ad8fc02 100755 --- a/.local/bin/makewall +++ b/.local/bin/makewall @@ -11,18 +11,19 @@ displays=$(xrandr | grep " connected" | sed 's/^\([a-Z,0-9,-]*\).*/\1/') # Otherwise, set the wallpaper to the default wallpaper # (default.png or default.jpg) setDisplay() { - case $(ls $wallDir) in - *"$1"*) - wall=$(ls $wallDir | grep "$1" | head -n 1) - xwallpaper --output $1 --zoom $wallDir/$wall ;; - *) - wall=$(ls $wallDir | grep "default" | head -n 1) - xwallpaper --output $1 --zoom $wallDir/$wall ;; - esac + case $(ls $wallDir) in + *"$1"*) + wall=$(ls $wallDir | grep "$1" | head -n 1) + xwallpaper --output $1 --zoom $wallDir/$wall + ;; + *) + wall=$(ls $wallDir | grep "default" | head -n 1) + xwallpaper --output $1 --zoom $wallDir/$wall + ;; + esac } # Set the wallpaper for each display for display in $displays; do - setDisplay $display + setDisplay $display done - diff --git a/.local/bin/setbg b/.local/bin/setbg new file mode 100755 index 0000000..6608d7a --- /dev/null +++ b/.local/bin/setbg @@ -0,0 +1,28 @@ +#!/bin/sh + +# Make sure given file is an image +[ -z "$1" ] && exit +[ ! -f "$1" ] && exit +[ -z "$(file "$1" | grep -o 'image data')" ] && exit + +displays=$(xrandr | grep " connected" | sed 's/^\([a-Z,0-9,-]*\).*/\1/') + +# selected="$(echo "$displays" | dmenu -w "$(xdotool getactivewindow)" -p " Select monitor:")" + +# Same as above but use dmenu only if there are multiple displays +if [ "$(echo "$displays" | wc -l)" -gt 1 ]; then + selected="$(echo "$displays" | dmenu -w "$(xdotool getactivewindow)" -p " Select monitor:")" +else + selected="$displays" +fi + +[ -z "$selected" ] && exit + +src="$1" +extension="${1##*.}" +dest="$XDG_CONFIG_HOME/wallpapers/${selected}.$extension" + +ln -sf "$src" "$dest" && notify-send -a "Wallpaper" -i "$src" "Changed monitor: $selected" + +# Re-render all wallpapers +makewall diff --git a/.local/bin/shortcutgen b/.local/bin/shortcutgen index 0020ec9..08164f0 100755 --- a/.local/bin/shortcutgen +++ b/.local/bin/shortcutgen @@ -1,63 +1,15 @@ #!/bin/sh -# Removing unecessary comments and documentation -raw=$(cat $HOME/.config/shortcutrc | tail -n +19 "$HOME/.config/shortcutrc" | sed "s/^|\s*//g; - s/\(.*\)|\(.*\)|\(.*\)|/\1|\2|\3/g; - s/\s*$//g; - /^$/d" | head -n -1) -# #---NERDTREE---# # -echo "$raw" | sed "s/\(.*\)\s*|.*|\s\(.*\)/\1\2/g; - s/ \{1,\}/ /g; - s/.HOME/~/g; - s/-*+-*+-*|//g" > $HOME/.NERDTreeBookmarks +# raw (basic processing before converting to specific formats) +# - remove comments +# - remove empty lines +# - remove spacing (keep commas between columns) +# - remove trailing whitespace -# #---ZSH---# # -# be sure to source $HOME/.cache/zsh-shortcuts in your .zshrc -echo "$raw" | sed 's/^.*|\s\([A-Za-z0-9]*\)\s*|\s\(.*\)$/alias\ g\1="cd\ \2"/g; /^-*+-*+-*|$/d' > $HOME/.cache/zsh-shortcuts +raw="$(sed 's/#.*//g;s/,\s*/,/g;/^$/d;s/\s*$//g' <"$XDG_CONFIG_HOME/shortcutrc")" -# #---RANGER---# # -# Commands implemented: -# g -> go -# m -> move to... -# t -> new tab -# Y -> copy to... -# awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts" -manual=$(sed -n '/Automated Shortcut Generation/q;p' $HOME/.config/ranger/shortcuts.conf) -printf '\n\n# #---Automated Shortcut Generation---#' >> $HOME/.config/ranger/shortcuts.conf -echo "$raw" | sed 's/^.*|\s\(.*\)\s|\s\(.*\)$/map\ g\1\ cd\ \2\nmap\ t\1\ tab_new\ \2\nmap\ m\1\ shell\ mv\ -v\ %s\ \2\nmap\ Y\1\ shell\ cp\ -rv\ %s\ \2\n/g; - s/.HOME/~/g; - s/^-*+-*+-*|$//g' >> $HOME/.config/ranger/shortcuts.conf +# lf +echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/map g\2 cd \3/' >"$XDG_CONFIG_HOME/lf/shortcuts" -# #---ENVIRONMENTAL VARIABLES---# # -echo "$raw" | sed 's/[A-z,a-z,0-9]*\s*|\s*/g/; - s/\s*|\s*/=/; s/$/"/; - s/-*+-*+.*$// - s/^[A-z]*=/\U&/g - s/"$//g' > ~/.cache/shell-vars - -# #---Vifm---# # -vifm=$(echo "$raw" | sed " - s/^[A-Z,a-z,0-9]*\s*|//; - s/\$HOME/~/; - s/$/<cr>/" -) -vifmcd=$( echo "$vifm" | sed " - s/^\s*/nnoremap\ g/; - s/|/:cd/;" -) -vifmv=$( echo "$vifm" | sed " - s/^\s*/nnoremap\ m/; - s/|/:move/") -vifmy=$( echo "$vifm" | sed " - s/^\s*/nnoremap\ y/; - s/|/:copy/") -echo "$vifmcd\n\n$vifmv\n\n$vifmy" > ~/.cache/vifm-shortcuts - - - -# #---Testing---# # -# echo "$raw" | sed "s/[A-z,a-z,0-9]*\s*|//" - -# clear -# echo "$vifmv" -# cat ~/.cache/vifm-shortcuts +# shell (aliases and environment variables) +echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/alias g\2="cd \3"\nexport G\U\2="\3"/' >"$HOME/.cache/zsh-shortcuts" |