mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Compare commits
8 Commits
034a982d53
...
aac4982c7b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aac4982c7b | ||
|
|
0795202675 | ||
|
|
bbcbac64fa | ||
|
|
52fab9d50a | ||
|
|
0db54f9618 | ||
|
|
4854a853e4 | ||
|
|
d3035edc7e | ||
|
|
943220f884 |
@ -13,10 +13,6 @@ image() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ifub() {
|
|
||||||
[ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Note that the cache file name is a function of file information, meaning if
|
# Note that the cache file name is a function of file information, meaning if
|
||||||
# an image appears in multiple places across the machine, it will not have to
|
# an image appears in multiple places across the machine, it will not have to
|
||||||
# be regenerated once seen.
|
# be regenerated once seen.
|
||||||
@ -29,10 +25,15 @@ case "$(file --dereference --brief --mime-type -- "$1")" in
|
|||||||
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
|
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
|
||||||
[ ! -f "$CACHE" ] && djvused "$1" -e 'select 1; save-page-with /dev/stdout' | convert -density 200 - "$CACHE.jpg" > /dev/null 2>&1
|
[ ! -f "$CACHE" ] && djvused "$1" -e 'select 1; save-page-with /dev/stdout' | convert -density 200 - "$CACHE.jpg" > /dev/null 2>&1
|
||||||
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
|
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
|
||||||
|
image/svg+xml)
|
||||||
|
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
|
||||||
|
[ ! -f "$CACHE" ] && inkscape --convert-dpi-method=none -o "$CACHE.png" --export-overwrite -D --export-png-color-mode=RGBA_16 "$1"
|
||||||
|
image "$CACHE.png" "$2" "$3" "$4" "$5" "$1"
|
||||||
|
;;
|
||||||
image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;;
|
image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;;
|
||||||
text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
|
text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
|
||||||
text/troff) man ./ "$1" | col -b ;;
|
text/troff) man ./ "$1" | col -b ;;
|
||||||
text/* | */xml | application/json | application/x-ndjson) bat --terminal-width "$(($4-2))" -f "$1" ;;
|
text/* | */xml | application/json | application/x-ndjson) bat -p --theme ansi --terminal-width "$(($4-2))" -f "$1" ;;
|
||||||
audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
|
audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
|
||||||
video/* )
|
video/* )
|
||||||
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
|
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
|
||||||
|
|||||||
@ -68,6 +68,14 @@ set noshowcmd
|
|||||||
imap <leader>i <esc>:call ToggleIPA()<CR>a
|
imap <leader>i <esc>:call ToggleIPA()<CR>a
|
||||||
nm <leader>q :call ToggleProse()<CR>
|
nm <leader>q :call ToggleProse()<CR>
|
||||||
|
|
||||||
|
" vim-airline
|
||||||
|
if !exists('g:airline_symbols')
|
||||||
|
let g:airline_symbols = {}
|
||||||
|
endif
|
||||||
|
let g:airline_symbols.colnr = ' C:'
|
||||||
|
let g:airline_symbols.linenr = ' L:'
|
||||||
|
let g:airline_symbols.maxlinenr = '☰ '
|
||||||
|
|
||||||
" Shortcutting split navigation, saving a keypress:
|
" Shortcutting split navigation, saving a keypress:
|
||||||
map <C-h> <C-w>h
|
map <C-h> <C-w>h
|
||||||
map <C-j> <C-w>j
|
map <C-j> <C-w>j
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
#!/bin/zsh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2155
|
||||||
|
|
||||||
# profile file. Runs on login. Environmental variables are set here.
|
# Profile file, runs on login. Environmental variables are set here.
|
||||||
|
|
||||||
# If you don't plan on reverting to bash, you can remove the link in ~/.profile
|
# Add all directories in `~/.local/bin` to $PATH
|
||||||
# to clean up.
|
export PATH="$PATH:$(find ~/.local/bin -type d | paste -sd ':' -)"
|
||||||
|
|
||||||
# Adds `~/.local/bin` to $PATH
|
unsetopt PROMPT_SP 2>/dev/null
|
||||||
export PATH="$PATH:${$(find ~/.local/bin -type d -printf %p:)%%:}"
|
|
||||||
|
|
||||||
unsetopt PROMPT_SP
|
|
||||||
|
|
||||||
# Default programs:
|
# Default programs:
|
||||||
export EDITOR="nvim"
|
export EDITOR="nvim"
|
||||||
@ -52,7 +50,7 @@ export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history"
|
|||||||
export DICS="/usr/share/stardict/dic/"
|
export DICS="/usr/share/stardict/dic/"
|
||||||
export SUDO_ASKPASS="$HOME/.local/bin/dmenupass"
|
export SUDO_ASKPASS="$HOME/.local/bin/dmenupass"
|
||||||
export FZF_DEFAULT_OPTS="--layout=reverse --height 40%"
|
export FZF_DEFAULT_OPTS="--layout=reverse --height 40%"
|
||||||
export LESS=-R
|
export LESS="R"
|
||||||
export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')"
|
export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')"
|
||||||
export LESS_TERMCAP_md="$(printf '%b' '[1;36m')"
|
export LESS_TERMCAP_md="$(printf '%b' '[1;36m')"
|
||||||
export LESS_TERMCAP_me="$(printf '%b' '[0m')"
|
export LESS_TERMCAP_me="$(printf '%b' '[0m')"
|
||||||
@ -61,15 +59,15 @@ export LESS_TERMCAP_se="$(printf '%b' '[0m')"
|
|||||||
export LESS_TERMCAP_us="$(printf '%b' '[1;32m')"
|
export LESS_TERMCAP_us="$(printf '%b' '[1;32m')"
|
||||||
export LESS_TERMCAP_ue="$(printf '%b' '[0m')"
|
export LESS_TERMCAP_ue="$(printf '%b' '[0m')"
|
||||||
export LESSOPEN="| /usr/bin/highlight -O ansi %s 2>/dev/null"
|
export LESSOPEN="| /usr/bin/highlight -O ansi %s 2>/dev/null"
|
||||||
export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme.
|
export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme.
|
||||||
export MOZ_USE_XINPUT2="1" # Mozilla smooth scrolling/touchpads.
|
export MOZ_USE_XINPUT2=1 # Mozilla smooth scrolling/touchpads.
|
||||||
export AWT_TOOLKIT="MToolkit wmname LG3D" # May have to install wmname
|
export AWT_TOOLKIT="MToolkit wmname LG3D" # May have to install wmname
|
||||||
export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm
|
export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm
|
||||||
|
|
||||||
[ ! -f ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ] && setsid shortcuts >/dev/null 2>&1
|
[ ! -f "$XDG_CONFIG_HOME/shell/shortcutrc" ] && setsid -f shortcuts >/dev/null 2>&1
|
||||||
|
|
||||||
# Start graphical server on user's current tty if not already running.
|
# Start graphical server on user's current tty if not already running.
|
||||||
[ "$(tty)" = "/dev/tty1" ] && ! pidof -s Xorg >/dev/null 2>&1 && exec startx "$XINITRC"
|
[ "$(tty)" = "/dev/tty1" ] && ! pidof -s Xorg >/dev/null 2>&1 && exec startx "$XINITRC"
|
||||||
|
|
||||||
# Switch escape and caps if tty and no passwd required:
|
# Switch escape and caps if tty and no passwd required:
|
||||||
sudo -n loadkeys ${XDG_DATA_HOME:-$HOME/.local/share}/larbs/ttymaps.kmap 2>/dev/null
|
sudo -n loadkeys "$XDG_DATA_HOME/larbs/ttymaps.kmap" 2>/dev/null
|
||||||
|
|||||||
111
.local/bin/chadmarked
Normal file
111
.local/bin/chadmarked
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
#!/bin/dash
|
||||||
|
|
||||||
|
URLQUERY_FILE="$HOME/.local/share/urlquery"
|
||||||
|
CLIPBOARD="xclip -o"
|
||||||
|
ACTION_MENU='@@'
|
||||||
|
|
||||||
|
DMENU() {
|
||||||
|
dmenu -i -l $1 -p "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
error_notify() {
|
||||||
|
notify-send "$1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_file_exists() {
|
||||||
|
[ -f "$URLQUERY_FILE" ] || {
|
||||||
|
notify-send "$URLQUERY_FILE does not exist. Creating it now."
|
||||||
|
touch "$URLQUERY_FILE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get_selection() {
|
||||||
|
cut -d= -f1 "$URLQUERY_FILE" | DMENU $LINE_COUNT "Bookmarks"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_file() {
|
||||||
|
pattern="$1"
|
||||||
|
replacement="$2"
|
||||||
|
sed "/$pattern/c\\
|
||||||
|
$replacement" "$URLQUERY_FILE" > "$URLQUERY_FILE.tmp" && mv "$URLQUERY_FILE.tmp" "$URLQUERY_FILE" ||
|
||||||
|
error_notify "Failed to update the file."
|
||||||
|
}
|
||||||
|
|
||||||
|
is_valid_url() {
|
||||||
|
echo "$1" | grep -qE "^https?://[^[:space:]/?#][^[:space:]]+$"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_bookmark() {
|
||||||
|
URL=$($CLIPBOARD)
|
||||||
|
is_valid_url "$URL" || error_notify "The clipboard content is not a valid URL."
|
||||||
|
grep -q "=$URL$" "$URLQUERY_FILE" && notify-send "The URL is already in the list." && return
|
||||||
|
NAME=$(DMENU 0 "Name")
|
||||||
|
[ -n "$NAME" ] && echo "${NAME}=${URL}" >> "$URLQUERY_FILE" && notify-send "'$NAME' is bookmarked."
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_bookmark() {
|
||||||
|
NAME=$(get_selection)
|
||||||
|
[ -z "$NAME" ] && error_notify "Failed to delete the bookmark."
|
||||||
|
sed "/^$NAME=/d" "$URLQUERY_FILE" > "$URLQUERY_FILE.tmp"
|
||||||
|
mv "$URLQUERY_FILE.tmp" "$URLQUERY_FILE"
|
||||||
|
[ ! -s "$URLQUERY_FILE" ] || ! grep -qE "\S" "$URLQUERY_FILE" && rm "$URLQUERY_FILE"
|
||||||
|
notify-send "'$NAME' is deleted."
|
||||||
|
}
|
||||||
|
|
||||||
|
edit_name() {
|
||||||
|
OLD_NAME="$1"
|
||||||
|
NEW_NAME=$(DMENU 0 "New Name")
|
||||||
|
[ -z "$NEW_NAME" ] && return
|
||||||
|
URL=$(grep "^$OLD_NAME=" "$URLQUERY_FILE" | cut -d= -f2)
|
||||||
|
update_file "^$OLD_NAME=" "$NEW_NAME=$URL"
|
||||||
|
}
|
||||||
|
|
||||||
|
edit_url() {
|
||||||
|
NAME="$1"
|
||||||
|
NEW_URL=$(DMENU 0 "New URL")
|
||||||
|
[ -z "$NEW_URL" ] && return
|
||||||
|
update_file "^$NAME=.*" "$NAME=$NEW_URL"
|
||||||
|
}
|
||||||
|
|
||||||
|
edit_bookmark() {
|
||||||
|
NAME=$(get_selection)
|
||||||
|
[ -z "$NAME" ] && error_notify "Failed to edit the bookmark."
|
||||||
|
FIELD=$(echo "Name\nURL" | DMENU 2 "Edit")
|
||||||
|
case "$FIELD" in
|
||||||
|
"Name") edit_name "$NAME" ;;
|
||||||
|
"URL") edit_url "$NAME" ;;
|
||||||
|
esac
|
||||||
|
notify-send "'$NAME' is updated."
|
||||||
|
}
|
||||||
|
|
||||||
|
open_bookmark() {
|
||||||
|
URL=$(grep "^$SELECTION=" "$URLQUERY_FILE" | cut -d= -f2-)
|
||||||
|
case "$URL" in
|
||||||
|
*"search"*|*"wiki"*)
|
||||||
|
QUERY=$(DMENU 0 "Search")
|
||||||
|
URL="${URL}${QUERY}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
$BROWSER "$URL" || notify-send "Failed to open the URL."
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_file_exists
|
||||||
|
|
||||||
|
LINE_COUNT=$(wc -l < "$URLQUERY_FILE")
|
||||||
|
SELECTION=$(get_selection)
|
||||||
|
[ -z "$SELECTION" ] && exit
|
||||||
|
|
||||||
|
case "$SELECTION" in
|
||||||
|
"$ACTION_MENU")
|
||||||
|
ACTION=$(echo "Add\nDelete\nEdit" | DMENU 3 "Action")
|
||||||
|
case "$ACTION" in
|
||||||
|
"Add") add_bookmark ;;
|
||||||
|
"Delete") delete_bookmark ;;
|
||||||
|
"Edit") edit_bookmark ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
open_bookmark
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Loading…
x
Reference in New Issue
Block a user