diff --git a/.config/Scripts/.offlinepass.py b/.config/Scripts/.offlinepass.py new file mode 100644 index 0000000..9844ed5 --- /dev/null +++ b/.config/Scripts/.offlinepass.py @@ -0,0 +1,5 @@ +import subprocess + +def mailpasswd(account): + path = "/home/hate/.Mail/Gmail/.gmail-%s-passwd.gpg" % account + return subprocess.check_output(["gpg", "--quiet", "--batch", "-d", path]).strip() diff --git a/.config/Scripts/albumart.sh b/.config/Scripts/albumart.sh new file mode 100755 index 0000000..5310d79 --- /dev/null +++ b/.config/Scripts/albumart.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +#put this file to ~/.ncmpcpp/ + +COVER=~/.cache/bum/current.jpg + +function reset_background +{ + printf "\e]20;;100x100+1000+1000\a" +} + +{ + #resize the image's width to 300px + convert "$COVER" -resize 300x "$COVER" + if [[ -f "$COVER" ]] ; then + #scale down the cover to 30% of the original + sleep 3 + printf "\e]20;${COVER};70x70+0+00:op=keep-aspect\a" + else + reset_background + fi +} & + + + diff --git a/.config/Scripts/backlight.sh b/.config/Scripts/backlight.sh new file mode 100755 index 0000000..7875362 --- /dev/null +++ b/.config/Scripts/backlight.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "$(light | cut -d. -f1)" diff --git a/.config/Scripts/betterlockscreen b/.config/Scripts/betterlockscreen new file mode 100755 index 0000000..cea2cc8 --- /dev/null +++ b/.config/Scripts/betterlockscreen @@ -0,0 +1,370 @@ +#!/usr/bin/env bash + +# Author : Pavan Jadhaw +# Github Profile : https://github.com/pavanjadhaw +# Project Repository : https://github.com/pavanjadhaw/betterlockscreen + + +# create folder in ~/.cache/i3lock directory +folder="$HOME/.cache/i3lock" + +# ratio for rectangle to be drawn for time background on lockscreen +# Original Image +orig_wall="$folder/wall.png" + +# Versions (from here) +# You can use these images to set different versions as wallpaper +# lockscreen background. +resized="$folder/resized.png" # resized image for your resolution + +# images to be used as wallpaper +dim="$folder/dim.png" # image with subtle overlay of black +blur="$folder/blur.png" # blurred version +dimblur="$folder/dimblur.png" + +# lockscreen images (images to be used as lockscreen background) +l_resized="$folder/l_resized.png" +l_dim="$folder/l_dim.png" +l_blur="$folder/l_blur.png" +l_dimblur="$folder/l_dimblur.png" + + +prelock() { + pkill -u "$USER" -USR1 dunst +} + +lock() { + #$1 image path + letterEnteredColor=d23c3dff + letterRemovedColor=d23c3dff + passwordCorrect=00000000 + passwordIncorrect=d23c3dff + background=00000000 + foreground=ffffffff + i3lock \ + -t -n -i "$1" \ + --timepos="x-90:h-ch+30" \ + --datepos="tx+24:ty+25" \ + --clock --datestr "Type password to unlock..." \ + --insidecolor=$background --ringcolor=$foreground --line-uses-inside \ + --keyhlcolor=$letterEnteredColor --bshlcolor=$letterRemovedColor --separatorcolor=$background \ + --insidevercolor=$passwordCorrect --insidewrongcolor=$passwordIncorrect \ + --ringvercolor=$foreground --ringwrongcolor=$foreground --indpos="x+280:h-70" \ + --radius=20 --ring-width=4 --veriftext="" --wrongtext="" \ + --textcolor="$foreground" --timecolor="$foreground" --datecolor="$foreground" \ + --force-clock +} + +postlock() { + pkill -u "$USER" -USR2 dunst +} + +rec_get_random() { + dir="$1" + if [ ! -d "$dir" ]; then + user_input="$dir" + return + fi + dir=($dir/*) + dir=${dir[RANDOM % ${#dir[@]}]} + rec_get_random "$dir" +} + +usage() { + + echo "Important : Update the image cache, Ex: betterlockscreen -u path/to/image.jpg" + echo " Image cache must be updated to initially configure or update wallpaper used" + echo + echo + echo "See : https://github.com/pavanjadhaw/betterlockscreen for additional info..." + echo + echo + echo "Options:" + echo + echo " -h --help" + + echo " For help. Ex: betterlockscreen -h or betterlockscreen --help" + echo + echo + echo " -u --update" + echo " to update image cache, you should do this before using any other options" + + echo " Ex: betterlockscreen -u path/to/image.png when image.png is custom background" + echo " Or you can use betterlockscreen -u path/to/imagedir and a random file will be selected" + echo + echo + echo " -l --lock" + echo " to lock screen, Ex. betterlockscreen -l" + echo " you can also use dimmed or blurred background for lockscreen" + echo " Ex: betterlockscreen -l dim (for dimmed background)" + echo " Ex: betterlockscreen -l blur (for blurred background)" + echo " Ex: betterlockscreen -l dimblur (for dimmed + blurred background)" + echo + echo + echo " -s --suspend" + echo " to suspend system and lock screen, Ex. betterlockscreen -s" + echo " you can also use dimmed or blurred background for lockscreen" + echo " Ex: betterlockscreen -s dim (for dimmed background)" + echo " Ex: betterlockscreen -s blur (for blurred background)" + echo " Ex: betterlockscreen -s dimblur (for dimmed + blurred background)" + echo + echo + echo " -w --wall" + echo " you can also set lockscreen background as wallpaper" + echo " to set wallpaper. Ex betterlockscreen -w or betterlockscreen --wall" + echo " you can also use dimmed or blurred variants" + echo " Ex: betterlockscreen -w dim (for dimmed wallpaper)" + echo " Ex: betterlockscreen -w blur (for blurred wallpaper)" + echo " Ex: betterlockscreen -w dimblur (for dimmed + blurred wallpaper)" + echo + echo + echo " -r --resolution" + echo " to be used after -u" + echo " used to set a custom resolution for the image cache." + echo " Ex: betterlockscreen -u path/to/image.png -r 1920x1080" + echo " Ex: betterlockscreen -u path/to/image.png --resolution 3840x1080" + echo + echo " -b --blur" + echo " to be used after -u" + echo " used to set blur intensity. Default to 1." + echo " Ex: betterlockscreen -u path/to/image.png -b 3" + echo " Ex: betterlockscreen -u path/to/image.png --blur 0.5" + echo + +} + +# Options +case "$1" in + "") + if [ ! -f $l_dim ]; then + + echo "Important : Update the image cache, Ex. betterlockscreen -u path/to/image.jpg" + echo + echo " Image cache must be updated to initially configure or update wallpaper used" + echo + echo "See also : For other set of options and help use help command." + echo "Ex. betterlockscreen -h or betterlockscreen --help" + + echo + echo "See : https://github.com/pavanjadhaw/betterlockscreen for addition info..." + exit 1 + else + echo + echo "Seems you havent provided any argument, see below for usage info" + echo + echo "See also : For other set of options and help use help command." + + echo "Ex. betterlockscreen -h or betterlockscreen --help" + + echo + echo "See : https://github.com/pavanjadhaw/betterlockscreen for addition info..." + echo + exit 1 + fi + ;; + + -h | --help) + + usage + + ;; + + -l | --lock) + case "$2" in + "") + # default lockscreen + prelock + lock "$l_resized" + postlock + ;; + + dim) + # lockscreen with dimmed background + prelock + lock "$l_dim" + postlock + ;; + + blur) + # set lockscreen with blurred background + prelock + lock "$l_blur" + postlock + ;; + + dimblur) + # set lockscreen with dimmed + blurred background + prelock + lock "$l_dimblur" + postlock + ;; + esac + ;; + + -s | --suspend) + case "$2" in + "") + # default lockscreen + prelock + systemctl suspend && lock "$l_resized" + postlock + ;; + + dim) + # lockscreen with dimmed background + prelock + systemctl suspend && lock "$l_dim" + postlock + ;; + + blur) + # set lockscreen with blurred background + prelock + systemctl suspend && lock "$l_blur" + postlock + ;; + + dimblur) + # set lockscreen with dimmed + blurred background + prelock + systemctl suspend && lock "$l_dimblur" + postlock + ;; + esac + ;; + + + -w | --wall) + case "$2" in + "") + # set resized image as wallpaper if no argument is supplied by user + feh --bg-fill $resized + ;; + + dim) + # set dimmed image as wallpaper + feh --bg-fill $dim + ;; + + blur) + # set blurred image as wallpaper + feh --bg-fill $blur + ;; + + dimblur) + # set dimmed + blurred image as wallpaper + feh --bg-fill $dimblur + ;; + esac + ;; + + -u | --update) + background="$2" + shift 2 + + # find your resolution so images can be resized to match your screen resolution + y_res=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') + # default blur level + blur_level=1 + + # parse update arguments + while [ $# -gt 0 ]; do + case "$1" in + -r | --resolution ) + y_res="$2" + shift 2 + ;; + -b | --blur ) + blur_level="$2" + shift 2 + ;; + *) + shift ;; + esac + done + + rectangles=" " + SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') + for RES in $SR; do + SRA=(${RES//[x+]/ }) + CX=$((${SRA[2]} + 25)) + CY=$((${SRA[1]} - 30)) + rectangles+="rectangle $CX,$CY $((CX+300)),$((CY-80)) " + done + + # User supplied Image + user_image="$folder/user_image.png" + + # create folder + if [ ! -d $folder ]; then + echo "Creating '$folder' directory to cache processed images." + mkdir -p "$folder" + fi + + # get random file in dir if passed argument is a dir + rec_get_random "$background" + + # get user image + cp "$user_input" "$user_image" + if [ ! -f $user_image ]; then + echo "Please specify the path to the image you would like to use" + exit 1 + fi + + # replace orignal with user image + cp "$user_image" "$orig_wall" + rm "$user_image" + + echo "Generating alternate images based on the image you specified," + echo "please wait this might take few seconds..." + + # wallpapers + + echo + echo "Converting provided image to match your resolution..." + # resize image + convert "$orig_wall" -resize "$y_res""^" -gravity center -extent "$y_res" "$resized" + + echo + echo "Applying dim and blur effect to resized image" + # dim + convert "$resized" -fill black -colorize 40% "$dim" + + # blur + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + convert "$resized" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$y_res^" -gravity center -extent "$y_res" \ + "$blur" + + # dimblur + convert "$dim" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$y_res^" -gravity center -extent "$y_res" \ + "$dimblur" + + # lockscreen backgrounds + + echo + echo "Caching images for faster screen locking" + # resized + convert "$resized" -draw "fill black fill-opacity 0.4 $rectangles" "$l_resized" + + # dim + convert "$dim" -draw "fill black fill-opacity 0.4 $rectangles" "$l_dim" + + # blur + convert "$blur" -draw "fill black fill-opacity 0.4 $rectangles" "$l_blur" + + # blur + convert "$dimblur" -draw "fill black fill-opacity 0.4 $rectangles" "$l_dimblur" + + echo + echo "All required changes have been applied" + ;; +esac diff --git a/.config/Scripts/extract b/.config/Scripts/extract new file mode 100755 index 0000000..aaf2911 --- /dev/null +++ b/.config/Scripts/extract @@ -0,0 +1,30 @@ +#!/bin/bash +# there are two different ways this script can work. +# for the first way, uncomment the two lines after the if and place two '.' in front of the /$1 +# this creates a new directory in the directory where the compressed file is and dumps the content in it +# for the second way, comment the two lines under the if and place just one '.' in front of the /$1 +# this just dumps the content of the compressed file in the same directory of the compressed file +if [ -f $1 ] ; then + NAME=${1%.*} + mkdir $NAME && cd $NAME + case $1 in + *.tar.bz2) tar xvjf ../$1 ;; + *.tar.gz) tar xvzf ../$1 ;; + *.tar.xz) tar xvJf ../$1 ;; + *.lzma) unlzma ../$1 ;; + *.bz2) bunzip2 ../$1 ;; + *.rar) unrar x -ad ../$1 ;; + *.gz) gunzip ../$1 ;; + *.tar) tar xvf ../$1 ;; + *.tbz2) tar xvjf ../$1 ;; + *.tgz) tar xvzf ../$1 ;; + *.zip) unzip ../$1 ;; + *.Z) uncompress ../$1 ;; + *.7z) 7z x ../$1 ;; + *.xz) unxz ../$1 ;; + *.exe) cabextract ../$1 ;; + *) echo "extract: '$1' - unknown archive method" ;; + esac +else +echo "$1 - file does not exist" + fi diff --git a/.config/Scripts/gmail.sh b/.config/Scripts/gmail.sh new file mode 100755 index 0000000..1aeefc7 --- /dev/null +++ b/.config/Scripts/gmail.sh @@ -0,0 +1,13 @@ +USER= +PASS=Your_Password + +COUNT=`curl -su $USER:$PASS https://mail.google.com/mail/feed/atom || echo "unknown number of"` +COUNT=`echo "$COUNT" | grep -oPm1 "(?<=)[^<]+" ` +echo $COUNT +if [ "$COUNT" != "0" ]; then + if [ "$COUNT" = "1" ];then + WORD="mail"; + else + WORD="mails"; + fi +fi diff --git a/.config/Scripts/gmail_notifier.py b/.config/Scripts/gmail_notifier.py new file mode 100644 index 0000000..4bbcdd8 --- /dev/null +++ b/.config/Scripts/gmail_notifier.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright 2011 Orphée Lafond-Lummis . No rights reserved. + +"""Gmail notifier for twmn. +1. Fill in your email and password. +2. Enable IMAP in Gmail. +3. Enjoy. +""" + +#TODO: handle disconnection +#TODO: store password in a less sucky way (getpass maybe?) +#TODO: add gmail icon to notification request + +import imaplib +import re +import socket +import time +import os + +def cred_from_muttrc(): + with open(os.path.expanduser('~/.muttrc')) as fin: + data = fin.read() + re_user = re.search(r'set\s+imap_user\s*=\s*"(.*)"', data, re.MULTILINE) + re_pass = re.search(r'set\s+imap_pass\s*=\s*"(.*)"', data, re.MULTILINE) + if re_user: + user = re_user.group(1) + if re_pass: + password = re_pass.group(1) + return user, password + + +# Options +EMAIL = "lahtinen.harri@gmail.com" +PASSWORD = "Alicante2014" +# ... or if ~/.muttrc exists, read it. +#EMAIL, PASSWORD = cred_from_muttrc() +FREQUENCY = 15 * 60 # Check emails every 30 minutes +TWMN_PORT = 9797 +TWNM_ADDR = "127.0.0.1" + + +def notification(sock, content): + TITLE = "Gmail" + message = "" + \ + "{}".format(TITLE) + \ + "{}".format(content) + \ + "{}".format("email_icon") + \ + "" + sock.send(bytes(message.encode("utf-8"))) + + +if __name__ == "__main__": + # Connect to twmn + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect((TWNM_ADDR, TWMN_PORT)) + + # Login to Gmail and select inbox + try: + gmail = imaplib.IMAP4_SSL('imap.gmail.com', 993) + gmail.login(EMAIL, PASSWORD) + gmail.select(readonly=1) # selects inbox by default + except imaplib.IMAP4.error as err: + notification(s, "Couldn't connect properly.") + raise SystemExit(-1) + + # Check emails at FREQUENCY interval + while True: + unreadCount = re.search(b"UNSEEN (\d+)", \ + gmail.status("INBOX", "(UNSEEN)")[1][0]).group(1) + unreadCount = int(unreadCount) + if unreadCount > 0: + content = "{} unread".format(unreadCount) + \ + " email{}.".format(("s" if unreadCount > 1 else "")) + notification(s, content) + time.sleep(FREQUENCY) diff --git a/.config/Scripts/gpmdp-remote b/.config/Scripts/gpmdp-remote new file mode 100755 index 0000000..a9350bc --- /dev/null +++ b/.config/Scripts/gpmdp-remote @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +# +# gpmdp-remote - get info from Google Play Music Desktop Player easily +# https://github.com/iandrewt/gpmdp-remote +# +# Created by Andrew Titmuss +# https://github.com/iandrewt/ + +# Speed up script by not using Unicode +export LC_ALL=C +export LANG=C + +# Determine config file location from uname +case "$(uname)" in + "Linux" | *"BSD") json_file="$HOME/.config/Google Play Music Desktop Player/json_store/playback.json" ;; + "Darwin") json_file="$HOME/Library/Application Support/Google Play Music Desktop Player/json_store/playback.json" ;; + "CYGWIN"*) json_file="$APPDATA/Google Play Music Desktop Player/json_store/playback.json" ;; +esac + +title () { + printf "%s\n" "$(awk -F '"|:' '/"title"/ {printf $5}' "$json_file")" +} + +artist () { + printf "%s\n" "$(awk -F '"|:' '/"artist"/ {printf $5}' "$json_file")" +} + +album () { + printf "%s\n" "$(awk -F '"|:' '!/"albumArt"/ && /"album"/ {printf $5}' "$json_file")" +} + +album_art () { + printf "%s\n" "$(awk -F '"|:' '/"albumArt"/ {printf $5":"$6}' "$json_file")" +} + +time_current () { + printf "%s\n" "$(awk -F ': |,' '/"current"/ {printf $2}' "$json_file")" +} + +time_total () { + printf "%s\n" "$(awk -F ': |,' '/"total"/ {printf $2}' "$json_file")" +} + +gpmdp_status () { + gpmdp_status=$(awk -F ': |,' '/"playing"/ {printf $2}' "$json_file") + + if [[ "$gpmdp_status" == *"true"* ]]; then + printf "%s\n" "Playing" + elif [[ "$gpmdp_status" == *"false"* ]]; then + printf "%s\n" "Paused" + fi +} + +gpmdp_info () { + if [ "$(gpmdp_status)" == "Playing" ]; then + printf "%s\n" "Now Playing: $(title) by $(artist)" + elif [ "$(gpmdp_status)" == "Paused" ]; then + printf "%s\n" "Paused: $(title) by $(artist)" + fi +} + +current () { + printf "%s\n" "$(artist) - $(album) - $(title)" +} + +usage () { cat << EOF + usage: gpmdp-remote