From 7c18316e4f978490744be4a01b2973eebb5d7cb1 Mon Sep 17 00:00:00 2001 From: spinach <19keegandeppe@gmail.com> Date: Mon, 3 Apr 2023 18:41:20 -0400 Subject: [PATCH] added general purpose file browser with proper launcher --- bin/rofi-files | 49 +++++++++++++++++++ editors/nvim/config/lua/due_nvim.lua | 5 +- editors/nvim/site/after/ftplugin/markdown.lua | 1 + .../site/pack/filebroswer/start/nvim-tree | 2 +- .../pack/filebroswer/start/telescope.nvim | 2 +- editors/nvim/site/pack/golang/opt/vim-go | 2 +- editors/nvim/site/pack/markdown/opt/vimwiki | 2 +- editors/nvim/site/pack/qol/start/vim-fugitive | 2 +- .../site/pack/statusbar/start/vim-airline | 2 +- gui/i3/base.conf | 3 ++ meta/configs/scripts.yaml | 1 + meta/dotbot | 2 +- shells/oh-my-zsh/custom/themes/powerlevel10k | 2 +- shells/st | 2 +- src/fzf | 2 +- src/tmux-mem-cpu-load | 2 +- src/weather | 2 +- 17 files changed, 70 insertions(+), 13 deletions(-) create mode 100755 bin/rofi-files diff --git a/bin/rofi-files b/bin/rofi-files new file mode 100755 index 0000000..b9024ea --- /dev/null +++ b/bin/rofi-files @@ -0,0 +1,49 @@ +#!/bin/bash + +# getting focused pwd +PID=$(xdotool getwindowfocus getwindowpid) +child=$PID +children=() +while [ -n "$child" ] ; do + children+=($child) + child=$(pgrep -P $child) +done + +last_ps=$(ps ${children[-1]} | grep -v PID | awk '{print $5}') + +if [ "$last_ps" == "tmux" ] ; then + current_pane=$(tmux list-panes | grep '(active)' | grep -o '^[0-9]') + cwd=$(tmux display-message -p -t $current_pane -F '#{pane_current_path}') +else + cwd=$(readlink -e /proc/${children[-2]}/cwd) +fi + +# change to the directory +cd $cwd +files=$(find * -type f) + +selection=$(echo "$files" | rofi-dmenu) + +# exit on quit +if [ -z "$selection" ] ; then + exit 0 +fi + +# grab extension +extension=$(echo "$selection" | grep -o '.\([a-zA-Z]\+\)$') + +# get proper opener +case "$extension" in + '.pdf') prg="zathura" ;; + '.md') prg="vim" ;; + '.png') prg="feh" ;; + '.jpg') prg="feh" ;; + '.jpeg') prg="feh" ;; + *) prg="xdg-open" ;; +esac + +if [[ "$1" == '-S' && "$prg" =~ [feh|zathura] ]] ; then + swallow $prg "$selection" +else + $prg "$selection" +fi diff --git a/editors/nvim/config/lua/due_nvim.lua b/editors/nvim/config/lua/due_nvim.lua index 60b952c..ea40311 100644 --- a/editors/nvim/config/lua/due_nvim.lua +++ b/editors/nvim/config/lua/due_nvim.lua @@ -119,6 +119,7 @@ function M.setup(c) overdue = c.overdue or 'OVERDUE' overdue_hi = c.overdue_hi or 'Error' date_hi = c.date_hi or 'Conceal' + week_hi = c.week_hi or 'Question' pattern_start = c.pattern_start or '<' pattern_end = c.pattern_end or '>' date_pattern = c.date_pattern or '(%d%d)%-(%d%d)' @@ -174,8 +175,10 @@ local function draw_due(due, buf, key) parsed = { today, today_hi } elseif due < 86400 then parsed = { parseDue(due), today_hi } - else + elseif due < 604800 then parsed = { parseDue(due), due_hi } + else + parsed = { parseDue(due), week_hi } end else parsed = { overdue, overdue_hi } diff --git a/editors/nvim/site/after/ftplugin/markdown.lua b/editors/nvim/site/after/ftplugin/markdown.lua index 6dcaa41..e804bcf 100644 --- a/editors/nvim/site/after/ftplugin/markdown.lua +++ b/editors/nvim/site/after/ftplugin/markdown.lua @@ -5,6 +5,7 @@ vim.cmd('packadd vimwiki') require('due_nvim').setup { ft = '*.md', date_hi = 'Comment', + week_hi = 'Structure', pattern_start = '<', pattern_end = '>', diff --git a/editors/nvim/site/pack/filebroswer/start/nvim-tree b/editors/nvim/site/pack/filebroswer/start/nvim-tree index bbb6d48..94e3b09 160000 --- a/editors/nvim/site/pack/filebroswer/start/nvim-tree +++ b/editors/nvim/site/pack/filebroswer/start/nvim-tree @@ -1 +1 @@ -Subproject commit bbb6d4891009de7dab05ad8fc2d39f272d7a751c +Subproject commit 94e3b0990017a42fa4581ea3d0bc08b897727d4d diff --git a/editors/nvim/site/pack/filebroswer/start/telescope.nvim b/editors/nvim/site/pack/filebroswer/start/telescope.nvim index a3f17d3..942fe5f 160000 --- a/editors/nvim/site/pack/filebroswer/start/telescope.nvim +++ b/editors/nvim/site/pack/filebroswer/start/telescope.nvim @@ -1 +1 @@ -Subproject commit a3f17d3baf70df58b9d3544ea30abe52a7a832c2 +Subproject commit 942fe5faef47b21241e970551eba407bc10d9547 diff --git a/editors/nvim/site/pack/golang/opt/vim-go b/editors/nvim/site/pack/golang/opt/vim-go index 23cc4bc..a494378 160000 --- a/editors/nvim/site/pack/golang/opt/vim-go +++ b/editors/nvim/site/pack/golang/opt/vim-go @@ -1 +1 @@ -Subproject commit 23cc4bca2f586c8c2f7d2cb78bbbfec4b7361763 +Subproject commit a494378f6c106a97e39c62b493c14476f9f7de4f diff --git a/editors/nvim/site/pack/markdown/opt/vimwiki b/editors/nvim/site/pack/markdown/opt/vimwiki index fea8bee..dec6a9e 160000 --- a/editors/nvim/site/pack/markdown/opt/vimwiki +++ b/editors/nvim/site/pack/markdown/opt/vimwiki @@ -1 +1 @@ -Subproject commit fea8bee382b2051b0137fd2cacf0862823ee69b3 +Subproject commit dec6a9ecab3e5ec9ceff28b84cabb5c62d05ee9f diff --git a/editors/nvim/site/pack/qol/start/vim-fugitive b/editors/nvim/site/pack/qol/start/vim-fugitive index 5b52a0f..ef99f1d 160000 --- a/editors/nvim/site/pack/qol/start/vim-fugitive +++ b/editors/nvim/site/pack/qol/start/vim-fugitive @@ -1 +1 @@ -Subproject commit 5b52a0f395065d6cb7b65a00a5e17eaf9ebd64d5 +Subproject commit ef99f1d90cdb33a52931aed5868785b51fb9411d diff --git a/editors/nvim/site/pack/statusbar/start/vim-airline b/editors/nvim/site/pack/statusbar/start/vim-airline index 038e3a6..a532fed 160000 --- a/editors/nvim/site/pack/statusbar/start/vim-airline +++ b/editors/nvim/site/pack/statusbar/start/vim-airline @@ -1 +1 @@ -Subproject commit 038e3a6ca59f11b3bb6a94087c1792322d1a1d5c +Subproject commit a532fed72ace069e61c0132125b728316f9abd3c diff --git a/gui/i3/base.conf b/gui/i3/base.conf index 305d584..853c233 100644 --- a/gui/i3/base.conf +++ b/gui/i3/base.conf @@ -51,6 +51,9 @@ bindsym $mod+Shift+q kill # start dmenu (a program launcher) bindsym $mod+d exec --no-startup-id rofi-launcher +bindsym $mod+o exec --no-startup-id rofi-files +bindsym $mod+Shift+o exec --no-startup-id rofi-files -S + # setting up a vimscratch pad to use vimwiki for_window [instance="todo"] move window to scratchpad for_window [instance="cal"] move window to scratchpad diff --git a/meta/configs/scripts.yaml b/meta/configs/scripts.yaml index 9422c89..de8d9b0 100644 --- a/meta/configs/scripts.yaml +++ b/meta/configs/scripts.yaml @@ -8,6 +8,7 @@ - link: ~/.local/bin/ssh_agent_check: bin/ssh_agent_check ~/.local/bin/poly_spotify: bin/poly_spotify + ~/.local/bin/rofi-files: bin/rofi-files ~/.local/bin/i3-scratchpad.sh: bin/i3-scratchpad.sh ~/.local/bin/todo_display.sh: bin/todo_display.sh ~/.local/bin/display_uptime: bin/display_uptime diff --git a/meta/dotbot b/meta/dotbot index da928a4..328bcb3 160000 --- a/meta/dotbot +++ b/meta/dotbot @@ -1 +1 @@ -Subproject commit da928a4c6b65148bfda3138674da1730c143f396 +Subproject commit 328bcb32590e5057b09bd27a40bc2fb21385fbf3 diff --git a/shells/oh-my-zsh/custom/themes/powerlevel10k b/shells/oh-my-zsh/custom/themes/powerlevel10k index a30145b..b474978 160000 --- a/shells/oh-my-zsh/custom/themes/powerlevel10k +++ b/shells/oh-my-zsh/custom/themes/powerlevel10k @@ -1 +1 @@ -Subproject commit a30145b0f82d06770e924e9eac064ed223a94e6b +Subproject commit b474978b2e9435c10ca66f8281352ebc825264f4 diff --git a/shells/st b/shells/st index d698aee..462ef27 160000 --- a/shells/st +++ b/shells/st @@ -1 +1 @@ -Subproject commit d698aee479f7fd5ce635568aa9892380d80f8ed7 +Subproject commit 462ef27cf39db4a837eeecf7135fb65cd0b8789a diff --git a/src/fzf b/src/fzf index 3364d4d..2023040 160000 --- a/src/fzf +++ b/src/fzf @@ -1 +1 @@ -Subproject commit 3364d4d147ade148d8e5dd67609e46f0ef6c50fc +Subproject commit 20230402d087858ca9a93aa8fe53d289f29c1836 diff --git a/src/tmux-mem-cpu-load b/src/tmux-mem-cpu-load index 5dccd18..6d96a8a 160000 --- a/src/tmux-mem-cpu-load +++ b/src/tmux-mem-cpu-load @@ -1 +1 @@ -Subproject commit 5dccd1801f36efb14e6b43ad90cb9569fe220d1c +Subproject commit 6d96a8a4906e91f44ddf97645d5c3c1980212402 diff --git a/src/weather b/src/weather index cb8bdd3..020bbf7 160000 --- a/src/weather +++ b/src/weather @@ -1 +1 @@ -Subproject commit cb8bdd3e43b50a0610cff3a69959cb27eb407afc +Subproject commit 020bbf7d64cc2f0c5d2a4ab96d45b8014ef54ad2