Browse Source

Remove unnecessary scripts and variables

Prompt was modified to be more readable and modifieable, more edits are
still required to make dmenu, st, and notify-send executions
configurable. Config and macro directories are being moved to Source
because I now see the many annoyances caused by having using user
specific bin directories. The configure script is what will be used
going formward to manage configurations and builds.
master
Immanuel Onyeka 2 years ago
parent
commit
4151f23339
9 changed files with 196 additions and 279 deletions
  1. +0
    -68
      backup
  2. +0
    -63
      bar.sh
  3. +59
    -0
      configure
  4. +0
    -14
      create
  5. +2
    -2
      dwm-start
  6. +135
    -30
      prompt
  7. +0
    -3
      store
  8. +0
    -96
      util
  9. +0
    -3
      vpn

+ 0
- 68
backup View File

@@ -1,68 +0,0 @@
#!/bin/sh

configs='cmus
ckb-next
compton
mpv
openbox
nnn
liferea
lutris
ranger
tmux
xkb
.bashrc
.profile
xfiles'

paths="$HOME/Documents $HOME/Notes $HOME/Pictures $HOME/Projects $HOME/Source"

BU="$HOME/Backups"

conf() {
configs=$(echo $configs | tr '\n' ' ')
for dir in $configs
do
rsync -av --progress --exclude '*.git/' $HOME/.config/$dir $BU/config/
done
}

mac() {
macros="$HOME/Macros/*"
rsync -av --progress --exclude '*.git/ *.swp$ *.swo$' $macros $BU/macros
}

global_vim() {
rcs=/etc/vim/*
packs=/usr/share/vim??/*
macros=$HOME/Macros/*
for dir in $macros
do
echo $dir
rsync -av --progress --exclude '*.git/' $HOME/.config/$dir $BU/config/global_vim/
done
}

notes() {
rcs=/etc/vim/*
packs=/usr/share/vim??/*
macros=$HOME/Macros/*
for dir in $macros
do
echo $dir
rsync -av --progress --exclude '*.git/' $HOME/.config/$dir $BU/config/global_vim/
done
}

archive() {
destination=$BU/archives/$(date +%F)-$(openssl rand -base64 6)
tar -g $BU/archives/tar.info -cvf $destination $paths
}

case "$1" in
configs) conf;;
macros) mac;;
globalvim) global_vim;;
notes) notes;;
archive) archive;;
esac

+ 0
- 63
bar.sh View File

@@ -1,63 +0,0 @@
#!/bin/sh

font=;

clock() {
date '+%H:%M %d-%m-%y'
}

# get the battery capacity and status
battery() {
BATC=/sys/class/power_supply/BAT0/capacity
BATS=/sys/class/power_supply/BAT0/status

# prepend percentage with a '+' if charging, '-' otherwise
test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
echo $BATC
}

volume() {
# get master volume level from amixer

# parse amixer output to get ONLY the level. Will output "84%"
# we need `uniq` because on some hardware, The master is listed twice in
# "Front Left" and Front Right" (because laptop speakers I guess)
amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p'| uniq
}

network() {
infs=$(ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p')
lo=$(echo $infs | awk '{print $1}')
int1=$(echo $infs | awk '{print $2}')
int2=$(echo $infs | awk '{print $3}')

#iwconfig returns an error code if the interface tested has no wireless extensions
if iwconfig $int1 >/dev/null 2>&1; then
wifi=$int1
eth0=$int2
else
wifi=$int2
eth0=$int1
fi

ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 || int=$wifi
printf $int
ping -c1 -s1 8.8.8.8 >/dev/null 2>&1 && echo "connected" || echo "disconnected"

}

# get cpu load (TODO- get this using iostat)


# get ram usage
memused() {
# store the total and free memory in two variables
t=$(grep -E 'MemTotal' /proc/meminfo |awk '{print $2}')
f=$(grep -E 'MemFree' /proc/meminfo |awk '{print $2}')
b=$(grep -E '^(Buffers)' /proc/meminfo |awk '{print $2}')
c=$(grep -E '^(Cached)' /proc/meminfo |awk '{print $2}')

# then, calcultate the percentage of memory used
bc | "100($t -$f -$c -$b) / $t"
}


+ 59
- 0
configure View File

@@ -0,0 +1,59 @@
#!/bin/sh

# A file used to automaticaly copy configs and macros to their appropriate
# location

CONFIGS=~/Source/configs
MACROS=~/Source/macros

# Copy a script over to /usr/local/bin and make it executable. Accepts the full
# path of a file
copy() {
if [ ! -e $1 ]; then return 1; fi
sudo cp $1 /usr/local/bin/
sudo chmod a+x /usr/local/bin/$(basename $1)
printf "Copied and made executable: %s\n" $(basename $1)
}

# Exclude files with extensions like .c or .sh that are not executable or
# are incomplete and copy them over
macros() {
for f in $(find ~/Source/macros -maxdepth 1 -type f -not -name '*.*')
do
copy "$f"
done
}

# Rebuilds selected custom applications
builds() {
for f in ~/Source/enabled/*
do
cd $f
git -C $f pull
sudo make clean install
done
}

vim() {
sudo cp ~/Source/configs/vimrc.local /etc/vim/vimrc.local
# Should copy plugins too
}

bash() {
cp $CONFIGS/.bashrc ~/.bashrc
cp $CONFIGS/.profile ~/.profile
}

# Used to configure a new system or reset things for an existing one.
all() {
ls
}

case $1 in
configure) copy $MACROS/configure;;
builds) builds;;
vim) vim;;
macros) macros;;
bash) bash;;
*) printf "Invalid argument";;
esac

+ 0
- 14
create View File

@@ -1,14 +0,0 @@
#!/bin/sh

password() {
tr -d '\n' < /dev/urandom | fold -w30 | head -n1
}

password_easy() {
tr -cd '[:alnum:]' < /dev/urandom | fold -w20 | head -n1
}

case $1 in
password) password;;
*) printf "Invalid argument";;
esac

+ 2
- 2
dwm-start View File

@@ -3,8 +3,8 @@ setxkbmap -option ctrl:swapcaps -option tilde:swapescape
source ~/.profile source ~/.profile
picom -b picom -b
~/.fehbg ~/.fehbg
xbindkeys -f $HOME/backups/configs/xbindkeysrc
protonmail-bridge --no-window --noninteractive &
xbindkeys -f $HOME/Source/configs/xbindkeysrc
( mru update; mru updatedirs ) & ( mru update; mru updatedirs ) &


# relaunch DWM if the binary changes, otherwise bail # relaunch DWM if the binary changes, otherwise bail


+ 135
- 30
prompt View File

@@ -3,6 +3,29 @@
browser_cmd="brave-browser" browser_cmd="brave-browser"
browser_new_cmd="brave-browser --new-window" browser_new_cmd="brave-browser --new-window"


# First argument is the directory picking message
ask_dir() {
d=$(mru listdirs | dmenu -i -c -l 20 -p "$1")
if [ -z "$d" ]; then exit; fi

printf "$d"
}

# First argument is the file picking message
ask_file() {
d=$(ask_dir "from")

if [ -z "$d" ]; then exit; fi

f=$(
find "$d" -maxdepth 4 \( -path '*/.*/*' -o -name 'node_modules'\
-o -name '*.uuid' -o -name 'vendor' -o -regex '.*sw[op]$' \) -prune -o -print |
dmenu -i -c -l 20 -p "$1"
)

printf "$f"
}

launch() { launch() {
app=$(printf "Notes app=$(printf "Notes
Files Files
@@ -26,6 +49,7 @@ launch() {
Package info Package info
Images Images
Games Games
Movie
Play clipboard Play clipboard
Play downloads Play downloads
Processes Processes
@@ -33,7 +57,7 @@ launch() {
dmenu -i -c -l 20 -p "Launcher") dmenu -i -c -l 20 -p "Launcher")


case $app in case $app in
Notes) st -t "Notes" -e vim "+cd ~/notes/text" "+CtrlP";;
Notes) st -t "Notes" -e vim "+cd ~/Notes" "+CtrlP";;
Files) st -t "Files" -e sh -lc nnn;; Files) st -t "Files" -e sh -lc nnn;;
Edit) editor;; Edit) editor;;
Editor) st -t "Editor" -e vim "+CtrlPMRUFiles";; Editor) st -t "Editor" -e vim "+CtrlPMRUFiles";;
@@ -45,7 +69,10 @@ launch() {
Tasks) st -t "Tasks" -e sh -lc taskwarrior-tui;; Tasks) st -t "Tasks" -e sh -lc taskwarrior-tui;;
Page) pages pager "$(printf "1\n2\n3\n" | dmenu -p 'page')";; Page) pages pager "$(printf "1\n2\n3\n" | dmenu -p 'page')";;
Games) games;; Games) games;;
Multiplexer) st -t "Multiplexer" -e tmux attach-session -t 0 || st -t "Multiplexer" -e tmux new-session -s 0;;
Movie) mpv $(find /mnt/media/movies -name '*.m*' -type f -not -path '*.x/*' |
dmenu -i -c -l 20 -p 'Play');;
Multiplexer) st -t "Multiplexer" -e tmux attach-session -t 0 ||
st -t "Multiplexer" -e tmux new-session -s 0;;
'Go page') num=$(go_page); pages pager $num;; 'Go page') num=$(go_page); pages pager $num;;
Chat) element-desktop;; Chat) element-desktop;;
Music) st -t "Music" -e ncmpcpp;; Music) st -t "Music" -e ncmpcpp;;
@@ -54,7 +81,8 @@ launch() {
Email) st -t 'Email' -e sh -lc neomutt;; Email) st -t 'Email' -e sh -lc neomutt;;
Images) view_images;; Images) view_images;;
'Play clipboard') mpv "$(xclip -o -selection clipboard)";; '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')";;
'Mixer') st -t "Mixer" -e pulsemixer;; 'Mixer') st -t "Mixer" -e pulsemixer;;
'Equalizer') qpaeq;; 'Equalizer') qpaeq;;
Processes) st -t "Processes" -e top;; Processes) st -t "Processes" -e top;;
@@ -82,6 +110,9 @@ action() {
Select song Select song
Download Download
Download music Download music
Torrent
Configure
Move
Update cache Update cache
Enable Bar Enable Bar
Exit" | tr -d '\t' | Exit" | tr -d '\t' |
@@ -108,6 +139,9 @@ action() {
#This should check for an error code and confirm that download has started #This should check for an error code and confirm that download has started
'Download') download;; 'Download') download;;
'Download music') download_music;; 'Download music') download_music;;
'Torrent') torrent;;
'Configure') configure;;
'Move') move;;
esac esac
} }


@@ -137,44 +171,54 @@ do_search() {
Github" | tr -d '\t' | dmenu -i -c -p "Search") Github" | tr -d '\t' | dmenu -i -c -p "Search")
case "$type" in case "$type" in
Manual) p=$(man -k '' | dmenu -i -c -l 20 -p 'Manual' | cut -d' ' -f1); if [ -z $p ]; then exit; fi; st -t "Manual - $p" -e man "$p";;
Manual) p=$(man -k '' | dmenu -i -c -l 20 -p 'Manual' | cut -d' ' -f1);
if [ -z $p ]; then exit; fi; st -t "Manual - $p" -e man "$p";;
Github) github;; Github) github;;
Godocs) godoc;; Godocs) godoc;;
DDG) ddg;; DDG) ddg;;
Package) package;; Package) package;;
Definition) word=$(printf '' | dmenu -p 'word'); if [ -z "$word" ]; then exit; fi; st -e sh -lc "dict \"$word\" | less";;
Definition) word=$(printf '' | dmenu -p 'word');
if [ -z "$word" ]; then exit; fi;
st -e sh -lc "dict \"$word\" | less";;
esac esac
} }


download() { download() {
youtube-dl --add-metadata --no-progress -o "$HOME/downloads/%(title)s.%(ext)s" "$(xclip -selection clipboard -o)"
youtube-dl --add-metadata --no-progress -o \
"$HOME/Downloads/%(title)s.%(ext)s" "$(xclip -selection clipboard -o)"
notify-send -u low -t 3000 "Download complete" notify-send -u low -t 3000 "Download complete"
} }


download_music() { download_music() {
youtube-dl -x --add-metadata --no-progress --audio-format mp3 -o \ youtube-dl -x --add-metadata --no-progress --audio-format mp3 -o \
"$HOME/music/new/%(track)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)" "$HOME/music/new/%(track)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)"

if [ ! $? ]; then if [ ! $? ]; then
youtube-dl -x --add-metadata --no-progress --audio-format mp3 -o \ youtube-dl -x --add-metadata --no-progress --audio-format mp3 -o \
"$HOME/music/new/%(title)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)" "$HOME/music/new/%(title)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)"
fi fi

if [ -e "$HOME/music/new/NA - NA"* ]; then if [ -e "$HOME/music/new/NA - NA"* ]; then
rm "$HOME/music/new/NA - NA"* rm "$HOME/music/new/NA - NA"*
youtube-dl -x --add-metadata --no-progress --audio-format mp3 -o \ youtube-dl -x --add-metadata --no-progress --audio-format mp3 -o \
"$HOME/music/new/%(title)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)"
"$HOME/music/new/%(title)s - %(artist)s.%(ext)s" \
"$(xclip -selection clipboard -o)"
fi fi
notify-send -u low -t 3000 "Download complete"


notify-send -u low -t 3000 "Download complete"
} }


view_images() { view_images() {
d=$(mru listdirs | dmenu -c -l 20 -i -p 'where?') d=$(mru listdirs | dmenu -c -l 20 -i -p 'where?')

if [ -z "$d" ]; then exit; fi if [ -z "$d" ]; then exit; fi

sxiv -r "$d" sxiv -r "$d"
} }


package() { package() {
type=$(printf "search\ninfo" | dmenu -c -p 'package') type=$(printf "search\ninfo" | dmenu -c -p 'package')

if [ -z "$type" ]; then if [ -z "$type" ]; then
exit exit
elif [ "$type" = "info" ]; then elif [ "$type" = "info" ]; then
@@ -189,37 +233,45 @@ package() {
editor() { editor() {
#handle spacing in filenames bug #handle spacing in filenames bug
file=$(mru list | dmenu -i -c -l 20 -p 'edit file') file=$(mru list | dmenu -i -c -l 20 -p 'edit file')

if [ -z "$file" ]; then exit; fi if [ -z "$file" ]; then exit; fi

first=$(printf "$file" | head -n1 -) first=$(printf "$file" | head -n1 -)
d=$(dirname "$first") d=$(dirname "$first")
files=$(printf "$file" | tr '\n' ' ') files=$(printf "$file" | tr '\n' ' ')

printf "files: $files" printf "files: $files"
st -t 'Editor' -e vim "+cd $d" $files st -t 'Editor' -e vim "+cd $d" $files
} }


opener() { opener() {
mru list | dmenu -i -c -l 20 -p 'open' | while read f; do xdg-open "$f"; done
mru list | dmenu -i -c -l 20 -p 'open' |
while read f; do xdg-open "$f"; done
} }


screenshot() { screenshot() {
method=$(printf "clipboard
method=$(
printf "clipboard
file file
both" | both" |
dmenu -i -p "Screenshot") dmenu -i -p "Screenshot")


if [ $method = "file" ]; then if [ $method = "file" ]; then
scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c
255,0,0,255 -t 'Hi'"\
-s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png
fi fi


if [ $method = "clipboard" ]; then if [ $method = "clipboard" ]; then
scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c
255,0,0,255 -t 'Hi'"\
-s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\ -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\
-e "xclip $f; rm $f" -e "xclip $f; rm $f"
fi fi


if [ $method = "both" ]; then if [ $method = "both" ]; then
scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c
255,0,0,255 -t 'Hi'"\
-s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\ -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\
-e "xclip $f;" -e "xclip $f;"
fi fi
@@ -230,7 +282,8 @@ search_type() {
search_mode='tab' search_mode='tab'


case "$search_string" in case "$search_string" in
'New window') search_mode='window'; search_string=$(printf '' | dmenu -c -p "new $1");;
'New window') search_mode='window';
search_string=$(printf '' | dmenu -c -p "new $1");;
'Bookmarks');; 'Bookmarks');;
'History') ;; 'History') ;;
# *) printf "Invalid argument";; # *) printf "Invalid argument";;
@@ -293,11 +346,17 @@ manual() {
goinfo() { goinfo() {
#Maybe this can also show recent searches #Maybe this can also show recent searches
search=$(printf "Window\nNotify" | dmenu -p 'goinfo') search=$(printf "Window\nNotify" | dmenu -p 'goinfo')

case $search in case $search in
Window) search=$(printf '' | dmenu -p 'goinfo'); result=$(go doc "$search"); infowindow "$result"; exit;;
Notify) search=$(printf '' | dmenu -p 'goinfo'); result=$(go doc "$search"); notify-send -u low -t 0 "Go documentation" "$result"; exit;;
Window) search=$(printf '' | dmenu -p 'goinfo');
result=$(go doc "$search"); infowindow "$result"; exit;;
Notify) search=$(printf '' | dmenu -p 'goinfo');
result=$(go doc "$search");
notify-send -u low -t 0 "Go documentation" "$result"; exit;;
esac esac
result=$(go doc "$search"); notify-send -u low -t 0 "Go documentation" "$result";

result=$(go doc "$search");
notify-send -u low -t 0 "Go documentation" "$result";
} }


go_page() { go_page() {
@@ -320,6 +379,7 @@ cmd() {
cmd_clip() { cmd_clip() {
value=$(cmd) value=$(cmd)
show_value="$(expr substr "$value" 1 200)\n..." show_value="$(expr substr "$value" 1 200)\n..."

notify-send -u low -t 2000 "Items cliped" "$show_value" notify-send -u low -t 2000 "Items cliped" "$show_value"
printf "%s" "$value" | xclip -selection clipboard printf "%s" "$value" | xclip -selection clipboard
} }
@@ -330,28 +390,31 @@ sel_account() {
sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" | sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" |
dmenu -c -i -l 20 -p 'account' dmenu -c -i -l 20 -p 'account'
) )

if [ -z "$account" ]; then exit; fi if [ -z "$account" ]; then exit; fi

printf "$account" printf "$account"
} }


username() { username() {
account=$(sel_account) account=$(sel_account)

if [ -z "$account" ]; then exit; fi if [ -z "$account" ]; then exit; fi

name=$(pass show "$account" | sed -n -e "s/^username: //p" | name=$(pass show "$account" | sed -n -e "s/^username: //p" |
dmenu -c -i -l 20 -p 'which username' | xclip -f -selection clipboard) dmenu -c -i -l 20 -p 'which username' | xclip -f -selection clipboard)

if [ -z "$name" ]; then exit; fi if [ -z "$name" ]; then exit; fi

notify-send -u low -t 2000 "username copied" "$account: $name" notify-send -u low -t 2000 "username copied" "$account: $name"
} }


password() { password() {
rm prompt-login-*
touch /tmp/prompt-login-$$
account=$(find ~/.password-store/[!\.]* -type f | account=$(find ~/.password-store/[!\.]* -type f |
sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" | sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" |
dmenu -i -c -l 20 -p 'which service') dmenu -i -c -l 20 -p 'which service')
pass -c $account pass -c $account
notify-send -u low -t 1000 'password copied' "Copied $account" notify-send -u low -t 1000 'password copied' "Copied $account"

} }


# Giving multiple accounts for the same service the same username may cause problems. # Giving multiple accounts for the same service the same username may cause problems.
@@ -361,12 +424,17 @@ other_password() {
account=$(sel_account) account=$(sel_account)
name=$(pass show "$account" | sed -n -e "s/^username: //p" | name=$(pass show "$account" | sed -n -e "s/^username: //p" |
dmenu -i -c -l 20 -p 'which user password') dmenu -i -c -l 20 -p 'which user password')

if [ -z "$name" ]; then exit; fi if [ -z "$name" ]; then exit; fi

copy=$(pass show $account | grep -B 1 "^username: $name" | head -n1 | tr -d '\n') copy=$(pass show $account | grep -B 1 "^username: $name" | head -n1 | tr -d '\n')

printf "$copy" | xclip -selection clipboard printf "$copy" | xclip -selection clipboard
notify-send -u low -t 2000 "password copied" "$account: $name" notify-send -u low -t 2000 "password copied" "$account: $name"
sleep 30s sleep 30s

new_copy=$(xclip -o -selection clipboard) new_copy=$(xclip -o -selection clipboard)

if [ "$copy" = $newcopy ]; then if [ "$copy" = $newcopy ]; then
printf '' | xclip -selection clipboard printf '' | xclip -selection clipboard
fi fi
@@ -375,33 +443,39 @@ other_password() {
show_password() { show_password() {
account=$(sel_account) account=$(sel_account)
info=$(pass show "$account") info=$(pass show "$account")

st -e sh -lc "printf '$info' | less" st -e sh -lc "printf '$info' | less"
} }


edit_password() { edit_password() {
account=$(sel_account) account=$(sel_account)
if [ -z "$account" ]; then exit; fi
error=$(st -e pass edit "$account" 2>&1)
if [ -n "$error" ]; then notify-send -u low -t 3000 "password edit error" "$error"; fi
}

if [ -z "$account" ]; then exit; fi
error=$(st -e pass edit "$account" 2>&1)

if [ -n "$error" ];
then notify-send -u low -t 3000 "password edit error" "$error"; fi
}


# Execute a command with the specified file or directory as it's argument # Execute a command with the specified file or directory as it's argument
choose() { choose() {
d=$(mru listdirs | dmenu -i -c -l 20 -p 'from') d=$(mru listdirs | dmenu -i -c -l 20 -p 'from')

if [ -z "$d" ]; then exit; fi if [ -z "$d" ]; then exit; fi

f=$( 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 -c -l 20 -p 'choose file'
(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 -c -l 20 -p 'choose file'
) )

if [ -z "$f" ]; then exit; fi if [ -z "$f" ]; then exit; fi


c=$(dmenu_path | dmenu -i -c -p 'operation') c=$(dmenu_path | dmenu -i -c -p 'operation')

if [ -z $c ]; then exit; fi if [ -z $c ]; then exit; fi
$c "$f"
}


vpn() {
ls
$c "$f"
} }


# It finds all the current files in a known directory without needing to update the mru list of files # It finds all the current files in a known directory without needing to update the mru list of files
@@ -466,6 +540,37 @@ bookmarks() {
esac esac
} }


torrent() {
sel=$(printf "List
Add
Delete
Edit" | tr -d "\t" | dmenu -i -c -p 'Bookmarks')

case "$sel" in
'Add') btcli add -T -d /mnt/media/torrents/ \
"$(
find ~/Downloads -name '*.torrent' |
dmenu -i -c -l 30 -p "Select torrent"
)";;
'List');; # Already lists as final output
esac

notify-send -u low -t 6000 "Torrents" "$(btcli list)"

}


move() {
f=$(ask_file "Choose file")
dest=$(ask_dir "Destination")
notify-send -u low -t 6000 "Move" "$(mv $f $dest)"
}

# Should be used for automatically selecting and copying files in
# ~/Source/configs to their correct path
# configure() {
# }

case $1 in case $1 in
launch ) launch;; launch ) launch;;
action) action;; action) action;;


+ 0
- 3
store View File

@@ -1,3 +0,0 @@
#!/bin/sh

#For downloading bookmarks in a directory

+ 0
- 96
util View File

@@ -1,96 +0,0 @@
#!/bin/sh
#A file for managing git tar/git backups
gitcmd() {
#First arg should be the name of the subdirectory, second arg should be command
check_args $# 2
if [ ! -d "$BACKUPS_PATH/$1" ]; then
invalid_path_msg "$1"
return 1;
fi

git -C $BACKUPS_PATH/$1 $2
printf "The command succeded\n"
}

git_clone_backup() {
check_args $# 2
git -C $BACKUPS_PATH clone $1:Backups/$2
}

git_clone_proj() {
check_args $# 2
git -C $HOME/Projects clone ssh://$1/~/Projects/$2
}

bdiff() {
check_args $# 2
if [ ! -d "$BACKUPS_PATH/$1" ]; then
invalid_path_msg "$1"
return 1;
fi
case "$1" in
configs) vimdiff "$BACKUPS_PATH/$1/$2" "$XDG_CONFIG_HOME/$2";;
macros) vimdiff "$BACKUPS_PATH/$1/$2" "$HOME/Macros/$2";;
global_vim) vimdiff "$BACKUPS_PATH/$1/$2" "/usr/share/vim/$2";;
*) invalid_path_msg "$1"; return 1;;
esac
}

overwrite_local() {
if [ ! -e $BACKUPS_PATH/$1/$2 ]; then
printf "The backup path $BACKUPS_PATH/$1/$2 does not exist\n"
return 1;
fi
case "$1" in
configs) cp -r $BACKUPS_PATH/$1/$2 "$XDG_CONFIG_HOME/";;
macros) cp -r $BACKUPS_PATH/$1/$2 "$HOME/Macros/";;
*) invalid_path_msg "$1"; return 1;;
esac
printf "local overwrite successful\n"
}

overwrite_lmacros() {
overwrite_local macros '*'
}

overwrite_backup() {
if [ git diff --stat $BACKUPS_PATH/$1 ]; then
printf "There are uncommited changes in $1\n"
return 1
fi
case "$1" in
config) cp -r $XDG_CONFIG_HOME/$2 "$BACKUPS_PATH/$1/$2";;
macros) cp -r $HOME/Macros/$2 "$BACKUPS_PATH/$1/$2";;
*) invalid_path_msg "$1"; return 1;;
esac
printf "backup overwrite successful\n"
}

invalid_path_msg() {
printf "That path is invalid. $@\n"
}

check_args() {
if [ $1 -ne $2 ]; then
printf "Invalid number of arguments. Expected $2\n"
exit;
fi
return 0;
}

case "$1" in
pull-backup)
case "$2" in
configs) pull_backup configs;;
macros) pull_backup macros;;
esac
;;
overwrite-local) overwrite_local $2 $3;;
overwrite-backup) overwrite_backup $2 $3;;
gitcmd) gitcmd "$2" "$3";;
push-backup) overwrite_backup $2 $3;;
bclone) git_clone_backup "$2" "$3";;
pclone) git_clone_proj "$2" "$3";;
bdiff) bdiff $2 "$3";;
*) printf "No such option\n";;
esac

+ 0
- 3
vpn View File

@@ -1,3 +0,0 @@
#!/bin/sh



Loading…
Cancel
Save