소스 검색

Add picker and music downloader

master
= 3 년 전
부모
커밋
4771f87d66
4개의 변경된 파일58개의 추가작업 그리고 23개의 파일을 삭제
  1. +1
    -1
      README.md
  2. +2
    -2
      dwm-start
  3. +1
    -1
      mru
  4. +54
    -19
      prompt

+ 1
- 1
README.md 파일 보기

@@ -109,5 +109,5 @@ what?- Consider entr in dwm-start for watching files
- unicode character insertion
- finish editing text-opener
change prompt icon to nerd icon
- select window with wmctrl
- finish dwm patching, select window with wmctrl, then setup vpn, then maybe dmenu patches
- prompt for copying files to laptop

+ 2
- 2
dwm-start 파일 보기

@@ -2,8 +2,8 @@
setxkbmap -option caps:swapescape
picom -b
~/.fehbg
xbindkeys -f $HOME/Backups/configs/xbindkeysrc
mru update &
xbindkeys -f $HOME/backups/configs/xbindkeysrc
( mru update; mru updatedirs ) &

# relaunch DWM if the binary changes, otherwise bail
csum=$(sha1sum $(which dwm.winkey))


+ 1
- 1
mru 파일 보기

@@ -26,7 +26,7 @@ create_new() {
path=$(get_cache_path "$1")

find $path -type f -not \( -path '*/.*/*' -o -path '*node_modules/*' -o \
-path '*Backups/my-plugins*' -o -path '*.sw[po]' \) -printf \
-path '*backups/my-plugins*' -o -path '*.sw[po]' \) -printf \
'%TY-%Tm-%Td\t%TT\t%p\n' | sort -r > $file'.new'
}



+ 54
- 19
prompt 파일 보기

@@ -9,6 +9,8 @@ launch() {
Edit
Editor
Open
Pick
Choose
Terminal
Multiplexer
LBRY
@@ -26,11 +28,13 @@ launch() {
dmenu -i -p "Launcher")

case $app in
Notes) st -t "Notes" -e vim "+cd ~/Notes/text" "+CtrlP";;
Notes) st -t "Notes" -e vim "+cd ~/notes/text" "+CtrlP";;
Files) st -t "Files" -e sh -lc nnn;;
Edit) editor;;
Editor) st -t "Editor" -e vim "+CtrlPMRUFiles";;
Open) opener;;
Pick) pick;;
Choose) choose;;
Terminal) st -t "Terminal";;
Page) pages pager "$(printf "1\n2\n3\n" | dmenu -p 'page')";;
Multiplexer) st -t "Multiplexer" -e tmux attach-session -t 0 || st -t "Multiplexer" -e tmux new-session -s 0;;
@@ -42,7 +46,7 @@ launch() {
'Hidden browser') $browser_cmd --incognito;;
Email) $browser_cmd mail.protonmail.com/login;;
'Play clipboard') mpv "$(xclip -o -selection clipboard)";;
'Play downloads') mpv "$HOME/Downloads/tmp/$(ls ~/Downloads/tmp/ | dmenu -i -l 10 -p 'play')";;
'Play downloads') mpv "$HOME/downloads/tmp/$(ls ~/downloads/tmp/ | dmenu -i -l 10 -p 'play')";;
Processes) st -t "Processes" -e htop;;
esac
}
@@ -53,8 +57,6 @@ action() {
Play Music
Command
Command to clipboard
Choose
Choosedir
Select VPN
Disable VPN
Enable VPN
@@ -66,6 +68,8 @@ action() {
Username
Alternate password
Download
Download music
Update cache
Enable Bar" | tr -d '\t' |
dmenu -i -p "Actions")

@@ -77,15 +81,15 @@ action() {
'Disable Bar') tmux set -g status off;;
'Enable Bar') tmux set -g status on;;
'Command') cmd;;
'Choose') chooser;;
'Choosedir') choosedir;;
'Command to clipboard') cmd_clip;;
'Username') username;;
'Password') password;;
'Alternate password') other_password;;
'Show calender') notify-send 'Calender' "\n\n$(cal)";;
'Update cache') { mru update; mru updatedirs; };;
#This should check for an error code and confirm that download has started
'Download') youtube-dl --no-progress -o "$HOME/Downloads/tmp/%(title)s.%(ext)s" "$(xclip -selection clipboard -o)"; notify-send -u low -t 3000 "Download complete";;
'Download') download;;
'Download music') download_music;;
esac
}

@@ -104,6 +108,7 @@ login() {
Show) show_password;;
esac
}

do_search() {
type=$(printf "Manual
DDG
@@ -114,7 +119,7 @@ do_search() {
Github" | tr -d '\t' | dmenu -i -p "Search")
case "$type" in
Manual) p=$(printf '' | dmenu -p 'man'); if [ -z $p ]; then exit; fi; st -t "Manual $p" -e man "$p";;
Manual) p=$(man -k '' | dmenu -l 20 -p 'Manual' | cut -d' ' -f1); if [ -z $p ]; then exit; fi; st -t "Manual - $p" -e man "$p";;
Github) github;;
Godocs) godoc;;
DDG) ddg;;
@@ -123,6 +128,20 @@ do_search() {
esac
}

download() {
youtube-dl --no-progress -o "$HOME/downloads/%(title)s.%(ext)s" "$(xclip -selection clipboard -o)"
notify-send -u low -t 3000 "Download complete"
}
download_music() {
youtube-dl --no-progress -f bestaudio -o \
"$HOME/downloads/music/%(track)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)"
if [ $? ]; then
youtube-dl --no-progress -f bestaudio -o \
"$HOME/downloads/music/%(title)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)"
fi
notify-send -u low -t 3000 "Download complete"

}
package() {
type=$(printf "search\ninfo" | dmenu -p 'package')
if [ -z "$type" ]; then
@@ -326,35 +345,51 @@ edit_password() {
if [ -n "$error" ]; then notify-send -u low -t 3000 "password edit error" "$error"; fi
}

chooser() {
f=$(mru list | dmenu -i -l 20 -p 'choose file')
# Execute a command with the specified file or directory as it's argument
choose() {
d=$(mru listdirs | dmenu -i -l 20 -p 'from')
if [ -z "$d" ]; then exit; fi
f=$(
(printf "$d\n"; find "$d" -type f -not \( -path '*/.*/*' -o -path '*node_modules/*' -o -ipath '*backups/my-plugins*' -o -ipath '*/.uuid' -ipath '*.swp*' \)) |
dmenu -i -l 20 -p 'choose file'
)
if [ -z "$f" ]; then exit; fi
c=$(dmenu_path | dmenu -i -p 'operation')
if [ -z $c ]; then exit; fi
$c "$f"
}

choosedir(){
f=$(mru listdirs | dmenu -i -l 20 -p 'choose dir')
if [ -z "$f" ]; then exit; fi
c=$(dmenu_path | dmenu -i -p 'operation')
if [ -z $c ]; then exit; fi
$c "$f"
}
}

vpn() {
ls
}

# It finds all the current files in a known directory without needing to update the mru list of files
# If the directory is chosen instead of the file within it, it opens the directory with nnn
pick() {
d=$(mru listdirs | dmenu -i -l 20 -p 'from')
if [ -z "$d" ]; then exit; fi
f=$(
(printf "$d\n"; find "$d" -type f -not \( -path '*/.*/*' -o -path '*node_modules/*' -o -ipath '*backups/my-plugins*' -o -ipath '*/.uuid' -ipath '*.swp*' \)) |
dmenu -i -l 20 -p 'pick file'
)
if [ -z "$f" ]; then exit; fi
if [ "$d" = "$f" ]; then st -t 'Files' -e sh -lc "nnn '$f'"; exit; fi
xdg-open "$f"
}

case $1 in
launch ) launch;;
action) action;;
pick) pick;;
cmd) cmd;;
cmd_clip) cmd_clip;;
login) login;;
search) do_search;;
open) opener;;
choose) chooser;;
choose) choose;;
vpn) vpn;;
download) download;;
download_music) download_music;;
*) printf "Invalid argument";;
esac

불러오는 중...
취소
저장