diff options
Diffstat (limited to 'bin/desktop')
-rwxr-xr-x | bin/desktop/password-store.sh | 51 | ||||
-rwxr-xr-x | bin/desktop/takeshot | 78 |
2 files changed, 129 insertions, 0 deletions
diff --git a/bin/desktop/password-store.sh b/bin/desktop/password-store.sh new file mode 100755 index 0000000..1de3148 --- /dev/null +++ b/bin/desktop/password-store.sh | |||
@@ -0,0 +1,51 @@ | |||
1 | #! /bin/bash | ||
2 | |||
3 | # Use rofi to quickly access password by command 'pass' | ||
4 | # xsel needed !! | ||
5 | |||
6 | ROFI_ARGS=( "-font" "Hack 22" ) | ||
7 | |||
8 | find ~/.password-store -name '*gpg' -printf %P\\n | \ | ||
9 | sed 's/.gpg$//' | \ | ||
10 | rofi -dmenu "${ROFI_ARGS[@]}" | { | ||
11 | # Get arguments for command 'pass' | ||
12 | read ARG1 ARG2 | ||
13 | |||
14 | if [[ -z $ARG1 ]]; then | ||
15 | exit 1 | ||
16 | elif [[ $ARG1 == edit ]]; then | ||
17 | # Edit an existing password | ||
18 | alacritty --hold -e pass edit $ARG2 && \ | ||
19 | rofi -e Password Edited: $ARG2 | ||
20 | else | ||
21 | # If pass fails, then it means password doesn't exists | ||
22 | set pipefail | ||
23 | |||
24 | pass $ARG1 | { | ||
25 | # If command fails, just fail directly | ||
26 | read PASSWORD; [[ -z $PASSWORD ]] && exit 1 | ||
27 | |||
28 | # Simply copy password into system clipboard | ||
29 | echo $PASSWORD | xsel -ib | ||
30 | |||
31 | # Show success message, and display extra contents | ||
32 | rofi "${ROFI_ARGS[@]}" \ | ||
33 | -e "Copied: $ARG1 $(echo; echo; cat | sed '1{/^$/d}')" | ||
34 | } || { | ||
35 | # Make sure user want to create a new password | ||
36 | return_code=$(alacritty -e sh -c ' | ||
37 | dialog --yesno "Password does not exist, Generate a new one?" 8 30; | ||
38 | echo "$?" | ||
39 | ') | ||
40 | [[ $return_code == 1 ]] && exit 1 | ||
41 | |||
42 | # Generate a new password by ARG1 | ||
43 | alacritty -e pass generate $ARG1 --clip && \ | ||
44 | |||
45 | # Show success message | ||
46 | rofi "${ROFI_ARGS[@]}" -e "Password Created and Copied: $ARG1" | ||
47 | } | ||
48 | |||
49 | # TODO: if return code is 2, it means gpg password is not cached | ||
50 | fi | ||
51 | } | ||
diff --git a/bin/desktop/takeshot b/bin/desktop/takeshot new file mode 100755 index 0000000..09252f3 --- /dev/null +++ b/bin/desktop/takeshot | |||
@@ -0,0 +1,78 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | ## Copyright (C) 2020-2022 Aditya Shakya <adi1090x@gmail.com> | ||
4 | ## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 | ||
5 | |||
6 | ## Script to take screenshots with maim | ||
7 | |||
8 | time=`date +%Y-%m-%d-%H-%M-%S` | ||
9 | geometry=`xrandr | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current'` | ||
10 | dir="`xdg-user-dir PICTURES`" | ||
11 | file="Screenshot_${time}_${geometry}.png" | ||
12 | |||
13 | # notify and view screenshot | ||
14 | notify_view () { | ||
15 | dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Copied to clipboard." | ||
16 | viewnior ${dir}/"$file" | ||
17 | if [[ -e "$dir/$file" ]]; then | ||
18 | dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Screenshot Saved." | ||
19 | else | ||
20 | dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Screenshot Deleted." | ||
21 | fi | ||
22 | } | ||
23 | |||
24 | # countdown | ||
25 | countdown () { | ||
26 | for sec in `seq $1 -1 1`; do | ||
27 | dunstify -t 1000 --replace=699 -i /usr/share/archcraft/icons/dunst/timer.png "Taking shot in : $sec" | ||
28 | sleep 1 | ||
29 | done | ||
30 | } | ||
31 | |||
32 | # take shots | ||
33 | shotnow () { | ||
34 | cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png | ||
35 | notify_view | ||
36 | } | ||
37 | |||
38 | shot5 () { | ||
39 | countdown '5' | ||
40 | sleep 1 && cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png | ||
41 | notify_view | ||
42 | } | ||
43 | |||
44 | shot10 () { | ||
45 | countdown '10' | ||
46 | sleep 1 && cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png | ||
47 | notify_view | ||
48 | } | ||
49 | |||
50 | shotwin () { | ||
51 | cd ${dir} && maim -u -f png -i `xdotool getactivewindow` | tee "$file" | xclip -selection clipboard -t image/png | ||
52 | notify_view | ||
53 | } | ||
54 | |||
55 | shotarea () { | ||
56 | cd ${dir} && maim -u -f png -s -b 2 -c 0.35,0.55,0.855 | tee "$file" | xclip -selection clipboard -t image/png | ||
57 | notify_view | ||
58 | } | ||
59 | |||
60 | if [[ ! -d "$dir" ]]; then | ||
61 | mkdir -p "$dir" | ||
62 | fi | ||
63 | |||
64 | if [[ "$1" == "--now" ]]; then | ||
65 | shotnow | ||
66 | elif [[ "$1" == "--in5" ]]; then | ||
67 | shot5 | ||
68 | elif [[ "$1" == "--in10" ]]; then | ||
69 | shot10 | ||
70 | elif [[ "$1" == "--win" ]]; then | ||
71 | shotwin | ||
72 | elif [[ "$1" == "--area" ]]; then | ||
73 | shotarea | ||
74 | else | ||
75 | echo -e "Available Options : --now --in5 --in10 --win --area" | ||
76 | fi | ||
77 | |||
78 | exit 0 | ||