added bitwarden support
This commit is contained in:
parent
0831ed6931
commit
3055ce0516
22
.scripts/bw-unlock
Executable file
22
.scripts/bw-unlock
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
##
|
||||
# Depends: zenity
|
||||
#
|
||||
# Generates bw session key and saves it in tmp file where only current user has permissions
|
||||
#
|
||||
# By Solomon Laing (solomonlaing@pm.me)
|
||||
# Date 2020-03-26
|
||||
##
|
||||
|
||||
password=$(zenity --password)
|
||||
|
||||
session=$(bw unlock "$password" | awk 'NF{last=$NF} END{print last}')
|
||||
|
||||
loc="/tmp/bw-session"
|
||||
|
||||
touch $loc -f
|
||||
|
||||
chmod 600 $loc
|
||||
|
||||
echo "$session" > /tmp/bw-session
|
||||
40
.scripts/passwords
Executable file
40
.scripts/passwords
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
##
|
||||
# Depends bw (bitwarden-cli), bw-unlock (personal script), xclip
|
||||
#
|
||||
# Processes bw to allow for searching of passwords by website (and if multple logins per website, by account).
|
||||
#
|
||||
# By Solomon Laing (solomonlaing@pm.me)
|
||||
# Date 2020-03-26
|
||||
##
|
||||
|
||||
# get bw-session, will only work if owned by current user
|
||||
if ! session=$(cat /tmp/bw-session)
|
||||
then
|
||||
/home/solomon/.scripts/bw-unlock
|
||||
session=$(cat /tmp/bw-session)
|
||||
fi
|
||||
|
||||
items=$(bw list items --session "$session")
|
||||
options=$(echo "$items" | jq ".[].name" | sed 's/"//g')
|
||||
|
||||
entry=$(echo "$options" | dmenu -i -p "Which entry?" $1)
|
||||
|
||||
if ! password=$(bw get password "$entry" --session "$session")
|
||||
then
|
||||
|
||||
user_options=$(bw list items --search "$entry" --session "$session")
|
||||
|
||||
# does not return array, not sure why yet
|
||||
# user_options=$(echo "$items" | jq '.[] | select(.name == "'"$entry"'") | .')
|
||||
|
||||
user=$(echo "$user_options" | jq '.[].login.username' | dmenu -i -p "Which account?" $1 | sed 's/"//g')
|
||||
|
||||
pass=$(echo "$user_options" | jq '.[] | select(.login.username == "'"$user"'") | .login.password' | sed 's/"//g')
|
||||
|
||||
echo "$pass" | xclip -sel clip
|
||||
|
||||
else
|
||||
echo "$password" | xclip -sel clip
|
||||
fi
|
||||
@ -136,10 +136,12 @@ clickable ws = "<action=xdotool key super+"++show i++">"++ws++"</action>"
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Key bindings. Add, modify or remove key bindings here.
|
||||
-- These are general keybindings custom script bindings are not included.
|
||||
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
|
||||
|
||||
[
|
||||
-- launch a terminal
|
||||
[ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
|
||||
((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
|
||||
|
||||
-- launch rofi
|
||||
, ((modm, xK_a ), spawn "rofi -show run")
|
||||
@ -147,15 +149,6 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
|
||||
-- launch dmenu
|
||||
, ((modm, xK_o ), spawn "dmenu_run")
|
||||
|
||||
-- prompt computer shutdown
|
||||
, ((modm .|. shiftMask, xK_s ), spawn "/home/solomon/.scripts/prompt \"Are you sure you want to Shutdown?\" \"shutdown now\"")
|
||||
|
||||
-- prompt computer reboot
|
||||
, ((modm .|. shiftMask, xK_r ), spawn "/home/solomon/.scripts/prompt \"Are you sure you want to Restart?\" \"reboot\"")
|
||||
|
||||
-- prompt computer lock
|
||||
, ((modm .|. shiftMask, xK_l ), spawn "/home/solomon/.scripts/prompt \"Are you sure you want to lock?\" \"slock\"")
|
||||
|
||||
-- launch rofi ssh
|
||||
, ((modm .|. shiftMask, xK_a ), spawn "rofi -show ssh")
|
||||
|
||||
@ -230,6 +223,28 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
|
||||
]
|
||||
++
|
||||
|
||||
--
|
||||
-- these are my general custom bindings and scripts
|
||||
--
|
||||
[
|
||||
-- prompt computer shutdown
|
||||
, ((modm .|. shiftMask, xK_s ), spawn "/home/solomon/.scripts/prompt \"Are you sure you want to Shutdown?\" \"shutdown now\"")
|
||||
|
||||
-- prompt computer reboot
|
||||
, ((modm .|. shiftMask, xK_r ), spawn "/home/solomon/.scripts/prompt \"Are you sure you want to Restart?\" \"reboot\"")
|
||||
|
||||
-- prompt computer lock
|
||||
, ((modm .|. shiftMask, xK_l ), spawn "/home/solomon/.scripts/prompt \"Are you sure you want to lock?\" \"slock\"")
|
||||
|
||||
-- unlock bitwarden cli and store session key
|
||||
, ((modm .|. shiftMask, xK_t ), spawn "/home/solomon/.scripts/bw-unlock")
|
||||
|
||||
-- search for password using bitwarden cli through dmenu
|
||||
, ((modm, xK_t ), spawn "/home/solomon/.scripts/passwords")
|
||||
|
||||
]
|
||||
++
|
||||
|
||||
--
|
||||
-- music controlls as I figure them out
|
||||
--
|
||||
|
||||
Loading…
Reference in New Issue
Block a user