scripts added
This commit is contained in:
parent
7bc11f19cf
commit
638a61fe67
|
|
@ -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()
|
||||
|
|
@ -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
|
||||
} &
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "$(light | cut -d. -f1)"
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
USER=
|
||||
PASS=Your_Password
|
||||
|
||||
COUNT=`curl -su $USER:$PASS https://mail.google.com/mail/feed/atom || echo "<fullcount>unknown number of</fullcount>"`
|
||||
COUNT=`echo "$COUNT" | grep -oPm1 "(?<=<fullcount>)[^<]+" `
|
||||
echo $COUNT
|
||||
if [ "$COUNT" != "0" ]; then
|
||||
if [ "$COUNT" = "1" ];then
|
||||
WORD="mail";
|
||||
else
|
||||
WORD="mails";
|
||||
fi
|
||||
fi
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2011 Orphée Lafond-Lummis <orftz.com>. 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 = "<root>" + \
|
||||
"<title>{}</title>".format(TITLE) + \
|
||||
"<content>{}</content>".format(content) + \
|
||||
"<icon>{}</icon>".format("email_icon") + \
|
||||
"</root>"
|
||||
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)
|
||||
|
|
@ -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 <option>
|
||||
info Print info about now playing song
|
||||
title Print current song title
|
||||
artist Print current song artist
|
||||
album Print current song album
|
||||
album_art Print current song album art URL
|
||||
time_current Print current song time in milliseconds
|
||||
time_total Print total song time in milliseconds
|
||||
status Print whether GPMDP is paused or playing
|
||||
current Print now playing song in "artist - album - song" format
|
||||
help Print this help message
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
case $1 in
|
||||
info) gpmdp_info ;;
|
||||
title) title ;;
|
||||
artist) artist ;;
|
||||
album) album ;;
|
||||
album_art) album_art ;;
|
||||
time_current) time_current ;;
|
||||
time_total) time_total ;;
|
||||
status) gpmdp_status ;;
|
||||
current) current ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,260 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import copy
|
||||
import fcntl
|
||||
import json
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from contextlib import contextmanager, suppress
|
||||
from pathlib import Path
|
||||
|
||||
import i3ipc
|
||||
|
||||
|
||||
DEFAULT_CONF = {
|
||||
"menu": "rofi -dmenu -p 'quickterm: ' -no-custom -auto-select",
|
||||
"term": "urxvt",
|
||||
"history": "{$HOME}/.cache/i3/i3-quickterm.order",
|
||||
"ratio": 0.25,
|
||||
"pos": "top",
|
||||
"shells": {
|
||||
"haskell": "ghci",
|
||||
"js": "node",
|
||||
"python": "ipython3 --no-banner",
|
||||
"shell": "{$SHELL}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MARK_QT_PATTERN = 'quickterm_.*'
|
||||
MARK_QT = 'quickterm_{}'
|
||||
|
||||
|
||||
def TERM(executable, execopt='-e', execfmt='expanded', titleopt='-T'):
|
||||
"""Helper to declare a terminal in the hardcoded list"""
|
||||
if execfmt not in ('expanded', 'string'):
|
||||
raise RuntimeError('Invalid execfmt')
|
||||
|
||||
fmt = executable
|
||||
|
||||
if titleopt is not None:
|
||||
fmt += ' ' + titleopt + ' {title}'
|
||||
|
||||
fmt += ' {} {{{}}}'.format(execopt, execfmt)
|
||||
|
||||
return fmt
|
||||
|
||||
|
||||
TERMS = {
|
||||
'alacritty': TERM('alacritty', titleopt='-t'),
|
||||
'gnome-terminal': TERM('gnome-terminal', execopt='--', titleopt=None),
|
||||
'roxterm': TERM('roxterm'),
|
||||
'st': TERM('st'),
|
||||
'termite': TERM('termite', execfmt='string', titleopt='-t'),
|
||||
'urxvt': TERM('urxvt'),
|
||||
'xfce4-terminal': TERM('xfce4-terminal', execfmt='string'),
|
||||
'xterm': TERM('xterm'),
|
||||
}
|
||||
|
||||
|
||||
def conf_path():
|
||||
home_dir = os.environ['HOME']
|
||||
xdg_dir = os.environ.get('XDG_CONFIG_DIR', '{}/.config'.format(home_dir))
|
||||
|
||||
return xdg_dir + '/i3/i3-quickterm.json'
|
||||
|
||||
|
||||
def read_conf(fn):
|
||||
try:
|
||||
with open(fn, 'r') as f:
|
||||
c = json.load(f)
|
||||
return c
|
||||
except Exception as e:
|
||||
print('invalid config file: {}'.format(e), file=sys.stderr)
|
||||
return {}
|
||||
|
||||
|
||||
@contextmanager
|
||||
def get_history_file(conf):
|
||||
if conf['history'] is None:
|
||||
yield None
|
||||
return
|
||||
|
||||
p = Path(expand_command(conf['history'])[0])
|
||||
|
||||
os.makedirs(str(p.parent), exist_ok=True)
|
||||
|
||||
f = open(str(p), 'a+')
|
||||
fcntl.lockf(f, fcntl.LOCK_EX)
|
||||
|
||||
try:
|
||||
f.seek(0)
|
||||
yield f
|
||||
finally:
|
||||
fcntl.lockf(f, fcntl.LOCK_UN)
|
||||
f.close()
|
||||
|
||||
|
||||
def expand_command(cmd, **rplc_map):
|
||||
d = {'$' + k: v for k, v in os.environ.items()}
|
||||
d.update(rplc_map)
|
||||
|
||||
return shlex.split(cmd.format(**d))
|
||||
|
||||
|
||||
def move_back(conn, selector):
|
||||
conn.command('{} floating enable, move scratchpad'
|
||||
.format(selector))
|
||||
|
||||
|
||||
def pop_it(conn, mark_name, pos='top', ratio=0.25):
|
||||
ws, _ = get_current_workspace(conn)
|
||||
wx, wy = ws['rect']['x'], ws['rect']['y']
|
||||
wwidth, wheight = ws['rect']['width'], ws['rect']['height']
|
||||
|
||||
width = wwidth
|
||||
height = int(wheight*ratio)
|
||||
posx = wx
|
||||
|
||||
if pos == 'bottom':
|
||||
margin = 6
|
||||
posy = wy + wheight - height - margin
|
||||
else: # pos == 'top'
|
||||
posy = wy
|
||||
|
||||
conn.command('[con_mark={mark}],'
|
||||
'resize set {width} px {height} px,'
|
||||
'move absolute position {posx}px {posy}px,'
|
||||
'move scratchpad,'
|
||||
'scratchpad show'
|
||||
''.format(mark=mark_name, posx=posx, posy=posy,
|
||||
width=width, height=height))
|
||||
|
||||
|
||||
def get_current_workspace(conn):
|
||||
ws = [w for w in conn.get_workspaces() if w['focused']][0]
|
||||
tree = conn.get_tree()
|
||||
|
||||
# wname = workspace['name']
|
||||
ws_tree = [c for c in tree.descendents()
|
||||
if c.type == 'workspace' and c.name == ws['name']][0]
|
||||
|
||||
return ws, ws_tree
|
||||
|
||||
|
||||
def toggle_quickterm_select(conf, hist=None):
|
||||
"""Hide a quickterm visible on current workspace or prompt
|
||||
the user for a shell type"""
|
||||
conn = i3ipc.Connection()
|
||||
ws, ws_tree = get_current_workspace(conn)
|
||||
|
||||
# is there a quickterm opened in the current workspace?
|
||||
qt = ws_tree.find_marked(MARK_QT_PATTERN)
|
||||
if qt:
|
||||
qt = qt[0]
|
||||
move_back(conn, '[con_id={}]'.format(qt.id))
|
||||
return
|
||||
|
||||
with get_history_file(conf) as hist:
|
||||
# compute the list from conf + (maybe) history
|
||||
hist_list = None
|
||||
if hist is not None:
|
||||
with suppress(Exception):
|
||||
hist_list = json.load(hist)
|
||||
|
||||
# invalidate if different set from the configured shells
|
||||
if set(hist_list) != set(conf['shells'].keys()):
|
||||
hist_list = None
|
||||
|
||||
shells = hist_list or sorted(conf['shells'].keys())
|
||||
|
||||
proc = subprocess.Popen(expand_command(conf['menu']),
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
for r in shells:
|
||||
proc.stdin.write((r + '\n').encode())
|
||||
stdout, _ = proc.communicate()
|
||||
|
||||
shell = stdout.decode().strip()
|
||||
|
||||
if shell not in conf['shells']:
|
||||
return
|
||||
|
||||
if hist is not None:
|
||||
# put the selected shell on top
|
||||
shells = [shell] + [s for s in shells if s != shell]
|
||||
hist.truncate(0)
|
||||
json.dump(shells, hist)
|
||||
|
||||
toggle_quickterm(conf, shell)
|
||||
|
||||
|
||||
def quoted(s):
|
||||
return "'" + s + "'"
|
||||
|
||||
|
||||
def term_title(shell):
|
||||
return '{} - i3-quickterm'.format(shell)
|
||||
|
||||
|
||||
def toggle_quickterm(conf, shell):
|
||||
conn = i3ipc.Connection()
|
||||
tree = conn.get_tree()
|
||||
shell_mark = MARK_QT.format(shell)
|
||||
qt = tree.find_marked(shell_mark)
|
||||
|
||||
# does it exist already?
|
||||
if len(qt) == 0:
|
||||
term = TERMS.get(conf['term'], conf['term'])
|
||||
qt_cmd = "{} -i {}".format(sys.argv[0], shell)
|
||||
|
||||
term_cmd = expand_command(term, title=quoted(term_title(shell)),
|
||||
expanded=qt_cmd,
|
||||
string=quoted(qt_cmd))
|
||||
os.execvp(term_cmd[0], term_cmd)
|
||||
else:
|
||||
qt = qt[0]
|
||||
ws, ws_tree = get_current_workspace(conn)
|
||||
|
||||
move_back(conn, '[con_id={}]'.format(qt.id))
|
||||
if qt.workspace().name != ws.name:
|
||||
pop_it(conn, shell_mark, conf['pos'], conf['ratio'])
|
||||
|
||||
|
||||
def launch_inplace(conf, shell):
|
||||
conn = i3ipc.Connection()
|
||||
shell_mark = MARK_QT.format(shell)
|
||||
conn.command('mark {}'.format(shell_mark))
|
||||
move_back(conn, '[con_mark={}]'.format(shell_mark))
|
||||
pop_it(conn, shell_mark, conf['pos'], conf['ratio'])
|
||||
prog_cmd = expand_command(conf['shells'][shell])
|
||||
os.execvp(prog_cmd[0], prog_cmd)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-i', '--in-place', dest='in_place',
|
||||
action='store_true')
|
||||
parser.add_argument('shell', metavar='SHELL', nargs='?')
|
||||
args = parser.parse_args()
|
||||
|
||||
conf = copy.deepcopy(DEFAULT_CONF)
|
||||
conf.update(read_conf(conf_path()))
|
||||
|
||||
if args.shell is None:
|
||||
toggle_quickterm_select(conf)
|
||||
sys.exit(0)
|
||||
|
||||
if args.shell not in conf['shells']:
|
||||
print('unknown shell: {}'.format(args.shell), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if args.in_place:
|
||||
launch_inplace(conf, args.shell)
|
||||
else:
|
||||
toggle_quickterm(conf, args.shell)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -z $@ ]
|
||||
then
|
||||
function gen_workspaces()
|
||||
{
|
||||
i3-msg -t get_workspaces | tr ',' '\n' | grep "name" | sed 's/"name":"\(.*\)"/\1/g' | sort -n
|
||||
}
|
||||
|
||||
|
||||
echo empty; gen_workspaces
|
||||
else
|
||||
WORKSPACE=$@
|
||||
|
||||
if [ x"empty" = x"${WORKSPACE}" ]
|
||||
then
|
||||
i3_empty_workspace.sh >/dev/null
|
||||
elif [ -n "${WORKSPACE}" ]
|
||||
then
|
||||
i3-msg workspace "${WORKSPACE}" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
|
||||
# source https://faq.i3wm.org/question/2172/how-do-i-find-the-criteria-for-use-with-i3-config-commands-like-for_window-eg-to-force-splashscreens-and-dialogs-to-show-in-floating-mode/
|
||||
|
||||
# i3-get-window-criteria - Get criteria for use with i3 config commands
|
||||
|
||||
# To use, run this script, then click on a window.
|
||||
# Output is in the format: [<name>=<value> <name>=<value> ...]
|
||||
|
||||
# Known problem: when WM_NAME is used as fallback for the 'title="<string>"'
|
||||
# criterion, quotes in "<string>" are not escaped properly. This is a problem
|
||||
# with the output of `xprop`,
|
||||
# reported upstream: https://bugs.freedesktop.org/show_bug.cgi?id=66807
|
||||
|
||||
PROGNAME=`basename "$0"`
|
||||
|
||||
# Check for xwininfo and xprop
|
||||
for cmd in xwininfo xprop; do
|
||||
if ! which $cmd > /dev/null 2>&1; then
|
||||
echo "$PROGNAME: $cmd: command not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
match_int='[0-9][0-9]*'
|
||||
match_string='".*"'
|
||||
match_qstring='"[^"\\]*(\\.[^"\\]*)*"' # NOTE: Adds 1 backreference
|
||||
|
||||
{
|
||||
# Run xwininfo, get window id
|
||||
window_id=`xwininfo -int | sed -nre "s/^xwininfo: Window id: ($match_int) .*$/\1/p"`
|
||||
echo "id=$window_id"
|
||||
|
||||
# Run xprop, transform its output into i3 criteria. Handle fallback to
|
||||
# WM_NAME when _NET_WM_NAME isn't set
|
||||
xprop -id $window_id |
|
||||
sed -nr \
|
||||
-e "s/^WM_CLASS\(STRING\) = ($match_qstring), ($match_qstring)$/instance=\1\nclass=\3/p" \
|
||||
-e "s/^WM_WINDOW_ROLE\(STRING\) = ($match_qstring)$/window_role=\1/p" \
|
||||
-e "/^WM_NAME\(STRING\) = ($match_string)$/{s//title=\1/; h}" \
|
||||
-e "/^_NET_WM_NAME\(UTF8_STRING\) = ($match_qstring)$/{s//title=\1/; h}" \
|
||||
-e '${g; p}'
|
||||
} | sort | tr "\n" " " | sed -r 's/^(.*) $/[\1]\n/'
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This program will automatically search your mails.
|
||||
# And print number of new messages.
|
||||
# Require another prog for doing this, offlineimap, msmtp or isync.
|
||||
|
||||
gmaildir=/home/hate/.Mail/Gmail/INBOX/new
|
||||
prog=/usr/bin/offlineimap
|
||||
count=0
|
||||
log=/tmp/mails.log
|
||||
|
||||
if [ -x $prog ] ; then
|
||||
|
||||
$prog 2>/dev/null &
|
||||
wait
|
||||
|
||||
if [ $? = 0 ] ; then
|
||||
echo "$(date) - $prog success" >> $log
|
||||
elif [ $? = 1 ] ; then
|
||||
echo "$(date) - $prog has fail" >> $log
|
||||
else
|
||||
echo "$(date) - unknown prob" >> $log
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -d ${gmaildir} ]] ; then
|
||||
echo "$(date) - $gmaildir does not exist" >> $log
|
||||
elif [[ ! -n $(ls "${gmaildir}") ]] ; then
|
||||
echo "$(date) - $gmaildir no new mail found" >> $log
|
||||
else
|
||||
count=$(ls -1 "${gmaildir}" | wc -l)
|
||||
fi
|
||||
|
||||
echo "${count}"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import socket
|
||||
import mpd
|
||||
import time
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.connect(("127.0.0.1", 9797))
|
||||
client = mpd.MPDClient()
|
||||
client.connect("127.0.0.1", "6600")
|
||||
prev = ""
|
||||
while True:
|
||||
current = client.currentsong()
|
||||
if prev != current:
|
||||
s.send("<root><title>" + current["title"] + "</title>"
|
||||
"<content> from " + current["artist"] + "</content></root>")
|
||||
prev = current
|
||||
time.sleep(1)
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env bash
|
||||
# nrnl.sh - displays sys info
|
||||
|
||||
# colors
|
||||
f=3 b=4
|
||||
for j in f b; do
|
||||
for i in {0..7}; do
|
||||
printf -v $j$i "%b" "\e[${!j}${i}m"
|
||||
done
|
||||
done
|
||||
bld=$'\e[1m'
|
||||
rst=$'\e[0m'
|
||||
inv=$'\e[7m'
|
||||
|
||||
# detect
|
||||
user=$(whoami)
|
||||
host=$(hostname)
|
||||
kernel=$(uname -r)
|
||||
kernel=${kernel%-*}
|
||||
kernel=${kernel%_*}
|
||||
shell=$(basename $SHELL)
|
||||
os() {
|
||||
os=$(source /etc/os-release && echo $ID)
|
||||
export os
|
||||
}
|
||||
|
||||
wm() {
|
||||
id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)
|
||||
id=${id##* }
|
||||
wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t)
|
||||
wm=${wm/*_NET_WM_NAME = }
|
||||
wm=${wm/\"}
|
||||
wm=${wm/\"*}
|
||||
wm=${wm,,}
|
||||
export wm
|
||||
}
|
||||
|
||||
init() {
|
||||
init=$(readlink /sbin/init)
|
||||
init=${init##*/}
|
||||
init=${init%%-*}
|
||||
export init
|
||||
}
|
||||
|
||||
# exec
|
||||
os
|
||||
wm
|
||||
init
|
||||
cat <<EOF
|
||||
$user${f2}@${rst}$host
|
||||
os${f2}:${rst} ${f7}$os${rst}
|
||||
┌───┐ kernel${f2}:${rst} ${f7}$kernel${rst}
|
||||
│${f2}•${rst}˩${f2}•${rst}│ shell${f2}:${rst} ${f7}$shell${rst}
|
||||
└───┘ init${f2}:${rst} ${f7}$init${rst}
|
||||
wm${f2}:${rst} ${f7}$wm${rst}
|
||||
EOF
|
||||
|
||||
# optional blocks
|
||||
if [[ $1 = "-b" ]]; then
|
||||
pcs() { for i in {0..7}; do echo -en "\e[${1}$((30+$i))m \u2588\u2588 \e[0m"; done; }
|
||||
printf "\n%s\n%s\n\n" "$(pcs)" "$(pcs '1;')"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. Aborting."; exit 1; }
|
||||
command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. Aborting."; exit 1; }
|
||||
|
||||
APIKEY="99e2d54517287c6de1e9db99db2fdc84"
|
||||
CITY_ID="659181" # customise this for your city
|
||||
URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}"
|
||||
|
||||
WEATHER_RESPONSE=$(wget -qO- "${URL}")
|
||||
|
||||
WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g')
|
||||
WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp')
|
||||
WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg')
|
||||
WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed')
|
||||
|
||||
#WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}")
|
||||
WIND_SPEED=$(awk "BEGIN {print $WIND_SPEED}")
|
||||
WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}")
|
||||
DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N )
|
||||
WIND_DIR=${DIR_ARRAY[WIND_DIR]}
|
||||
|
||||
case $WEATHER_CONDITION in
|
||||
'Clouds')
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
'Rain')
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
'Snow')
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
*)
|
||||
WEATHER_ICON=""
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${WEATHER_ICON} ${WEATHER_CONDITION} ${WEATHER_TEMP}°C"
|
||||
#echo "${WEATHER_ICON} ${WEATHER_CONDITION}: ${WEATHER_TEMP}°C: ${WIND_SPEED} m/s ${WIND_DIR}"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
|
||||
updates_arch=0
|
||||
fi
|
||||
|
||||
if ! updates_aur=$(yay -Qum | wc -l); then
|
||||
# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then
|
||||
# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
|
||||
updates_aur=0
|
||||
fi
|
||||
|
||||
updates=$(("$updates_arch" + "$updates_aur"))
|
||||
|
||||
if [ "$updates" -gt 0 ]; then
|
||||
echo "# $updates"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# small power menu using rofi, i3, systemd and pm-utils
|
||||
# (last 3 dependencies are adjustable below)
|
||||
# tostiheld, 2016
|
||||
|
||||
poweroff_command="systemctl poweroff"
|
||||
reboot_command="systemctl reboot"
|
||||
logout_command="i3-msg exit"
|
||||
hibernate_command="systemctl hibernate"
|
||||
suspend_command="systemctl suspend"
|
||||
|
||||
# you can customise the rofi command all you want ...
|
||||
rofi_command="rofi -width 10 -lines 5 -hide-scrollbar -opacity 100 -padding 5"
|
||||
|
||||
options=$'poweroff\nreboot\nlogout\nhibernate\nsuspend'
|
||||
|
||||
# ... because the essential options (-dmenu and -p) are added here
|
||||
eval \$"$(echo "$options" | $rofi_command -dmenu -p "")_command"
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
#!/usr/bin/env bash
|
||||
# author: unknown
|
||||
# sentby: MoreChannelNoise (https://www.youtube.com/user/MoreChannelNoise)
|
||||
# editby: gotbletu (https://www.youtube.com/user/gotbletu)
|
||||
|
||||
# demo: https://www.youtube.com/watch?v=kxJClZIXSnM
|
||||
# info: this is a script to launch other rofi scripts,
|
||||
# saves us the trouble of binding multiple hotkeys for each script,
|
||||
# when we can just use one hotkey for everything.
|
||||
|
||||
declare -A LABELS
|
||||
declare -A COMMANDS
|
||||
|
||||
###
|
||||
# List of defined 'bangs'
|
||||
|
||||
# launch programs
|
||||
COMMANDS["apps"]="rofi -show run"
|
||||
LABELS["apps"]=""
|
||||
|
||||
#ssh
|
||||
COMMANDS["ssh"]="rofi -show ssh"
|
||||
LABELS["ssh"]=""
|
||||
|
||||
# change window
|
||||
COMMANDS["window"]="rofi -show window"
|
||||
LABELS["window"]=""
|
||||
|
||||
# lock
|
||||
COMMANDS["lock"]="exec betterlockscreen --lock dim"
|
||||
LABELS["lock"]=""
|
||||
|
||||
# mpd
|
||||
COMMANDS["mpd"]="~/.config/Scripts/rofi-mpd -a"
|
||||
LABELS["mpd"]=""
|
||||
|
||||
# googler
|
||||
COMMANDS["googler"]="~/.config/Scripts/rofi-googler.sh"
|
||||
LABELS["googler"]=""
|
||||
|
||||
# open bookmarks
|
||||
COMMANDS["bookmarks"]="~/.config/Scripts/rofi-surfraw-bookmarks.sh"
|
||||
LABELS["bookmarks"]=""
|
||||
|
||||
# search local files
|
||||
COMMANDS["locate"]="~/.config/Scripts/rofi-locate.sh"
|
||||
LABELS["locate"]=""
|
||||
|
||||
# open custom web searches
|
||||
COMMANDS["websearch"]="~/.config/Scripts/rofi-surfraw-websearch.sh"
|
||||
LABELS["websearch"]=""
|
||||
|
||||
# i3 switch workspace
|
||||
COMMANDS["workspace"]="~/.config/Scripts/i3_switch_workspace.sh"
|
||||
LABELS["workspace"]=""
|
||||
|
||||
# show clipboard history
|
||||
# source: https://github.com/erebe/greenclip
|
||||
COMMANDS["clipboard"]='rofi -modi "clipboard:greenclip print" -show clipboard'
|
||||
LABELS["clipboard"]=""
|
||||
|
||||
# references --------------------------
|
||||
#COMMANDS[";sr2"]="chromium 'wikipedia.org/search-redirect.php?search=\" \${input}\""
|
||||
#LABELS[";sr2"]=""
|
||||
|
||||
#COMMANDS[";piratebay"]="chromium --disk-cache-dir=/tmp/cache http://thepiratebay.org/search/\" \${input}\""
|
||||
#LABELS[";piratebay"]=""
|
||||
|
||||
#COMMANDS[".bin"]="spacefm -r '/home/hate/bin'"
|
||||
#LABELS[".bin"]=".bin"
|
||||
|
||||
#COMMANDS["#screenshot"]='/home/dka/bin/screenshot-scripts/myscreenshot.sh'
|
||||
#LABELS["#screenshot"]="screenshot"
|
||||
|
||||
################################################################################
|
||||
# do not edit below
|
||||
################################################################################
|
||||
##
|
||||
# Generate menu
|
||||
##
|
||||
function print_menu()
|
||||
{
|
||||
for key in ${!LABELS[@]}
|
||||
do
|
||||
echo "$key ${LABELS}"
|
||||
# echo "$key ${LABELS[$key]}"
|
||||
# my top version just shows the first field in labels row, not two words side by side
|
||||
done
|
||||
}
|
||||
##
|
||||
# Show rofi.
|
||||
##
|
||||
function start()
|
||||
{
|
||||
# print_menu | rofi -dmenu -p "?=>"
|
||||
print_menu | sort | rofi -dmenu -mesg ">>> launch your collection of rofi scripts" -i -p " "
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Run it
|
||||
value="$(start)"
|
||||
|
||||
# Split input.
|
||||
# grab upto first space.
|
||||
choice=${value%%\ *}
|
||||
# graph remainder, minus space.
|
||||
input=${value:$((${#choice}+1))}
|
||||
|
||||
##
|
||||
# Cancelled? bail out
|
||||
##
|
||||
if test -z ${choice}
|
||||
then
|
||||
exit
|
||||
fi
|
||||
|
||||
# check if choice exists
|
||||
if test ${COMMANDS[$choice]+isset}
|
||||
then
|
||||
# Execute the choice
|
||||
eval echo "Executing: ${COMMANDS[$choice]}"
|
||||
eval ${COMMANDS[$choice]}
|
||||
else
|
||||
eval $choice | rofi
|
||||
# prefer my above so I can use this same script to also launch apps like geany or leafpad etc (DK)
|
||||
# echo "Unknown command: ${choice}" | rofi -dmenu -p "error"
|
||||
fi
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
#!/bin/bash
|
||||
action=$(echo close | rofi -dmenu -p "Google: ")
|
||||
|
||||
search () {
|
||||
query=$1
|
||||
index=$2
|
||||
|
||||
sel=$(printf "$(googler -n 15 -s $2 --json $1 | jq '.[].url' | sed -e 's/^"//' -e 's/"$//')\nMore\n" | rofi -dmenu)
|
||||
|
||||
case $sel in
|
||||
"") exit ;;
|
||||
"More") search $query $(expr $index + 15) ;;
|
||||
*) chromium --new-tab $sel ;;
|
||||
esac
|
||||
}
|
||||
|
||||
search $action 0
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
# _ _ _ _
|
||||
# __ _ ___ | |_| |__ | | ___| |_ _ _
|
||||
# / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
|
||||
#| (_| | (_) | |_| |_) | | __/ |_| |_| |
|
||||
# \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
|
||||
# |___/
|
||||
# https://www.youtube.com/user/gotbletu
|
||||
# https://twitter.com/gotbletu
|
||||
# https://plus.google.com/+gotbletu
|
||||
# https://github.com/gotbletu
|
||||
# gotbleu@gmail.com
|
||||
|
||||
# info: rofi-locate is a script to search local files and folders on your computer using the locate command and the updatedb database
|
||||
# requirements: rofi mlocate
|
||||
# playlist: rofi https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m
|
||||
|
||||
xdg-open "$(locate home media | rofi -threads 0 -width 100 -dmenu -i -p "locate:")"
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
#!/bin/bash
|
||||
|
||||
#when set to exit, mpd_control will exit if you press escape
|
||||
#when set to break, mpd_control will go the upper level if possible
|
||||
ESC_ACTION="break"
|
||||
# source configuration file for rofi if exists
|
||||
|
||||
ROFI="rofi -dmenu -p 'Search : '"
|
||||
|
||||
addaftercurrent(){
|
||||
|
||||
#playlist is empty, just add the song
|
||||
if [ "$(mpc -p 6600 playlist | wc -l)" == "0" ]; then
|
||||
mpc -p 6600 add "$1"
|
||||
|
||||
#there is no current song so mpd is stopped
|
||||
#it seems to be impossible to determine the current songs' position when
|
||||
#mpd is stopped, so just add to the end
|
||||
elif [ -z "$(mpc -p 6600 current)" ]; then
|
||||
mpc -p 6600 play
|
||||
CUR_POS=$(mpc -p 6600 | tail -2 | head -1 | awk '{print $2}' | sed 's/#//' | awk -F/ '{print $1}')
|
||||
END_POS=$(mpc -p 6600 playlist | wc -l)
|
||||
mpc -p 6600 add "$1"
|
||||
mpc -p 6600 move $(($END_POS+1)) $(($CUR_POS+1))
|
||||
mpc -p 6600 stop
|
||||
|
||||
#at least 1 song is in the playlist, determine the position of the
|
||||
#currently played song and add $1 after it
|
||||
else
|
||||
|
||||
CUR_POS=$(mpc -p 6600 | tail -2 | head -1 | awk '{print $2}' | sed 's/#//' | awk -F/ '{print $1}')
|
||||
END_POS=$(mpc -p 6600 playlist | wc -l)
|
||||
mpc -p 6600 add "$1"
|
||||
mpc -p 6600 move $(($END_POS+1)) $(($CUR_POS+1))
|
||||
fi
|
||||
}
|
||||
addaftercurrentandplay(){
|
||||
|
||||
#playlist is empty, just add the song
|
||||
if [ "$(mpc -p 6600 playlist | wc -l)" == "0" ]; then
|
||||
mpc -p 6600 add "$1"
|
||||
mpc -p 6600 play
|
||||
|
||||
#there is no current song so mpd is stopped
|
||||
#it seems to be impossible to determine the current songs' position when
|
||||
#mpd is stopped, so just add to the end
|
||||
elif [ -z "$(mpc -p 6600 current)" ]; then
|
||||
mpc -p 6600play
|
||||
CUR_POS=$(mpc -p 6600 | tail -2 | head -1 | awk '{print $2}' | sed 's/#//' | awk -F/ '{print $1}')
|
||||
END_POS=$(mpc -p 6600 playlist | wc -l)
|
||||
mpc -p 6600 add "$1"
|
||||
mpc -p 6600 move $(($END_POS+1)) $(($CUR_POS+1))
|
||||
mpc -p 6600 play $(($CUR_POS+1))
|
||||
|
||||
#at least 1 song is in the playlist, determine the position of the
|
||||
#currently played song and add $1 after it
|
||||
else
|
||||
|
||||
CUR_POS=$(mpc -p 6600 | tail -2 | head -1 | awk '{print $2}' | sed 's/#//' | awk -F/ '{print $1}')
|
||||
END_POS=$(mpc -p 6600 playlist | wc -l)
|
||||
mpc -p 6600 add "$1"
|
||||
mpc -p 6600 move $(($END_POS+1)) $(($CUR_POS+1))
|
||||
mpc -p 6600 play $(($CUR_POS+1))
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
|
||||
-a|--artist)
|
||||
|
||||
while true; do
|
||||
|
||||
ARTIST="$(mpc -p 6600 list artist | sort -f | $ROFI)";
|
||||
if [ "$ARTIST" = "" ]; then $ESC_ACTION; fi
|
||||
|
||||
while true; do
|
||||
|
||||
ALBUMS=$(mpc -p 6600 list album artist "$ARTIST" | sort -f);
|
||||
ALBUM=$(echo -e "replace all\nadd all\n--------------------------\n$ALBUMS" | $ROFI);
|
||||
if [ "$ALBUM" = "" ]; then $ESC_ACTION;
|
||||
|
||||
elif [ "$ALBUM" = "replace all" ]; then
|
||||
CUR_SONG=$(mpc -p 6600 current)
|
||||
mpc -p 6600 clear
|
||||
mpc -p 6600 find artist "$ARTIST" | mpc -p 6600 add
|
||||
if [ -n "$CUR_SONG" ]; then mpc -p 6600 play; fi
|
||||
$ESC_ACTION
|
||||
elif [ "$ALBUM" = "add all" ]; then
|
||||
mpc -p 6600 find artist "$ARTIST" | mpc -p 6600 add
|
||||
$ESC_ACTION
|
||||
fi
|
||||
|
||||
while true; do
|
||||
|
||||
TITLES=$(mpc -p 6600 list title artist "$ARTIST" album "$ALBUM")
|
||||
TITLE=$(echo -e "replace all\nadd all\n--------------------------\n$TITLES" | $ROFI);
|
||||
if [ "$TITLE" = "" ]; then $ESC_ACTION
|
||||
elif [ "$TITLE" = "replace all" ]; then
|
||||
CUR_SONG=$(mpc -p 6600 current)
|
||||
mpc -p 6600 clear;
|
||||
mpc -p 6600 find artist "$ARTIST" album "$ALBUM" | mpc -p 6600 add
|
||||
if [ -n "$CUR_SONG" ]; then mpc -p 6600 play; fi
|
||||
$ESC_ACTION
|
||||
elif [ "$TITLE" = "add all" ]; then
|
||||
mpc -p 6600 find artist "$ARTIST" album "$ALBUM" | mpc -p 6600 add
|
||||
$ESC_ACTION
|
||||
|
||||
fi
|
||||
|
||||
while true; do
|
||||
DEC=$(echo -e "add after current and play\nadd after current\nreplace\nadd at the end" | $ROFI);
|
||||
case $DEC in
|
||||
|
||||
"")
|
||||
$ESC_ACTION
|
||||
;;
|
||||
|
||||
"add after current and play")
|
||||
addaftercurrentandplay "$(mpc -p 6600 find artist "$ARTIST" album "$ALBUM" title "$TITLE" | head -1 )"
|
||||
;;
|
||||
|
||||
"add after current")
|
||||
addaftercurrent "$(mpc -p 6600 find artist "$ARTIST" album "$ALBUM" title "$TITLE" | head -1 )"
|
||||
;;
|
||||
|
||||
"replace")
|
||||
CUR_SONG=$(mpc -p 6600 current)
|
||||
mpc -p 6600 clear
|
||||
mpc -p 6600 find artist "$ARTIST" album "$ALBUM" title "$TITLE" | head -1 | mpc -p 6600 add
|
||||
if [ -n "$CUR_SONG" ]; then mpc -p 6600 play; fi
|
||||
;;
|
||||
|
||||
"add at the end")
|
||||
mpc -p 6600 find artist "$ARTIST" album "$ALBUM" title "$TITLE" | head -1 | mpc -p 6600 add
|
||||
;;
|
||||
|
||||
esac
|
||||
$ESC_ACTION
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
;;
|
||||
|
||||
-t|--track)
|
||||
|
||||
TITLE=$(mpc -p 6600 list title | sort -f | $ROFI)
|
||||
if [ "$TITLE" = "" ]; then exit; fi
|
||||
|
||||
SONG=$(mpc -p 6600 find title "$TITLE" | head -1)
|
||||
addaftercurrentandplay "$SONG"
|
||||
;;
|
||||
|
||||
-p|--playlist)
|
||||
PLAYLIST=$(mpc -p 6600 lsplaylists | $ROFI);
|
||||
if [ "$PLAYLIST" = "" ]; then exit; fi
|
||||
CUR_SONG=$(mpc -p 6600 current)
|
||||
mpc -p 6600 clear
|
||||
mpc -p 6600 load "$PLAYLIST";
|
||||
if [ -n "$CUR_SONG" ]; then mpc -p 6600 play; fi
|
||||
;;
|
||||
|
||||
-j|--jump)
|
||||
|
||||
TITLE=$(mpc -p 6600 playlist | $ROFI);
|
||||
if [ "$TITLE" = "" ]; then exit; fi
|
||||
POS=$(mpc -p 6600 playlist | grep -n "$TITLE" | awk -F: '{print $1}')
|
||||
mpc -p 6600 play $POS;
|
||||
;;
|
||||
|
||||
-l|--longplayer)
|
||||
|
||||
while true; do
|
||||
|
||||
ALBUM=$(mpc -p 6600 list album | sort -f | $ROFI);
|
||||
if [ "$ALBUM" = "" ]; then $ESC_ACTION;
|
||||
fi
|
||||
|
||||
while true; do
|
||||
|
||||
TITLES=$(mpc -p 6600 list title album "$ALBUM")
|
||||
TITLE=$(echo -e "replace all\nadd all\n--------------------------\n$TITLES" | $ROFI);
|
||||
if [ "$TITLE" = "" ]; then $ESC_ACTION
|
||||
elif [ "$TITLE" = "replace all" ]; then
|
||||
CUR_SONG=$(mpc -p 6600 current)
|
||||
mpc -p 6600 clear;
|
||||
mpc -p 6600 find album "$ALBUM" | mpc -p 6600 add
|
||||
if [ -n "$CUR_SONG" ]; then mpc -p 6600 play; fi
|
||||
$ESC_ACTION
|
||||
elif [ "$TITLE" = "add all" ]; then
|
||||
mpc -p 6600 find album "$ALBUM" | mpc -p 6600 add
|
||||
$ESC_ACTION
|
||||
|
||||
fi
|
||||
|
||||
while true; do
|
||||
DEC=$(echo -e "add after current and play\nadd after current\nreplace\nadd at the end" | $ROFI);
|
||||
case $DEC in
|
||||
|
||||
"")
|
||||
$ESC_ACTION
|
||||
;;
|
||||
|
||||
"add after current and play")
|
||||
addaftercurrentandplay "$(mpc -p 6600 find album "$ALBUM" title "$TITLE" | head -1 )"
|
||||
;;
|
||||
|
||||
"add after current")
|
||||
addaftercurrent "$(mpc -p 6600 find album "$ALBUM" title "$TITLE" | head -1 )"
|
||||
;;
|
||||
|
||||
"replace")
|
||||
CUR_SONG=$(mpc -p 6600 current)
|
||||
mpc -p 6600 clear
|
||||
mpc -p 6600 find album "$ALBUM" title "$TITLE" | head -1 | mpc -p 6600 add
|
||||
if [ -n "$CUR_SONG" ]; then mpc -p 6600 play; fi
|
||||
;;
|
||||
|
||||
"add at the end")
|
||||
mpc -p 6600 find album "$ALBUM" title "$TITLE" | head -1 | mpc -p 6600 add
|
||||
;;
|
||||
|
||||
esac
|
||||
$ESC_ACTION
|
||||
done
|
||||
done
|
||||
done
|
||||
;;
|
||||
|
||||
-h|--help)
|
||||
echo "-a, --artist search for artist, then album, then title"
|
||||
echo "-t, --track search for a single track in the whole database"
|
||||
echo "-p, --playlist search for a playlist load it"
|
||||
echo "-j, --jump jump to another song in the current playlist"
|
||||
echo "-l, --longplayer search for album, then title"
|
||||
|
||||
|
||||
|
||||
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: rofi-mpd [OPTION]"
|
||||
echo "Try 'rofi-mpd --help' for more information."
|
||||
;;
|
||||
|
||||
esac
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
#!/bin/bash
|
||||
# _ _ _ _
|
||||
# __ _ ___ | |_| |__ | | ___| |_ _ _
|
||||
# / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
|
||||
#| (_| | (_) | |_| |_) | | __/ |_| |_| |
|
||||
# \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
|
||||
# |___/
|
||||
# https://www.youtube.com/user/gotbletu
|
||||
# https://twitter.com/gotbletu
|
||||
# https://plus.google.com/+gotbletu
|
||||
# https://github.com/gotbletu
|
||||
# gotbleu@gmail.com
|
||||
|
||||
# info: rofi-surfraw-bookmarks is a script to open your saved surfraw bookmarks with the rofi launcher
|
||||
# requirements: rofi surfraw
|
||||
# playlist: rofi https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m
|
||||
# surfraw https://www.youtube.com/playlist?list=PLqv94xWU9zZ2e-lDbmBpdASA6A6JF4Nyz
|
||||
|
||||
# set your browser (uncomment if needed, some GUI does not detect browser variable)
|
||||
BROWSER=chromium
|
||||
|
||||
surfraw -browser=$BROWSER "$(cat ~/.config/surfraw/bookmarks | sed '/^$/d' | sed '/^#/d' | sed '/^\//d' | sort -n | rofi -dmenu -mesg ">>> Edit to add new bookmarks at ~/.config/surfraw/bookmarks" -i -p "rofi-surfraw-bookmarks: ")"
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
# _ _ _ _
|
||||
# __ _ ___ | |_| |__ | | ___| |_ _ _
|
||||
# / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
|
||||
#| (_| | (_) | |_| |_) | | __/ |_| |_| |
|
||||
# \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
|
||||
# |___/
|
||||
# https://www.youtube.com/user/gotbletu
|
||||
# https://twitter.com/gotbletu
|
||||
# https://plus.google.com/+gotbletu
|
||||
# https://github.com/gotbletu
|
||||
# gotbleu@gmail.com
|
||||
|
||||
# info: rofi-surfraw-websearch is a script to do internet searches from different websites, all from the rofi launcher
|
||||
# requirements: rofi surfraw
|
||||
# playlist: rofi https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m
|
||||
# surfraw https://www.youtube.com/playlist?list=PLqv94xWU9zZ2e-lDbmBpdASA6A6JF4Nyz
|
||||
|
||||
# set your browser (uncomment if needed, some GUI does not detect browser variable)
|
||||
BROWSER=chromium
|
||||
|
||||
surfraw -browser=$BROWSER $(sr -elvi | awk -F'-' '{print $1}' | sed '/:/d' | awk '{$1=$1};1' | rofi -kb-row-select "Tab" -kb-row-tab "Control+space" -dmenu -mesg ">>> Tab = Autocomplete" -i -p "rofi-surfraw-websearch: ")
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import time
|
||||
import sys
|
||||
|
||||
warn = int(sys.argv[1])
|
||||
|
||||
def get(command):
|
||||
return subprocess.check_output(command).decode("utf-8")
|
||||
|
||||
def convert(t):
|
||||
# convert set time into a calculate- able time
|
||||
return [int(n) for n in t.split(":")]
|
||||
|
||||
def calc_diff(t_curr, t_event):
|
||||
# calculate time span
|
||||
diff_hr = (t_event[0] - t_curr[0])*60
|
||||
diff_m = t_event[1] - t_curr[1]
|
||||
return diff_hr + diff_m
|
||||
|
||||
def cleanup(done, newlist):
|
||||
# clean up "done" -lists
|
||||
for item in done:
|
||||
if not item in newlist:
|
||||
done.remove(item)
|
||||
return done
|
||||
|
||||
def show_time(event, s = ""):
|
||||
# show scheduled event
|
||||
hrs = str(event[0][0]); mnts = str(event[0][1])
|
||||
mnts = "0"+mnts if len(mnts) != 2 else mnts
|
||||
subprocess.call(["notify-send", s, "At "+hrs+":"+mnts+" - "+event[1]])
|
||||
|
||||
startups = []; times = []
|
||||
|
||||
while True:
|
||||
currtime = convert(time.strftime("%H:%M"))
|
||||
events = [l.strip() for l in get(["calcurse", "-a"]).splitlines()][1:]
|
||||
# arrange event data:
|
||||
groups = []; sub = []
|
||||
for l in events:
|
||||
if l.startswith("* "):
|
||||
groups.append([l.replace("* ", "")])
|
||||
elif l.startswith("- "):
|
||||
sub.append(convert(l.split("->")[0].replace("-", "").strip()))
|
||||
else:
|
||||
groups.append(sub+[l])
|
||||
sub = []
|
||||
# run notifications
|
||||
for item in groups:
|
||||
# on startup:
|
||||
if not item in startups:
|
||||
# all- day events
|
||||
if len(item) == 1:
|
||||
subprocess.call(["notify-send", "Today - "+item[0]])
|
||||
# time- specific events
|
||||
elif len(item) == 2:
|
||||
show_time(item, "Appointment")
|
||||
startups.append(item)
|
||||
# as a reminder:
|
||||
if all([len(item) == 2, not item in times]):
|
||||
span = calc_diff(currtime, item[0])
|
||||
if span <= warn:
|
||||
show_time(item, "[Reminder]")
|
||||
times.append(item)
|
||||
# clean up events
|
||||
startups = cleanup(startups, groups); times = cleanup(times, groups)
|
||||
time.sleep(30)
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
#!/bin/sh
|
||||
|
||||
# █▓▒░ tmux status
|
||||
# by xero <http://xero.nu>
|
||||
# http://git.io/.files
|
||||
|
||||
FULL=▓
|
||||
EMPTY=░
|
||||
EOL=▒
|
||||
SIZE=7
|
||||
C0="#000000"
|
||||
C1="#222222"
|
||||
C2="#1C596E"
|
||||
C3="#B3291C"
|
||||
C4="#3A3A3A"
|
||||
C5="#efefef"
|
||||
C6="#878787"
|
||||
C7="#CBB3A0"
|
||||
|
||||
draw()
|
||||
{
|
||||
perc=$1
|
||||
SIZE=$2
|
||||
inc=$(( perc * SIZE / 100 ))
|
||||
out=
|
||||
thiscolor=
|
||||
for v in `seq 0 $(( SIZE - 1 ))`; do
|
||||
test "$v" -le "$inc" \
|
||||
&& out="${out}#[fg=$C1]${FULL}" \
|
||||
|| out="${out}#[fg=$C1]${EMPTY}"
|
||||
done
|
||||
echo $out
|
||||
}
|
||||
mail()
|
||||
{
|
||||
gmaildir=/home/hate/.Mail/Gmail/INBOX/new
|
||||
prog=/usr/bin/offlineimap
|
||||
count=0
|
||||
log=/tmp/mails.log
|
||||
|
||||
if [ -x $prog ] ; then
|
||||
|
||||
$prog 2>/dev/null &
|
||||
wait
|
||||
|
||||
if [ $? = 0 ] ; then
|
||||
echo "$(date) - $prog success" >> $log
|
||||
elif [ $? = 1 ] ; then
|
||||
echo "$(date) - $prog has fail" >> $log
|
||||
else
|
||||
echo "$(date) - unknown prob" >> $log
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -d ${gmaildir} ]] ; then
|
||||
echo "$(date) - $gmaildir does not exist" >> $log
|
||||
elif [[ ! -n $(ls "${gmaildir}") ]] ; then
|
||||
echo "$(date) - $gmaildir no new mail found" >> $log
|
||||
else
|
||||
count=$(ls -1 "${gmaildir}" | wc -l)
|
||||
fi
|
||||
|
||||
echo "▓ ✉ ${count} ▓"
|
||||
}
|
||||
weather()
|
||||
{
|
||||
|
||||
APIKEY="99e2d54517287c6de1e9db99db2fdc84"
|
||||
CITY_ID="659181" # customise this for your city
|
||||
URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}"
|
||||
|
||||
WEATHER_RESPONSE=$(wget -qO- "${URL}")
|
||||
|
||||
WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g')
|
||||
WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp')
|
||||
WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg')
|
||||
WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed')
|
||||
|
||||
#WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}")
|
||||
WIND_SPEED=$(awk "BEGIN {print $WIND_SPEED}")
|
||||
WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}")
|
||||
DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N )
|
||||
WIND_DIR=${DIR_ARRAY[WIND_DIR]}
|
||||
|
||||
case $WEATHER_CONDITION in
|
||||
'Clouds')
|
||||
WEATHER_ICON="☁"
|
||||
;;
|
||||
'Rain')
|
||||
WEATHER_ICON="☔"
|
||||
;;
|
||||
'Snow')
|
||||
WEATHER_ICON="☃"
|
||||
;;
|
||||
*)
|
||||
WEATHER_ICON="☀"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${WEATHER_ICON} ${WEATHER_TEMP}°C "
|
||||
}
|
||||
pkg()
|
||||
{
|
||||
#!/bin/bash
|
||||
pac=$(checkupdates | wc -l)
|
||||
aur=$(cower -u | wc -l)
|
||||
|
||||
check=$((pac + aur))
|
||||
if [[ "$check" != "0" ]]
|
||||
then
|
||||
echo "▓ Upg:$pac/$aur"
|
||||
fi
|
||||
}
|
||||
temp()
|
||||
{
|
||||
t=$(sensors | awk '/Core\ 0/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3) ; print $3}')
|
||||
tc=$C0
|
||||
case 1 in
|
||||
$((t <= 50)))
|
||||
tc=$C2
|
||||
;;
|
||||
$((t >= 75)))
|
||||
tc=$C3
|
||||
;;
|
||||
esac
|
||||
echo "#[fg=$tc]$t°c"
|
||||
}
|
||||
bat()
|
||||
{
|
||||
BATPATH=/sys/class/power_supply/CMB1
|
||||
STATUS=$BATPATH/status
|
||||
BAT_FULL=$BATPATH/charge_full
|
||||
BAT_NOW=$BATPATH/charge_now
|
||||
bf=$(cat $BAT_FULL)
|
||||
bn=$(cat $BAT_NOW)
|
||||
stat=$(cat $STATUS)
|
||||
case $stat in
|
||||
Full)
|
||||
st="="
|
||||
;;
|
||||
Discharging)
|
||||
st="-"
|
||||
;;
|
||||
Charging)
|
||||
st="+"
|
||||
;;
|
||||
esac
|
||||
echo "Bat: $st$(( 100 * $bn / $bf ))"%""
|
||||
}
|
||||
cpu()
|
||||
{
|
||||
CPU_USE=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}')
|
||||
printf "%.0f" $CPU_USE
|
||||
}
|
||||
ram()
|
||||
{
|
||||
free | awk '/Mem:/ {print int($3/$2 * 100.0)}'
|
||||
}
|
||||
clock()
|
||||
{
|
||||
mtime=$(date +'%H:%M')
|
||||
myear=$(date +'%m-%Y')
|
||||
mday=$(date +'%d-')
|
||||
echo "#[fg=$C5]#[bg=$C4] $mtime #[fg=$C5]$mday#[fg=$C6]$myear #[fg=$C6]$EOL"
|
||||
}
|
||||
front()
|
||||
{
|
||||
echo "▓░"
|
||||
#echo "#[bg=$C7]#[fg=$C1]▓░"
|
||||
}
|
||||
CPU_INFO=`cpu`
|
||||
RAM_INFO=`ram`
|
||||
echo `front` `weather` `pkg` `mail` `bat` `draw $RAM_INFO 4` `temp` `draw $CPU_INFO 7` `clock`
|
||||
#echo `front` `weather` `pkg` `mail` `temp` `clock`
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
xinput set-prop 14 307 1
|
||||
xinput set-prop 9 289 1
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Script to set colors generated by 'wal'
|
||||
# https://github.com/dylanaraps/wal
|
||||
|
||||
# Source generated colors.
|
||||
. "${HOME}/.cache/wal/colors.sh"
|
||||
|
||||
reload_dunst() {
|
||||
pkill dunst
|
||||
dunst \
|
||||
-lb "${color0:-#FFFFFF}" \
|
||||
-nb "${color1:-#FFFFFF}" \
|
||||
-cb "${color2:-#FFFFFF}" \
|
||||
-lf "${color0:-#000000}" \
|
||||
-bf "${color0:-#000000}" \
|
||||
-cf "${color0:-#000000}" \
|
||||
-nf "${color0:-#000000}" \
|
||||
-fn "Envy Code R 10" &
|
||||
}
|
||||
|
||||
main() {
|
||||
reload_dunst &
|
||||
# set_scss &
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -21,10 +21,6 @@ set_from_resource $coloru i3wm.color2 "#7B8349"
|
|||
set_from_resource $color0 i3wm.color0 "#fbf8f1"
|
||||
set_from_resource $color8 i3wm.color8 "#8a8061"
|
||||
|
||||
#set $video --no-startup-id bash ~/.config/Scripts/video.sh
|
||||
#set $stoprec --no-startup-id killall ffmpeg & killall screenkey
|
||||
#set $flash --no-startup-id bash ~/.config/Scripts/flash_win.sh
|
||||
|
||||
# Use Mouse+$mod to drag floating windows
|
||||
floating_modifier $mod
|
||||
|
||||
|
|
@ -36,14 +32,6 @@ bindsym Mod1+e layout toggle split
|
|||
#Sticky window
|
||||
bindsym $mod+Shift+s sticky toggle
|
||||
|
||||
# Set colors from Xresources
|
||||
# Change 'color7' and 'color2' to whatever colors you want i3 to use
|
||||
# from the generated scheme.
|
||||
# NOTE: The '#f0f0f0' in the lines below is the color i3 will use if
|
||||
# it fails to get colors from Xresources.
|
||||
#set_from_resource $fg i3wm.color6 #f0f0f0
|
||||
#set_from_resource $bg i3wm.color3 #f0f0f0
|
||||
|
||||
######### COLORS ##########
|
||||
#
|
||||
# class border backgr text indicator child_border
|
||||
|
|
@ -56,11 +44,11 @@ client.background $color0
|
|||
|
||||
###---Starting External Scripts---###
|
||||
|
||||
|
||||
#Twmn
|
||||
exec --no-startup-id twmnd &
|
||||
#Album art for mpd/mopidy
|
||||
#exec --no-startup-id bum &
|
||||
exec --no-startup-id killall python ~/.local/bin/bum
|
||||
exec --no-startup-id python ~/.local/bin/bum &
|
||||
#Mpdscribble
|
||||
#exec --no-startup-id mpdscribble --no-daemon &
|
||||
#Conky
|
||||
|
|
@ -81,8 +69,6 @@ exec --no-startup-id conky -d -c ~/.config/conky/conkybg &
|
|||
bindsym $mod+b exec --no-startup-id pkill compton
|
||||
bindsym $mod+Ctrl+b exec --no-startup-id compton -b -f
|
||||
exec --no-startup-id compton -b
|
||||
#Refresh bash/ranger shortcuts:
|
||||
#exec --no-startup-id python ~/.config/Scripts/shortcuts.py
|
||||
#Gnome privileges
|
||||
exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
|
||||
#Urxvt daemon
|
||||
|
|
@ -132,7 +118,6 @@ set $dec --no-startup-id amixer sset Master 2%-
|
|||
set $bigdec --no-startup-id amixer sset Master 5%-
|
||||
set $mute --no-startup-id amixer sset Master toggle
|
||||
set $truemute --no-startup-id amixer sset Master mute
|
||||
#set $screencast --no-startup-id bash ~/.config/Scripts/screencast_alsa.sh
|
||||
#set $audio --no-startup-id bash ~/.config/Scripts/audio_alsa.sh
|
||||
|
||||
#For PULSEAUDIO/PAMIXER
|
||||
|
|
@ -146,7 +131,6 @@ set $truemute --no-startup-id amixer sset Master mute
|
|||
#set $screencast --no-startup-id bash ~/.config/Scripts/screencast_pulse.sh
|
||||
#set $audio --no-startup-id bash ~/.config/Scripts/audio_pulse.sh
|
||||
|
||||
|
||||
###---Dropdown/Scratchpad Windows---###
|
||||
#First I have a tmux window used for background scripts.
|
||||
#I'll later bind this to mod+u.
|
||||
|
|
@ -319,7 +303,7 @@ bindsym $mod+Shift+6 move container to workspace $ws6; workspace $ws6
|
|||
bindsym $mod+Shift+7 move container to workspace $ws7; workspace $ws7
|
||||
bindsym $mod+Shift+8 move container to workspace $ws8; workspace $ws8
|
||||
bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9
|
||||
bindsym $mod+Shift+=0 move container to workspace $ws10; workspace $ws10
|
||||
bindsym $mod+Shift+0 move container to workspace $ws10; workspace $ws10
|
||||
|
||||
for_window [class="Google-chrome"] move to workspace $ws2
|
||||
for_window [class="Firefox"] move to workspace $ws2
|
||||
|
|
@ -359,6 +343,10 @@ bindsym $mod+Shift+Down move down
|
|||
bindsym $mod+Shift+Up move up
|
||||
bindsym $mod+Shift+Right move right
|
||||
|
||||
#Backlight keys
|
||||
bindsym Mod1+plus exec light -A 5
|
||||
bindsym Mod1+minus exec light -U 5
|
||||
|
||||
###---Media Keys---###
|
||||
|
||||
#Volume keys
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ set autoread " refresh file
|
|||
syntax on
|
||||
|
||||
" set the runtime path to include Vundle and initialize
|
||||
"set rtp+=~/.config/nvim/bundle/Vundle.vim
|
||||
"call vundle#begin('~/.config/nvim/bundle')
|
||||
"Plugin 'VundleVim/Vundle.vim'
|
||||
"call vundle#end()
|
||||
set rtp+=~/.config/nvim/bundle/Vundle.vim
|
||||
call vundle#begin('~/.config/nvim/bundle')
|
||||
Plugin 'VundleVim/Vundle.vim'
|
||||
call vundle#end()
|
||||
|
||||
filetype plugin indent on " allows auto-indenting depending on file type
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ message_delay_time = "3"
|
|||
#song_list_format = "{$5%a} $2»$8»$5» {$8%t}|{$8%f}$R{$2%b}"
|
||||
#song_list_format = " $7%l $2%t $R$5%a "
|
||||
#uncomment both statement's below if you want to display the albumart
|
||||
song_list_format = " $7%l $2%t $R$5%a "
|
||||
#song_list_format = " $7%l $2%t $R$5%a "
|
||||
#uncomment both statement's below if you want to display the albumart
|
||||
#execute_on_song_change="~/.ncmpcpp/art.sh"
|
||||
#song_list_format = " $2%t $R$5%a "
|
||||
|
|
@ -505,5 +505,7 @@ visualizer_color = 246,245,244,243,242,241,240,239,238,237,236,235
|
|||
#
|
||||
active_window_border = "red"
|
||||
#
|
||||
execute_on_song_change = twmnc -c "Now Playing ♫ $(mpc current)"
|
||||
execute_on_song_change = ~/.config/Scripts/albumart.sh && twmnc -c "Now Playing ♫ $(mpc current)"
|
||||
#execute_on_song_change="~/.ncmpcpp/art.sh"
|
||||
song_list_format = " $2%t $R$5%a "
|
||||
#execute_on_song_change = python ~/.config/Scripts(mpd_notifier.py
|
||||
|
|
|
|||
Loading…
Reference in New Issue