Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
maevius669 authored Dec 5, 2023
1 parent 88b99c8 commit c746130
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
14 changes: 14 additions & 0 deletions age-decrypt.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Desktop Entry]
Actions=DecryptAGE
Type=Service
Icon=preferences-security
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/age
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=true
X-KDE-Submenu=AGE Encryption

[Desktop Action DecryptAGE]
Name=Decrypt
Icon=preferences-security
Exec=age -d -i ~/.age-key/"$(whoami)".age-key %f > %f.tmp && rename 's/(.*).{8}/$1/' *.age.tmp
19 changes: 19 additions & 0 deletions age-encrypt.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Desktop Entry]
Actions=tarEncryptAGE;EncryptAGE
Type=Service
Icon=preferences-security
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/all
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=true
X-KDE-Submenu=AGE Encryption

[Desktop Action tarEncryptAGE]
Name=Compress & Encrypt
Icon=preferences-security
Exec=tar -pzcf "%f.tar.gz" %f && age -R ~/.age-key/"$(whoami)" "%f.tar.gz" > "%f.tar.gz.age" && rm -f "%f.tar.gz"

[Desktop Action EncryptAGE]
Name=Encrypt
Icon=preferences-security
Exec=age -R ~/.age-key/"$(whoami)" %f > "%f.age"
9 changes: 9 additions & 0 deletions age-mime.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/age">
<comment>AGE Encrypted File</comment>
<icon name="encrypted"/>
<glob-deleteall/>
<glob pattern="*.age"/>
</mime-type>
</mime-info>
43 changes: 43 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

check() {
command -v $1 &> /dev/null
}

# Check if Curl is installed
if ! check "curl"; then
echo "Installing Curl.."
if command -v apt &> /dev/null; then
sudo apt update && sudo apt install -y curl
elif command -v pacman &> /dev/null; then
sudo pacman -Sy --noconfirm curl
elif command -v yum &> /dev/null || command -v dnf &> /dev/null; then
sudo yum -y install curl
else
echo "System not supported. Install curl manually."
exit 1
fi
fi

# Check if AGE is installed
if ! check "age"; then
echo "Installing AGE encryption tool.."
sudo curl -s https://api.github.com/repos/FiloSottile/age/releases/latest | grep "browser_download_url.*linux-amd64.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O - | tar -xz -C /tmp
sudo mv /tmp/age/age /usr/bin/
sudo mv /tmp/age/age-keygen /usr/bin/
echo "AGE installed successfully."
fi

# Copy files to their respective directories.
# .desktop files are copied to ServiceMenus dir for context menu on Dolphin
# and an XML file to MIME dir for files with .age extension to distinguish with an icon and a description.
echo "Copying files.."
cp age-encrypt.desktop ~/.local/share/kservices5/ServiceMenus/
cp age-decrypt.desktop ~/.local/share/kservices5/ServiceMenus/
xdg-mime install --mode user --novendor age-mime.xml

# Create AGE key for current user at home folder .age-key
echo "Generating AGE key.."
mkdir -p ~/.age-key && age-keygen -o ~/.age-key/"$(whoami).age-key"
sed -n '2p' ~/.age-key/"$(whoami).age-key" > ~/.age-key/"$(whoami).pk" && sed 's/# public key: //' ~/.age-key/"$(whoami).pk" > ~/.age-key/"$(whoami)" && rm -f ~/.age-key/"$(whoami).pk" && sed -i '1i\# '$(whoami) ~/.age-key/"$(whoami)"
echo "Installation completed."

0 comments on commit c746130

Please sign in to comment.