updates galore!

This commit is contained in:
Solomon Laing 2024-04-16 21:41:55 +09:30
parent 149f84431a
commit fa6f8bbdfb
15 changed files with 226 additions and 304 deletions

View File

@ -18,28 +18,28 @@ set cleaner ctpvclear
# cmds/functions
cmd open ${{
case $(file --mime-type "$(readlink -f $f)" -b) in
application/vnd.oasis.opendocument.text) lowriter $fs ;;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
text/*|application/json|application/javascript|inode/x-empty) $EDITOR $fx;;
text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
image/svg+xml) display -- $f ;;
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" |
setsid -f sxiv -aio 2>/dev/null | while read -r file; do
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
setsid -f nsxiv -aio 2>/dev/null | while read -r file; do
[ -z "$file" ] && continue
lf -remote "send select \"$file\""
lf -remote "send toggle"
done &
;;
audio/*) mpv --audio-display=no $f ;;
audio/*|video/x-ms-asf) mpv --audio-display=no $f ;;
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
application/pdf|application/vnd*|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
application/pgp-encrypted) $EDITOR $fx ;;
application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
*) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
esac
}}
cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
cmd mkdir $mkdir -p "$@"
cmd extract ${{
clear; tput cup $(($(tput lines)/3)); tput bold
@ -47,7 +47,22 @@ cmd extract ${{
printf "%s\n\t" "$fx"
printf "extract?[y/N]"
read ans
[ $ans = "y" ] && aunpack $fx
[ $ans = "y" ] && {
case $fx in
*.tar.bz2) tar xjf $fx ;;
*.tar.gz) tar xzf $fx ;;
*.bz2) bunzip2 $fx ;;
*.rar) unrar e $fx ;;
*.gz) gunzip $fx ;;
*.tar) tar xf $fx ;;
*.tbz2) tar xjf $fx ;;
*.tgz) tar xzf $fx ;;
*.zip) unzip $fx ;;
*.Z) uncompress $fx ;;
*.7z) 7z x $fx ;;
*.tar.xz) tar xf $fx ;;
esac
}
}}
cmd delete ${{

View File

@ -13,20 +13,27 @@ image() {
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
# an image appears in multiple places across the machine, it will not have to
# be regenerated once seen.
case "$(file --dereference --brief --mime-type -- "$1")" in
image/avif) 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" ] && convert "$1" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;;
image/vnd.djvu)
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
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" ;;
#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/* | */xml | application/json) bat --terminal-width "$(($4-2))" -f "$1" ;;
application/zip) atool --list -- "$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 ;;
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)"
@ -38,6 +45,12 @@ case "$(file --dereference --brief --mime-type -- "$1")" in
[ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;;
*/epub+zip|*/mobi*)
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.jpg" ] && gnome-epub-thumbnailer "$1" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;;
application/*zip) atool --list -- "$1" ;;
*opendocument*) odt2txt "$1" ;;
application/pgp-encrypted) gpg -d -- "$1" ;;
esac

View File

@ -1,96 +0,0 @@
vim.api.nvim_create_autocmd({ "User" }, {
pattern = { "AlphaReady" },
callback = function()
vim.cmd([[
set laststatus=0 | autocmd BufUnload <buffer> set laststatus=3
]])
end,
})
vim.api.nvim_create_autocmd({ "VimResized" }, {
callback = function()
vim.cmd("tabdo wincmd =")
end,
})
vim.api.nvim_create_autocmd({ "CmdWinEnter" }, {
callback = function()
vim.cmd("quit")
end,
})
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
callback = function()
vim.cmd("set formatoptions-=cro")
end,
})
-- highlight on yank
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
callback = function()
vim.highlight.on_yank()
end,
})
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
vim.cmd("hi link illuminatedWord LspReferenceText")
end,
})
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- close some filetypes with <q>
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"qf",
"help",
"man",
"notify",
"lspinfo",
"spectre_panel",
"startuptime",
"tsplayground",
"PlenaryTestPopup",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
-- add spellcheck and wrapping to some file types
vim.api.nvim_create_autocmd("FileType", {
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- Prevent auto comment on next line
vim.cmd([[autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o]])
-- Set filetype to tex for .tex files?
vim.cmd([[autocmd BufRead,BufNewFile *.tex set filetype=tex]])
-- Trim whitespace from files on save
vim.cmd([[
autocmd BufWritePre * let currPos = getpos(".")
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre *.[ch] %s/\%$/\r/e
autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
]])
-- Run custom textclear command when exiting a .tex file (cleanup files)
vim.cmd([[autocmd VimLeave *.tex !texclear %]])

View File

@ -30,10 +30,6 @@ map("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result
map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
-- Copy/Paste
map("n", "<C-y>", '"+y', opts)
map("n", "<C-p>", '"+p', opts)
-- Save
map("n", "<C-s>", "<ESC>:w<CR>", opts)
map("i", "<C-s>", "<ESC>:w<CR>", opts)
@ -52,3 +48,7 @@ map("i", "jk", "<ESC>", opts)
-- Indenting
map("v", "<", "<gv", opts)
map("v", ">", ">gv", opts)
-- move through quickfix list
map("n", "<C-n>", ":cnext<cr>", opts)
map("n", "<C-p>", ":cprev<cr>", opts)

View File

@ -8,22 +8,22 @@ return {
"hrsh7th/cmp-emoji",
"hrsh7th/cmp-buffer",
"saadparwaiz1/cmp_luasnip",
{
"zbirenbaum/copilot-cmp",
dependencies = "copilot.lua",
opts = {},
config = function(_, opts)
local copilot_cmp = require("copilot_cmp")
copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source
require("lazyvim.utils").on_attach(function(client)
if client.name == "copilot" then
copilot_cmp._on_insert_enter({})
end
end)
end,
},
-- {
-- "zbirenbaum/copilot-cmp",
-- dependencies = "copilot.lua",
-- opts = {},
-- config = function(_, opts)
-- local copilot_cmp = require("copilot_cmp")
-- copilot_cmp.setup(opts)
-- -- attach cmp source whenever copilot attaches
-- -- fixes lazy-loading issues with the copilot cmp source
-- require("lazyvim.utils").on_attach(function(client)
-- if client.name == "copilot" then
-- copilot_cmp._on_insert_enter({})
-- end
-- end)
-- end,
-- },
},
config = function()
local cmp = require("cmp")
@ -51,7 +51,7 @@ return {
{ name = "path" },
{ name = "emoji" },
{ name = "buffer" },
{ name = "copilot" },
-- { name = "copilot" },
}),
formatting = {
format = function(_, item)
@ -70,20 +70,20 @@ return {
})
end,
},
{
"zbirenbaum/copilot-cmp",
dependencies = "copilot.lua",
opts = {},
config = function(_, opts)
local copilot_cmp = require("copilot_cmp")
copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source
require("lazyvim.utils").on_attach(function(client)
if client.name == "copilot" then
copilot_cmp._on_insert_enter({})
end
end)
end,
}
-- {
-- "zbirenbaum/copilot-cmp",
-- dependencies = "copilot.lua",
-- opts = {},
-- config = function(_, opts)
-- local copilot_cmp = require("copilot_cmp")
-- copilot_cmp.setup(opts)
-- -- attach cmp source whenever copilot attaches
-- -- fixes lazy-loading issues with the copilot cmp source
-- require("lazyvim.utils").on_attach(function(client)
-- if client.name == "copilot" then
-- copilot_cmp._on_insert_enter({})
-- end
-- end)
-- end,
-- }
}

View File

@ -7,11 +7,9 @@ return {
keys = {
{ "<leader>/", util.telescope("live_grep"), desc = "Find in Files (Grep)" },
{ "<leader><space>", util.telescope("find_files"), desc = "Find Files (root dir)" },
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" },
{ "<leader>ff", util.telescope("find_files"), desc = "Find Files (root dir)" },
{ "<leader>fF", util.telescope("find_files", { cwd = false }), desc = "Find Files (cwd)" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
{ "<leader>fp", "<cmd>Telescope projects<cr>", desc = "Find Projects" },
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },
{ "<leader>gb", "<cmd>Telescope git_branches<CR>", desc = "branches" },
@ -26,11 +24,10 @@ return {
{ "<leader>ht", "<cmd>Telescope builtin<cr>", desc = "Telescope" },
{ "<leader>sb", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "Buffer" },
{ "<leader>sc", "<cmd>Telescope command_history<cr>", desc = "Command History" },
{ "<leader>sg", util.telescope("live_grep"), desc = "Grep (root dir)" },
{ "<leader>sG", util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" },
{ "<leader>sG", util.telescope("live_grep"), desc = "Grep (root dir)" },
{ "<leader>sg", util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" },
{ "<leader>sm", "<cmd>Telescope marks<cr>", desc = "Jump to Mark" },
{ "<leader>so", "<cmd>Telescope resume<cr>", desc = "Resume last search" },
{ "<leader>sC", "<cmd>Telescope colorscheme<cr>", desc = "Colorscheme" },
{
"<leader>ss",
util.telescope("lsp_document_symbols", {

View File

@ -74,12 +74,12 @@ return {
u = { "<cmd>UndotreeToggle<cr>", "Undo Tree" },
["'"] = { "<cmd>close<CR>", "Close split" },
c = {
name = "+copilot",
c = { "<cmd>Copilot enable<cr>", "Enable Copilot" },
d = { "<cmd>Copilot disable<cr>", "Disable Copilot" },
t = { "<cmd>Copilot toggle<cr>", "Toggle Copilot" },
},
-- c = {
-- name = "+copilot",
-- c = { "<cmd>Copilot enable<cr>", "Enable Copilot" },
-- d = { "<cmd>Copilot disable<cr>", "Disable Copilot" },
-- t = { "<cmd>Copilot toggle<cr>", "Toggle Copilot" },
-- },
n = {
name = "+neorg",
@ -95,11 +95,6 @@ return {
},
},
f = {
name = "+file",
n = { "<cmd>enew<cr>", "New File" },
},
q = {
name = "+quit",
q = { "<cmd>wq<CR>", "Save and Quit Current" },

View File

@ -1,19 +1,17 @@
#!/bin/sh
# Syncs repositories and downloads updates, meant to be run as a cronjob.
# make sure you have set up passwordless sudo in SUDOERS file for this script
notify-send "Repository Sync" "Checking for package updates..."
notify-send "📦 Repository Sync" "Checking for package updates..."
sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]"
then
notify-send "Repository Sync" "Sync comelete. You have updates $(pacman -Qu | grep -vc "\[ignored\]") available."
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
else
notify-send "Repository Sync" "Sync complete. No new packages for update."
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
fi

View File

@ -3,4 +3,4 @@
# Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.config/cronsaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "Cronjobs saved and disabled.")
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")

View File

@ -9,10 +9,10 @@ output="$(date '+%y%m%d-%H%M-%S').png"
xclip_cmd="xclip -sel clip -t image/png"
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
"a selected area") maim -s pic-selected-"${output}" ;;
"a selected area") maim -u -s pic-selected-"${output}" ;;
"current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
"full screen") maim -q -d 0.2 pic-full-"${output}" ;;
"a selected area (copy)") maim -s | ${xclip_cmd} ;;
"a selected area (copy)") maim -u -s | ${xclip_cmd} ;;
"current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
"full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
esac

View File

@ -36,7 +36,7 @@ filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6
unopenedluks="$(for drive in $allluks; do
uuid="${drive%% *}"
uuid="${uuid//-}" # This is a bashism.
for open in $decrypted; do
[ -n "$decrypted" ] && for open in $decrypted; do
[ "$uuid" = "$open" ] && break 1
done && continue 1
echo "🔒 $drive"

View File

@ -1,11 +1,11 @@
#!/bin/sh
# When I open an image from the file manager in sxiv (the image viewer), I want
# When I open an image from the file manager in nsxiv (the image viewer), I want
# to be able to press the next/previous keys to key through the rest of the
# images in the same directory. This script "rotates" the content of a
# directory based on the first chosen file, so that if I open the 15th image,
# if I press next, it will go to the 16th etc. Autistic, I know, but this is
# one of the reasons that sxiv is great for being able to read standard input.
# one of the reasons that nsxiv is great for being able to read standard input.
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
base="$(basename "$1")"

View File

@ -1,4 +1,4 @@
[Desktop Entry]
Type=Application
Name=Image viewer
Exec=/usr/bin/sxiv -a %f
Exec=/usr/bin/nsxiv -a %f