diff --git a/arch-setup/packages.rice b/arch-setup/packages.rice index 38682235..2073744a 100644 --- a/arch-setup/packages.rice +++ b/arch-setup/packages.rice @@ -17,6 +17,9 @@ notmuch msmtp isync pass +pass-otp +newsboat +pam-gnupg libgee calcurse neomutt diff --git a/bash_logout b/bash_logout deleted file mode 100755 index 9bf6870f..00000000 --- a/bash_logout +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -date > $HOME/last -~/.local/bin/firefox-sync diff --git a/config/X11/xinitrc b/config/X11/xinitrc index e9ab5c6b..c51891ea 100755 --- a/config/X11/xinitrc +++ b/config/X11/xinitrc @@ -74,3 +74,5 @@ do exec dwm > $XDG_RUNTIME_DIR/dwm.log 2> $XDG_RUNTIME_DIR/dwm.err sleep 0.2 done + +firefox-sync diff --git a/config/mutt/.mailsynclastrun b/config/mutt/.mailsynclastrun deleted file mode 100644 index e69de29b..00000000 diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index ea73ac87..3ba0d3ec 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -16,7 +16,6 @@ compinit compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION [[ ! -d "$XDG_DATA_HOME"/zsh/history ]] || source "$XDG_DATA_HOME"/zsh/history -HISTFILE="$XDG_DATA_HOME"/zsh/history HISTSIZE=100000 SAVEHIST=100000 setopt appendhistory diff --git a/install.sh b/install.sh index cf1d2ea9..5cf132f4 100755 --- a/install.sh +++ b/install.sh @@ -82,9 +82,6 @@ chmod +x $HOME/.zshenv mvie ~/.profile ~/.dotfiles_backup/profile ln -sf ~/.dotfiles/profile ~/.profile -mvie ~/.bash_logout ~/.dotfiles_backup/bash_logout -ln -sf ~/.dotfiles/bash_logout ~/.bash_logout - cp ~/.dotfiles/config.env.def ~/.config.env # Downloading assets @@ -152,21 +149,24 @@ touch "$_Z_DATA" # Root Files and Directories sudo mkdir -p /usr/share/xsessions +sudo mkdir -p /etc/security sudo cp ~/.dotfiles/root/dwm.desktop /usr/share/xsessions +sudo cp ~/.dotfiles/root/pam_env.conf /etc/security/pam_env.conf sudo cp ~/.dotfiles/root/issue /etc/issue sudo cp ~/.dotfiles/root/motd /etc/motd sudo cp ~/.dotfiles/root/nancyj.flf /usr/share/figlet/fonts if [ "$(grep artix < $(uname -a))" = "" ]; then sudo cp ~/.dotfiles/root/quark /etc/init.d + sudo rc-update add quark else sudo cp ~/.dotfiles/root/quark.service /usr/lib/systemd/system + sudo systemctl enable quark fi sudo cp ~/.dotfiles/root/kdialog /usr/local/bin/kdialog sudo cp ~/.dotfiles/root/udevil.conf /etc/udevil/udevil.conf sudo chmod +x /usr/local/bin/kdialog sudo systemctl daemon-reload sudo groupadd nogroup -sudo systemctl enable quark if [ "$username" = "yigit" ]; then ~/.dotfiles/arch-setup/fetch_keys.sh # Fetch keys (For personal use, this is not for you) @@ -175,6 +175,17 @@ if [ "$username" = "yigit" ]; then git config --global user.name "Yigit Colakoglu" fi +# Setup for pam-gnupg +sudo cat << EOF >> /etc/pam.d/system-local-login + +session optional pam_env.so user_readenv=1 +auth optional pam_gnupg.so store-only +session optional pam_gnupg.so +EOF + +echo "allow-preset-passphrase" >> $GNUPGHOME/gpg-agent.conf +echo "max-cache-ttl 172800" >> $GNUPGHOME/gpg-agent.conf + # Build and Install Everything ## Suckless utilities echo "Installing suckless utilities" @@ -193,7 +204,6 @@ npm install > /dev/null 2> /dev/null npm run build > /dev/null 2> /dev/null cd $prev - # Vim and tmux plugins mkdir -p ~/.tmux/plugins vim +PlugInstall +qall diff --git a/local/bin/.gitignore b/local/bin/.gitignore index 00aacdaa..3abb8af6 100644 --- a/local/bin/.gitignore +++ b/local/bin/.gitignore @@ -60,3 +60,5 @@ !zaread !texclear !check-updates +!password_manager +!bwsync diff --git a/local/bin/bwsync b/local/bin/bwsync new file mode 100755 index 00000000..bf78508e --- /dev/null +++ b/local/bin/bwsync @@ -0,0 +1,81 @@ +#!/bin/sh + +skey="$(bw unlock --raw)" + +export BW_SESSION="$skey" + +data="$(bw list items | jq -r -M \ +'.[]| select( .type | contains(1)) |.name,.folderId,(.login|.username,.password,.totp,(.uris|.[0]|.uri))')" + +echo "Fetched passwords from bitwarden." + +uri="" +password="" +name="" +username="" +totp="" +fid="" + +echo "Cleaning previuos store" +prev=$(pwd) +cd $PASSWORD_STORE_DIR +for f in *; do + pass rm -rf "$f" +done +cd $prev + +strip_domain(){ + if [ "$1" = "null" ]; then + echo "null" + return 0 + fi + echo "$1" | head -n 1 | sed 's~http[s]*://~~g' | cut -d"/" -f 1 +} + +get_folder(){ + if [ "$1" = "null" ]; then + echo "No Folder" + return 0 + fi + bw get folder "$1" | jq -r -M ".name" +} + + +IFS=" +" +for l in $data; do + if [ "$name" = "" ]; then + name=$l + echo "$name" + elif [ "$fid" = "" ]; then + fid=$l + elif [ "$username" = "" ]; then + username=$l + elif [ "$password" = "" ]; then + password=$l + elif [ "$totp" = "" ]; then + totp=$l + elif [ "$uri" = "" ]; then + uri=$(strip_domain $l) + folder=$(get_folder $fid) + + if [ "$uri" = "null" ]; then + echo "$password" | pass insert -f -e "$folder/$name/$username" 2> /dev/null > /dev/null + if [ ! "$totp" = "null" ]; then + echo "$totp" | pass otp append -f -e "$folder/$name/$username" > /dev/null 2> /dev/null + fi + else + echo "$password" | pass insert -f -e "$folder/$uri/$username" 2> /dev/null > /dev/null + if [ ! "$totp" = "null" ]; then + echo "$totp" | pass otp append -f -e "$folder/$uri/$username" > /dev/null 2> /dev/null + fi + fi + uri="" + fid="" + password="" + name="" + username="" + totp="" + fi +done + diff --git a/local/bin/check-updates b/local/bin/check-updates index 2d13179a..254f5c30 100755 --- a/local/bin/check-updates +++ b/local/bin/check-updates @@ -20,11 +20,13 @@ notify " Repository Sync" "Checking for package updates..." sudo pacman -Syyuw --noconfirm || notify " An error occured" "Error downloading updates. Check your internet connection, if pacman is already running, or run update manually to see errors." -pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" if pacman -Qu | grep -v "\[ignored\]" then - notify " Repository Sync" "Updates available. Click statusbar icon () for update." + checkupdates 2> /dev/null > ~/.cache/pacman_updates + notify " Repository Sync" "$(pacman -Qu | grep -v "\[ignored\]" | wc -l) Updates available. Click statusbar icon () for update." else notify " Repository Sync" "Sync complete. No new packages for update." fi + +kill -49 "$(pidof dwmblocks)" diff --git a/local/bin/dmenu-mconnect b/local/bin/dmenu-mconnect index db6502fd..9f91638e 100755 --- a/local/bin/dmenu-mconnect +++ b/local/bin/dmenu-mconnect @@ -1,6 +1,6 @@ #!/usr/bin/env bash # dmenu_kdeconnect.sh is a script based off of these scripts -# [polybar-kdeconnect] https://github.com/HackeSta/polybar-kdeconnect +# [polybar-kdeconnect] https://github.com/HackeSta/polybar-kdeconnect # [polybar-kdeconnect-scripts] https://github.com/witty91/polybar-kdeconnect-scripts # Added features # - Removed polybar as a Dependencies (since I use dwm) @@ -25,9 +25,9 @@ # nnn # zenity # ranger -Picker='ranger' +Picker='lf' -# Color Settings of dmenu +# Color Settings of dmenu COLOR_DISCONNECTED='#000' # Device Disconnected COLOR_NEWDEVICE='#ff0' # New Device COLOR_BATTERY_90='#fff' # Battery >= 90 @@ -63,12 +63,12 @@ show_devices (){ icon=$(get_icon $battery $devicetype) # colors="$(get_colors $battery)" # echo "$colors" - show_menu "$devicename | $battery $icon" $deviceobj $battery + show_menu "$devicename | $battery $icon" $deviceobj $battery devices+="$devicename $battery $icon $SEPERATOR" elif [ "$isreach" = "false" ] && [ "$istrust" = "true" ];then #nothing is found devices+="$(get_icon -1 $devicetype)$SEPERATOR" - else + else #found but not yet paired icon=$(get_icon -2 $devicetype) show_pmenu $devicename $deviceobj @@ -94,32 +94,30 @@ show_menu () { options=$(printf "Send SMS\\nSend File\\nSend Text\\nSend URL\\nDisconnect\\n") menu=$(echo $options | dmenu -i -p $1 -l $optionNum ) case "$menu" in - *'Send File') - if [ $Picker == 'ranger' ]; then - mkdir -p $XDG_RUNTIME_DIR/ranger/ - rm -rf $XDG_RUNTIME_DIR/ranger/sentfile - st -c ranger -e ranger --choosefile=$XDG_RUNTIME_DIR/ranger/sentfile - if [ -f $XDG_RUNTIME_DIR/ranger/sentfile ]; then - mconnectctl share-file "$2" "$(cat $XDG_RUNTIME_DIR/ranger/sentfile)" - fi + *'Send File') + mkdir -p $XDG_RUNTIME_DIR/lf/ + rm -rf $XDG_RUNTIME_DIR/lf/sentfile + st -c ranger -e lf -selection-path "$XDG_RUNTIME_DIR/lf/sentfile" + if [ -f $XDG_RUNTIME_DIR/lf/sentfile ]; then + mconnectctl share-file "$2" "$(cat $XDG_RUNTIME_DIR/lf/sentfile)" fi;; - *'Send SMS' ) + *'Send SMS' ) message=$(echo 'OTW' | dmenu -i -p "Msg to send") recipient=$(echo '14039199518' | dmenu -i -p "Recipient's phone #") mconnectctl send-sms "$2" "$message" "$recipient" ;; - *'Send URL' ) + *'Send URL' ) message=$(echo 'Clipboard' | dmenu -i -p "Enter Url:") if [ "$message" = "Clipboard" ]; then message=$(sselp) fi mconnectctl share-url "$2" "$message";; - *'Send Text' ) + *'Send Text' ) message=$(echo 'Clipboard' | dmenu -i -p "Enter Text:") if [ "$message" = "Clipboard" ]; then message=$(sselp) fi mconnectctl share-text "$2" "$message";; - *'Disconnect' ) + *'Disconnect' ) mconnectctl disallow-device "$2" esac } diff --git a/local/bin/firefox-sync b/local/bin/firefox-sync index 4a6d761f..4598c016 100755 --- a/local/bin/firefox-sync +++ b/local/bin/firefox-sync @@ -3,7 +3,6 @@ source ~/.profile if [ ! "$BROWSER" = "firefox" ]; then - echo "Default browser is not firefox, exiting..." exit 0 fi diff --git a/local/bin/mailsync b/local/bin/mailsync index 491f73aa..13a9d201 100755 --- a/local/bin/mailsync +++ b/local/bin/mailsync @@ -47,7 +47,7 @@ case "$(uname)" in displays="$(echo "$pgrepoutput" | grep -wo "[0-9]*:[0-9]\+" | sort -u)" notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-:0}; do export DISPLAY=$x - notify-send --app-name="mutt-wizard" "mutt-wizard" "ﯬ $2 new mail(s) in \`$1\` account." + notify-send --app-name="mutt-wizard" "ﯬ $2 new mail(s) in \`$1\` account." done ;} messageinfo() { [ -n "$pgrepoutput" ] && for x in ${displays:-:0}; do export DISPLAY=$x diff --git a/local/bin/password_manager b/local/bin/password_manager index 97ccec83..cd27e23e 100755 --- a/local/bin/password_manager +++ b/local/bin/password_manager @@ -1,3 +1,43 @@ -#!/bin/sh +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +entry=$(printf '%s\n' "${password_files[@]}" | sort | dmenu -l 7 -p "Pass" -i "$@") + +[[ -n $entry ]] || exit + +action=$(echo -e "Username\nPassword\nTOTP" | dmenu -p "Entry" -i ) +case "$action" in + Username) + username=$(echo "$entry" | rev | cut -d"/" -f 1 | rev) + echo "$username" | xclip -selection clipboard + notify-send -a " Password Manager" "Username copied to clipboard";; + Password) + if [[ $typeit -eq 0 ]]; then + pass show -c "$entry" 2>/dev/null + else + pass show "$entry" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - + fi + notify-send -a " Password Manager" "Password copied to clipboard";; + TOTP) + if [[ $typeit -eq 0 ]]; then + pass otp -c "$entry" 2>/dev/null + else + pass otp "$entry" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - + fi + notify-send -a " Password Manager" "TOTP copied to clipboard";; +esac -bitwarden-dmenu --dmenu-args='-i -l 10' --dmenu-pswd-args="-P -nf white" --clear-clipboard 30 --session-timeout 96600 --sync-vault-after 48300 --on-error 'xargs notify-send --urgency=low' diff --git a/local/bin/zaread b/local/bin/zaread index 4b658118..c1cca958 100755 --- a/local/bin/zaread +++ b/local/bin/zaread @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ## zaread - a simple script created by paoloap. # default variables diff --git a/profile b/profile index 47610d58..b674e7d6 100755 --- a/profile +++ b/profile @@ -1,6 +1,6 @@ #!/bin/bash -# Fixes for some bugs +# Vars for some bugs and applications export QT_QPA_PLATFORMTHEME="qt5ct" export _JAVA_AWT_WM_NONREPARENTING=1 export AWT_TOOLKIT=MToolkit @@ -22,6 +22,7 @@ export XDG_CONFIG_DIRS="/etc/xdg" export XDG_RUNTIME_DIR="/run/user/1000" # Cleanup Home Directory +export HISTFILE="$XDG_DATA_HOME"/history export TMUX_PLUGIN_MANAGER_PATH="$XDG_DATA_HOME"/tmux/plugins export BORG_KEYS_DIR="$XDG_DATA_HOME"/keys/borg export CARGO_HOME="$XDG_DATA_HOME"/cargo @@ -92,10 +93,12 @@ fi # Start xinit if logged in from tty1 if [ "$DISPLAY" = "" ] && [ "$(tty)" = /dev/tty1 ]; then if [ "$DBUS_SESSION_BUS_ADDRESS" = "" ] && [ ! $(command -v dbus-launch) = "" ]; then - sleep 2 - exec xinit 2> $XDG_RUNTIME_DIR/xinit.err > $XDG_RUNTIME_DIR/xinit || exit + sleep 1 + exec xinit 2> $XDG_RUNTIME_DIR/xinit.err > $XDG_RUNTIME_DIR/xinit else - sleep 2 - exec xinit 2> $XDG_RUNTIME_DIR/xinit.err > $XDG_RUNTIME_DIR/xinit || exit + sleep 1 + exec xinit 2> $XDG_RUNTIME_DIR/xinit.err > $XDG_RUNTIME_DIR/xinit fi + exit fi + diff --git a/root/pam_env.conf b/root/pam_env.conf new file mode 100644 index 00000000..806faf7b --- /dev/null +++ b/root/pam_env.conf @@ -0,0 +1,2 @@ +GNUPGHOME DEFAULT=@{HOME}/.local/share/gnupg +XDG_CONFIG_HOME DEFAULT=@{HOME}/.config