Skip to content

Commit

Permalink
Add script for clipboard and encfs mounting
Browse files Browse the repository at this point in the history
  • Loading branch information
selevt committed Oct 13, 2014
1 parent e0b7754 commit 787ecf6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/clipboard
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
42 changes: 42 additions & 0 deletions scripts/encfsmount.sh
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

0 comments on commit 787ecf6

Please sign in to comment.