mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Compare commits
13 Commits
db779b6efd
...
0e54f8cd4c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e54f8cd4c | ||
|
|
628ed4dc99 | ||
|
|
a9cde940c2 | ||
|
|
779ef2f5fe | ||
|
|
131dcce268 | ||
|
|
5c346d90ac | ||
|
|
7752ed9ef1 | ||
|
|
0465be083b | ||
|
|
c25ce80916 | ||
|
|
156747aa77 | ||
|
|
8ec5ec569d | ||
|
|
8b4e8f59bb | ||
|
|
62e2856882 |
@ -7,10 +7,8 @@ restore_paused "yes"
|
|||||||
max_output_buffer_size "16384"
|
max_output_buffer_size "16384"
|
||||||
|
|
||||||
audio_output {
|
audio_output {
|
||||||
type "pulse"
|
type "pipewire"
|
||||||
name "pulse"
|
name "PipeWire Sound Server"
|
||||||
#type "alsa"
|
|
||||||
#name "ALSA"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_output {
|
audio_output {
|
||||||
|
|||||||
@ -57,4 +57,4 @@ alias \
|
|||||||
alias \
|
alias \
|
||||||
lf="lfub" \
|
lf="lfub" \
|
||||||
magit="nvim -c MagitOnly" \
|
magit="nvim -c MagitOnly" \
|
||||||
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \
|
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
||||||
|
|||||||
@ -15,6 +15,7 @@ setopt inc_append_history
|
|||||||
|
|
||||||
# Load aliases and shortcuts if existent.
|
# Load aliases and shortcuts if existent.
|
||||||
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
|
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
|
||||||
|
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc"
|
||||||
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc"
|
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc"
|
||||||
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,71 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit
|
|
||||||
|
|
||||||
if [ -f "$1" ]; then
|
BIB_FILE="${HOME}/latex/uni.bib"
|
||||||
# Try to get DOI from pdfinfo or pdftotext output.
|
[ -f "${BIB_FILE}" ] || BIB_FILE="${2:-$(find "${HOME}" -path "${HOME}/.*" \
|
||||||
doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
|
-prune -o -type "f" -name "*.bib" -print -quit)}"
|
||||||
doi=$(pdftotext "$1" 2>/dev/null - | sed -n '/[dD][oO][iI]:/{s/.*[dD][oO][iI]:\s*\(\S\+[[:alnum:]]\).*/\1/p;q}') ||
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
doi="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check crossref.org for the bib citation.
|
{ [ -f "${BIB_FILE}" ] || [ "${2}" ]; } || {
|
||||||
curl -s "https://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
|
printf "%s\n" "Create a .bib file or provide as \$2." && exit "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
filter() {
|
||||||
|
sed -n -E 's/.*((DOI|doi)((\.(org))?\/?|:? *))([^: ]+[^ .]).*/\6/p; T; q'
|
||||||
|
}
|
||||||
|
|
||||||
|
fpdf() {
|
||||||
|
pdf="${1}"
|
||||||
|
doi="$(pdfinfo "${pdf}" 2> "/dev/null" | filter)"
|
||||||
|
|
||||||
|
[ "${doi}" ] || doi="$(pdftotext -q -l "2" "${pdf}" - 2> "/dev/null" | filter)"
|
||||||
|
|
||||||
|
[ "${doi}" ] || printf "%s\n" "No DOI found for PDF: ${pdf}" >&2
|
||||||
|
|
||||||
|
printf "%s\n" "${doi}"
|
||||||
|
}
|
||||||
|
|
||||||
|
arrange() {
|
||||||
|
sed 's/\}, /\},\n /g
|
||||||
|
s/, /,\n /
|
||||||
|
s/ }/\n}/
|
||||||
|
s/,\s*pages=/,\n\tpages=/' |
|
||||||
|
sed '1s/^ *//
|
||||||
|
1s/[0-9]*\([0-9]\{2\}\)/\1/
|
||||||
|
1s/_//
|
||||||
|
1s/.*/\L&/
|
||||||
|
s/.*=/\L&/
|
||||||
|
s/=/ = /'
|
||||||
|
}
|
||||||
|
|
||||||
|
doi2bib() {
|
||||||
|
doi="${1#doi:}"
|
||||||
|
url="https://api.crossref.org/works/${doi}/transform/application/x-bibtex"
|
||||||
|
entry="$(curl -kLsS --no-fail "${url}" | arrange)"
|
||||||
|
red='\033[0;31m'
|
||||||
|
reset='\033[0m'
|
||||||
|
|
||||||
|
printf "${red}%s${reset}\n" "${entry}"
|
||||||
|
|
||||||
|
[ "${entry%"${entry#?}"}" != "@" ] && {
|
||||||
|
printf "%s\n" "Failed to fetch bibtex entry for DOI: ${doi}"
|
||||||
|
return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
grep -iFq "doi = {${doi}}" "${BIB_FILE}" 2> "/dev/null" && {
|
||||||
|
printf "%s\n" "Bibtex entry for DOI: ${doi} already exists in the file."
|
||||||
|
} || {
|
||||||
|
[ -s "${BIB_FILE}" ] && printf "\n" >> "${BIB_FILE}"
|
||||||
|
printf "%s\n" "${entry}" >> "${BIB_FILE}"
|
||||||
|
printf "%s\n" "Added bibtex entry for DOI: ${doi}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "${1}" ] || {
|
||||||
|
printf "%s\n" "Give either a pdf file or a DOI or a directory path that has PDFs as an argument."
|
||||||
|
exit "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -f "${1}" ] && doi="$(fpdf "${1}")" && doi2bib "${doi}" && exit "0"
|
||||||
|
|
||||||
|
[ -d "${1}" ] && for i in "${1}"/*.pdf; do doi="$(fpdf "${i}")" && doi2bib "${doi}"; done && exit "0"
|
||||||
|
|
||||||
|
doi="$(printf "%s\n" "${1}" | filter)" && doi2bib "${doi}"
|
||||||
|
|||||||
@ -79,8 +79,13 @@ case "$chosen" in
|
|||||||
💾*)
|
💾*)
|
||||||
chosen="${chosen%% *}"
|
chosen="${chosen%% *}"
|
||||||
chosen="${chosen:1}" # This is a bashism.
|
chosen="${chosen:1}" # This is a bashism.
|
||||||
|
parttype="$(echo "$lsblkoutput" | grep "$chosen")"
|
||||||
attemptmount || getmount
|
attemptmount || getmount
|
||||||
sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)"
|
case "${parttype##* }" in
|
||||||
|
vfat) sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000 ;;
|
||||||
|
btrfs) sudo -A mount "$chosen" "$mp" ;;
|
||||||
|
*) sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)" ;;
|
||||||
|
esac
|
||||||
notify-send "💾Drive Mounted." "$chosen mounted to $mp."
|
notify-send "💾Drive Mounted." "$chosen mounted to $mp."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ bmfiles="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files"
|
|||||||
|
|
||||||
# Output locations. Unactivated progs should go to /dev/null.
|
# Output locations. Unactivated progs should go to /dev/null.
|
||||||
shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
|
shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
|
||||||
|
shell_env_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc"
|
||||||
zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
|
||||||
lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc"
|
lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc"
|
||||||
vim_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim"
|
vim_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim"
|
||||||
@ -16,12 +17,14 @@ vifm_shortcuts="/dev/null"
|
|||||||
rm -f "$lf_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" "$vim_shortcuts" 2>/dev/null
|
rm -f "$lf_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" "$vim_shortcuts" 2>/dev/null
|
||||||
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
|
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
|
||||||
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
|
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
|
||||||
|
printf "# vim: filetype=sh\\n" > "$shell_env_shortcuts"
|
||||||
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
|
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
|
||||||
|
|
||||||
# Format the `directories` file in the correct syntax and sent it to all three configs.
|
# Format the `directories` file in the correct syntax and sent it to all three configs.
|
||||||
eval "echo \"$(cat "$bmdirs")\"" | \
|
eval "echo \"$(cat "$bmdirs")\"" | \
|
||||||
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||||
printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||||
|
printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ;
|
||||||
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
||||||
printf(\"abbr %s \42cd %s; and ls -A\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
printf(\"abbr %s \42cd %s; and ls -A\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||||
printf(\"map g%s :cd %s<CR>\nmap t%s <tab>:cd %s<CR><tab>\nmap M%s <tab>:cd %s<CR><tab>:mo<CR>\nmap Y%s <tab>:cd %s<CR><tab>:co<CR> \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ;
|
printf(\"map g%s :cd %s<CR>\nmap t%s <tab>:cd %s<CR><tab>\nmap M%s <tab>:cd %s<CR><tab>:mo<CR>\nmap Y%s <tab>:cd %s<CR><tab>:co<CR> \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ;
|
||||||
@ -33,6 +36,7 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
|||||||
eval "echo \"$(cat "$bmfiles")\"" | \
|
eval "echo \"$(cat "$bmfiles")\"" | \
|
||||||
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||||
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||||
|
printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ;
|
||||||
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
||||||
printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||||
printf(\"map %s :e %s<CR> \n\",\$1,\$2) >> \"$vifm_shortcuts\" ;
|
printf(\"map %s :e %s<CR> \n\",\$1,\$2) >> \"$vifm_shortcuts\" ;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user