This commit is contained in:
Rick van Lieshout 2019-12-01 16:51:55 +01:00
commit 9c629e44ff
11 changed files with 54 additions and 412 deletions

View File

@ -14,20 +14,20 @@ Older versions:
## Tools
| Purpose | Tool |
| ---------------- | ------------------------------------ |
| WM | i3 (i3-gaps) |
| App launcher | rofi |
| Shell | Bash |
| Package managers | Pacman & Trizen |
| OS | Arch Linux (or Antergos if I'm lazy) |
| Terminal | xfce4-terminal |
| Editor | nano |
| Code editor | vscode / jetbrains stuff |
| Browser | Chromium |
| File manager | If I have to use one ... Nautilus |
| Music | Google Play Music Desktop Player |
| | |
| Purpose | Tool |
| ---------------- | ---------------------------------------------------------------------- |
| WM | i3 (i3-gaps) |
| App launcher | rofi |
| Shell | Bash |
| Package managers | Pacman & Trizen |
| OS | Arch Linux |
| Terminal | xfce4-terminal |
| Editor | nano |
| Code editor | vscode / jetbrains stuff |
| Browser | Chromium |
| File manager | If I have to use one ... Nautilus |
| Music | Tidal through [Tidal-hifi](https://github.com/Mastermindzh/tidal-hifi) |
| | |
## computer specifc setup

View File

@ -31,6 +31,7 @@ alias untangle-line-endings='find ./ -type f -exec dos2unix {} \;'
## pacman and trizen
alias aur='trizen --noconfirm'
alias update='trizen -Syyu --noconfirm'
alias remove-orphans='sudo pacman -Rns $(pacman -Qtdq)'
alias updatekeys='sudo pacman-key --refresh-key'
alias clean-pacmancache='sudo paccache -rk 1 && sudo paccache -ruk0'
@ -51,7 +52,6 @@ alias pia='nohup sh /opt/pia/run.sh &>/dev/null & disown'
alias wifimenu='nm-connection-editor'
alias findcrlf='find . -path node_modules -prune -o -not -type d -exec file "{}" ";" | grep -E "BOM|CRLF"'
alias fixcrlf='findcrlf > /tmp/crlftolf && cat /tmp/crlftolf | while read line; do CUTLINE=$(echo $line | cut -f1 -d":") && dos2unix $CUTLINE; done'
alias mountrick='sudo mount -t cifs //192.168.1.2/Rick /mnt/rick/ -o username=mastermindzh,noexec'
alias enable-wifi='sudo ip link set wlp2s0 up'
alias scan-wifi='sudo iw dev wlp2s0 scan'
alias pretty-json='python -m json.tool'
@ -159,3 +159,21 @@ killport () {
fuser -k $1/tcp
fi
}
# function to switch kubernetes namespace
kubeswitch () {
if [ -z "$1" ] ; then
echo "please specify a namespace to switch to"
else
kubectl config set-context --current --namespace=$1
fi
}
# function to switch to a different azure kubernetes cluster
azkubeswitch () {
if [ -z "$2" ] ; then
echo "please execute with the following params: azkubeswitch {resourcegroupname} {clustername}"
else
az aks get-credentials --resource-group $1 --name $2
fi
}

View File

@ -12,13 +12,6 @@ source ~/.alias
source ~/.custom
source ~/.variables
# Fix .netcore paths if dotnet is installed
if hash dotnet 2>/dev/null; then
export DOTNET_ROOT=/opt/dotnet
export MSBuildSDKsPath=$DOTNET_ROOT/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks
export PATH="${PATH}:${DOTNET_ROOT}:~/.dotnet/tools"
fi
#... :P fancy stuffs
#screenfetch -t -A "UBUNTU"
neofetch

View File

@ -3,3 +3,7 @@ alias dock='bash ~/.docked.sh && i3-msg restart'
alias undock='bash ~/.undocked.sh && i3-msg restart'
alias mountdata='sudo cryptsetup open --type luks /dev/nvme0n1p7 data && sudo mount -t ext4 /dev/mapper/data /home/mastermindzh/data'
alias unmountdata='sudo umount /home/mastermindzh/data && sudo cryptsetup close data && sudo sysctl --write vm.drop_caches=3'
# useful kubernetes (AZURE) commands
alias kubernetes-qa='azkubeswitch Inforit.Cloud InforitCluster'
alias kubernetes-prod='azkubeswitch Inforit.Cloud Production'

View File

@ -9,7 +9,6 @@ otf-droid-sans-mono-powerline-git
downgrade
dive
xorg-xev
spotify
networkmanager-l2tp
snapd
i3blocks-contrib
i3blocks-contrib

View File

@ -39,7 +39,6 @@ set $workspace11 " Virtualbox"
set $workspace12 " Enpass"
# scripts
set $spotify ~/.config/i3/scripts/spotify-cli.sh
set $tidal ~/.config/i3/scripts/tidal-cli.sh
set $vpnmanager ~/.config/i3/scripts/vpn-manager.sh
@ -230,7 +229,6 @@ for_window [title="Tidal-hifi - settings"] floating enable
# Workspace specific tools #
# Use xprop to determine class #
############################################
assign [class="Google Play Music Desktop Player"] $workspace10
assign [class="Franz"] $workspace9
assign [class="Enpass-Desktop"] $workspace12
assign [class="Enpass"] $workspace12

View File

@ -41,12 +41,6 @@ separator_block_width=13
interval=1
color=#4293f5
# [spotify]
# command=bash ~/.config/i3/scripts/blocks/spotify.sh
# separator_block_width=13
# interval=1
# color=#1DB954
[weather]
command=curl wttr.in?format=1
separator_block_width=13
@ -60,12 +54,12 @@ color=#999999
# see the script for details.
[temperature]
command=bash ~/.config/i3/scripts/blocks/temp.sh
label=
label=
interval=1
color=#999999
[load_average]
label=
label=
interval=10
separator=true
color=#999999
@ -74,7 +68,7 @@ color=#999999
#
# The type defaults to "mem" if the instance is not specified.
[memory]
label=
label=
separator=true
interval=30
color=#999999
@ -84,7 +78,7 @@ color=#999999
# The script may be called with a optional argument to set the alert
# (defaults to 10 for 10%).
[disk]
label=
label=
instance=/
interval=5
separator=true
@ -92,7 +86,7 @@ color=#999999
# Updates
[updates]
label=
label=
command=pacman -Qu | wc -l
interval=60
separator=true
@ -104,14 +98,14 @@ color=#999999
# The address can be forced to IPv4 or IPv6 with -4 or -6 switches.
[iface]
#instance=wlan0
label=
label=
color=#0fad3c
interval=10
separator=true
# ping
[ping]
label=
label=
command=ping -c 2 8.8.8.8 | tail -1 | awk '{print $4}' | cut -d '/' -f 2 | cut -f1 -d"."
interval=60
separator=true
@ -123,7 +117,7 @@ color=#999999
# The second parameter overrides the mixer selection
# See the script for details.
[volume]
label=
label=
instance=Master
interval=1
command=/usr/lib/i3blocks/volume/volume 5 pulse
@ -151,7 +145,7 @@ color=#999999
# Date Time
[time]
label=
label=
command=date '+%Y-%m-%d %H:%M:%S'
interval=1
separator=true

View File

@ -1,74 +0,0 @@
#!/usr/bin/python
import json
from os.path import expanduser
import sys
import argparse
home = expanduser("~")
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description="Parses and print Google Play Music Desktop Player song info")
def parseJson():
try:
with open(home + '/.config/Google Play Music Desktop Player/json_store/playback.json') as f:
data = f.read()
except:
with open(home + '/GPMDP_STORE/playback.json') as f:
data = f.read()
return json.loads(data)
def getSong(data):
return data['song']['title']
def getAlbum(data):
return data['song']['album']
def getArtist(data):
return data['song']['artist']
def convert_time(ms):
x = ms / 1000
x % 60
m, s = divmod(x, 60)
return "%d:%02d" % (m, s)
def getProgress(data):
cur = data['time']['current']
total = data['time']['total']
return convert_time(cur) + "/" + convert_time(total)
def parseLayout(layout):
displaystr = ""
for i in layout:
if i == 't':
displaystr += getSong(data)
elif i == 'a':
displaystr += getAlbum(data)
elif i == 'A':
displaystr += getArtist(data)
elif i == 'p':
displaystr += getProgress(data)
elif i == '-':
displaystr += " - "
return displaystr
def run(data, layout):
displaystr = ""
if data['playing']:
displaystr = parseLayout(layout)
else:
sys.stdout.write(" ")
if sys.version[0] == '2':
print(displaystr.encode('utf-8'))
else:
print(displaystr)
parser.add_argument("--layout",
action="store",
dest="layout",
help="t = Song Title\na = Song Album\nA = Artist Name\np = Track time progess\n- = Spacer\nExample: t-a-A-p",
)
args = parser.parse_args()
data = parseJson()
try:
run(data, args.layout)
except:
run(data, "t-a-A-p")

View File

@ -1,14 +0,0 @@
#!/bin/bash
case $BLOCK_BUTTON in
1) ~/.config/i3/scripts/spotify-cli.sh play ;; # left click
4) ~/.config/i3/scripts/spotify-cli.sh next ;; # scroll up
5) ~/.config/i3/scripts/spotify-cli.sh prev ;; # scroll down
esac
if ~/.config/i3/scripts/spotify-cli.sh status | grep 'Paused' > /dev/null; then
printf ' ' # fa-pause
else
printf ' ' # fa-play
fi
~/.config/i3/scripts/spotify-cli.sh current-oneline

View File

@ -3,15 +3,15 @@
icon="$HOME/.config/i3/icons/lock.png"
tmpbg='/tmp/screen.png'
# detect whether spotify is running
isPlaying=$(~/.config/i3/scripts/spotify-cli.sh status);
# detect whether tidal is running
isPlaying=$(~/.config/i3/scripts/tidal-cli.sh status);
scrot "$tmpbg"
convert "$tmpbg" -scale 10% -scale 1000% "$tmpbg"
convert "$tmpbg" "$icon" -gravity center -composite -matte "$tmpbg"
# Stop music if playing
~/.config/i3/scripts/spotify-cli.sh pause
~/.config/i3/scripts/tidal-cli.sh pause
# check whether the lockscreen is being activated because of a suspend
if [[ $* == *--suspend ]]; then
@ -21,9 +21,9 @@ else
# if it isn't suspended, enable no-fork
i3lock -n -f -i "$tmpbg";
# if spotify was playing before we locked, resume.
if [ $isPlaying == "Playing" ]; then
~/.config/i3/scripts/spotify-cli.sh play
# if tidal was playing before we locked, resume.
if [ $isPlaying == "playing" ]; then
~/.config/i3/scripts/tidal-cli.sh play
fi;
fi
fi

View File

@ -1,276 +0,0 @@
#!/bin/bash
# CONSTANTS
SP_VERSION="0.1"
SP_DEST="org.mpris.MediaPlayer2.spotify"
SP_PATH="/org/mpris/MediaPlayer2"
SP_MEMB="org.mpris.MediaPlayer2.Player"
# To get SP_ID and SP_SECRET register at
# https://beta.developer.spotify.com/documentation/general/guides/app-settings/
SP_ID="<yout id>"
SP_SECRET="<your secret>"
# SHELL OPTIONS
shopt -s expand_aliases
SP_B64ID=$(echo -n "$SP_ID:$SP_SECRET"|base64)
SP_B64ID=$(echo $SP_B64ID | sed 's/ //g')
# UTILITY FUNCTIONS
function require {
hash $1 2>/dev/null || {
echo >&2 "Error: '$1' is required, but was not found."; exit 1;
}
}
# COMMON REQUIRED BINARIES
# We need dbus-send to talk to Spotify.
require dbus-send
# Assert standard Unix utilities are available.
require grep
require sed
require cut
require tr
# 'SPECIAL' (NON-DBUS-ALIAS) COMMANDS
function sp-dbus {
# Sends the given method to Spotify over dbus.
dbus-send --print-reply --dest=$SP_DEST $SP_PATH $SP_MEMB.$1 ${*:2} > /dev/null
}
function sp-open {
# Opens the given spotify: URI in Spotify.
sp-dbus OpenUri string:$1
}
function sp-metadata {
# Prints the currently playing track in a parseable format.
dbus-send \
--print-reply `# We need the reply.` \
--dest=$SP_DEST \
$SP_PATH \
org.freedesktop.DBus.Properties.Get \
string:"$SP_MEMB" string:'Metadata' \
| grep -Ev "^method" `# Ignore the first line.` \
| grep -Eo '("(.*)")|(\b[0-9][a-zA-Z0-9.]*\b)' `# Filter interesting fiels.`\
| sed -E '2~2 a|' `# Mark odd fields.` \
| tr -d '\n' `# Remove all newlines.` \
| sed -E 's/\|/\n/g' `# Restore newlines.` \
| sed -E 's/(xesam:)|(mpris:)//' `# Remove ns prefixes.` \
| sed -E 's/^"//' `# Strip leading...` \
| sed -E 's/"$//' `# ...and trailing quotes.` \
| sed -E 's/"+/|/' `# Regard "" as seperator.` \
| sed -E 's/ +/ /g' `# Merge consecutive spaces.`
}
function sp-current {
# Prints the currently playing track in a friendly format.
require column
sp-metadata \
| grep --color=never -E "(title)|(album)|(artist)" \
| sed 's/^\(.\)/\U\1/' \
| column -t -s'|'
}
function sp-current-oneline {
sp-metadata | grep -E "(title|artist)" | sed 's/^\(.\)*|//' | sed ':a;N;$!ba;s/\n/ - /g'
}
function sp-status {
dbus-send \
--print-reply \
--dest=$SP_DEST \
$SP_PATH \
org.freedesktop.DBus.Properties.Get \
string:"$SP_MEMB" string:'PlaybackStatus' \
| tail -1 \
| cut -d "\"" -f2
}
function sp-eval {
# Prints the currently playing track as shell variables, ready to be eval'ed
require sort
sp-metadata \
| grep --color=never -E "(title)|(album)|(artist)|(trackid)|(trackNumber)" \
| sort -r \
| sed 's/^\([^|]*\)\|/\U\1/' \
| sed -E 's/\|/="/' \
| sed -E 's/$/"/' \
| sed -E 's/^/SPOTIFY_/'
}
function sp-art {
# Prints the artUrl.
sp-metadata | grep "artUrl" | cut -d'|' -f2
}
function sp-display {
# Calls display on the artUrl.
require display
display $(sp-art)
}
function sp-feh {
# Calls feh on the artURl.
require feh
feh $(sp-art)
}
function sp-url {
# Prints the HTTP url.
TRACK=$(sp-metadata | grep "url" | cut -d'|' -f2 | cut -d':' -f3)
echo "http://open.spotify.com/track/$TRACK"
}
function sp-clip {
# Copies the HTTP url.
require xclip
sp-url | xclip
}
function sp-http {
# xdg-opens the HTTP url.
require xdg-open
xdg-open $(sp-url)
}
function sp-help {
# Prints usage information.
echo "Usage: sp [command]"
echo "Control a running Spotify instance from the command line."
echo ""
echo " sp play - Play/pause Spotify"
echo " sp pause - Pause Spotify"
echo " sp next - Go to next track"
echo " sp prev - Go to previous track"
echo ""
echo " sp current - Format the currently playing track"
echo " sp metadata - Dump the current track's metadata"
echo " sp eval - Return the metadata as a shell script"
echo ""
echo " sp art - Print the URL to the current track's album artwork"
echo " sp display - Display the current album artwork with \`display\`"
echo " sp feh - Display the current album artwork with \`feh\`"
echo ""
echo " sp url - Print the HTTP URL for the currently playing track"
echo " sp clip - Copy the HTTP URL to the X clipboard"
echo " sp http - Open the HTTP URL in a web browser"
echo ""
echo " sp open <uri> - Open a spotify: uri"
echo " sp search <q> - Start playing the best search result for the given query"
echo ""
echo " sp version - Show version information"
echo " sp help - Show this information"
echo ""
echo "Any other argument will start a search (i.e. 'sp foo' will search for foo)."
}
function sp-search {
# Searches for tracks, plays the first result.
require curl
#send request for token with ID and SecretID encoded to base64->grep take only token from reply->trim reply down to token-> modified request to include token in header
Q="$@"
ST=$(curl -H "Authorization: Basic $SP_B64ID" -d grant_type=client_credentials https://accounts.spotify.com/api/token --silent \
| grep -E -o "access_token\":\"[a-zA-Z0-9_-]+\"" -m 1 )
echo $Q
ST2=${ST:15:86}}
SPTFY_URI=$( \
curl -H "Authorization: Bearer $ST2" -s -G --data-urlencode "q=$Q" --data type=artist,track https://api.spotify.com/v1/search/ \
| grep -E -o "spotify:track:[a-zA-Z0-9]+" -m 1 \
)
sp-open $SPTFY_URI
}
function sp-version {
# Prints version information.
echo "sp $SP_VERSION"
echo "Copyright (C) 2013 Wander Nauta"
echo "License MIT"
}
# 'SIMPLE' (DBUS-ALIAS) COMMANDS
alias sp-play=" sp-dbus PlayPause"
alias sp-pause=" sp-dbus Pause"
alias sp-next=" sp-dbus Next"
alias sp-prev=" sp-dbus Previous"
# DISPATCHER
# First, we connect to the dbus session spotify is on. This isn't really needed
# when running locally, but is crucial when we don't have an X display handy
# (for instance, when running sp over ssh.)
SPOTIFY_PID="$(pidof -s spotify)"
if [[ -z "$SPOTIFY_PID" ]]; then
echo "Spotify is not running."
exit 1
fi
QUERY_ENVIRON="$(cat /proc/${SPOTIFY_PID}/environ | tr '\0' '\n' | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"
if [[ "${QUERY_ENVIRON}" != "" ]]; then
export DBUS_SESSION_BUS_ADDRESS="${QUERY_ENVIRON}"
fi
# Then we dispatch the command.
subcommand="$1"
if [[ -z "$subcommand" ]]; then
# No arguments given, print help.
sp-help
else
# Arguments given, check if it's a command.
if $(type sp-$subcommand > /dev/null 2> /dev/null); then
# It is. Run it.
shift
eval "sp-$subcommand $@"
else
# It's not. Try a search.
eval "sp-search $@"
fi
fi
# Copyright (C) 2013 Wander Nauta
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software, to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# The software is provided "as is", without warranty of any kind, express or
# implied, including but not limited to the warranties of merchantability,
# fitness for a particular purpose and noninfringement. In no event shall the
# authors or copyright holders be liable for any claim, damages or other
# liability, whether in an action of contract, tort or otherwise, arising from,
# out of or in connection with the software or the use or other dealings in the
# software.
#