-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script for clipboard and encfs mounting
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# SOURCE: https://github.com/milianw/shell-helpers/blob/master/clipboard | ||
|
||
# Access your KDE 4 klipper on the command line | ||
# usage: | ||
# ./clipboard | ||
# will output current contents of klipper | ||
# echo "foobar" | ./clipboard | ||
# will put "foobar" into your clipboard/klipper | ||
|
||
|
||
# check for stdin | ||
if ! test -t 0; then | ||
# oh, nice - user input! we set that as current clipboard content | ||
qdbus-qt4 org.kde.klipper /klipper setClipboardContents "$(</dev/stdin)" > /dev/null | ||
exit | ||
fi | ||
|
||
# if we reach this point no user input was given and we | ||
# print out the current contents of the clipboard | ||
qdbus-qt4 org.kde.klipper /klipper getClipboardContents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# This script mounts a encfs with the password being retrieved from KWallet. | ||
# If the password is not yet present in KWallet it will be prompted the first | ||
# time the script is executed. | ||
|
||
APP_NAME="encfs mounting" | ||
PWD_FOLDER="Passwords" | ||
PWD_KEY="encfs.dropbox" | ||
|
||
# Folder in which the encrypted files are stored | ||
ENC_DIR=~/Dropbox/crypt | ||
# Folder to be mounted with the decrypted files | ||
DEC_DIR=~/Hive | ||
|
||
|
||
# Default Wallet can also be retrieved with: | ||
# kreadconfig --file kwalletrc --group Wallet --key "Default Wallet" | ||
wallet=$(qdbus org.kde.kwalletd /modules/kwalletd org.kde.KWallet.localWallet) | ||
handle=$(qdbus org.kde.kwalletd /modules/kwalletd org.kde.KWallet.open "$wallet" 0 "$APP_NAME") | ||
|
||
if [ $handle -lt 0 ]; then | ||
kdialog --error "Wallet could not be opened" | ||
exit 3 | ||
fi | ||
|
||
hasKey=$(qdbus org.kde.kwalletd /modules/kwalletd org.kde.KWallet.hasEntry "$handle" "$PWD_FOLDER" "$PWD_KEY" "$APP_NAME") | ||
|
||
if ! $hasKey; then | ||
pwd=$(kdialog --password "Password for $PWD_KEY") | ||
qdbus org.kde.kwalletd /modules/kwalletd org.kde.KWallet.writePassword "$handle" "$PWD_FOLDER" "$PWD_KEY" "$pwd" "$APP_NAME" | ||
else | ||
pwd=$(qdbus org.kde.kwalletd /modules/kwalletd org.kde.KWallet.readPassword "$handle" "$PWD_FOLDER" "$PWD_KEY" "$APP_NAME") | ||
fi | ||
|
||
mntmsg=$(echo $pwd | encfs -S "$ENC_DIR" "$DEC_DIR" 2>&1) | ||
mntres=$? | ||
|
||
if [ $mntres -ne 0 ]; then | ||
kdialog --error "$mntmsg" | ||
exit 4 | ||
fi |