mirror of
https://github.com/Mastermindzh/dotfiles.git
synced 2025-07-26 12:13:22 +02:00
new rice
This commit is contained in:
74
i3/scripts/blocks/currentSong.py
Normal file
74
i3/scripts/blocks/currentSong.py
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/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")
|
12
i3/scripts/blocks/temp.sh
Normal file
12
i3/scripts/blocks/temp.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
temp=$(sensors | # execute sensors
|
||||
grep -w "Core 0:" | # grep for the first core
|
||||
sed 's/([^)]*)//g' | # filter
|
||||
tr -s " " | # remove whitespace
|
||||
sed -e 's/Core 0\(.*\):/\1/' | # get value between Core 0 and :
|
||||
cut -c 3- | rev | cut -c 7- | rev #remove clutter
|
||||
)
|
||||
|
||||
# echo out the result
|
||||
echo $temp°C
|
16
i3/scripts/brightness.sh
Normal file
16
i3/scripts/brightness.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#! /bin/bash
|
||||
|
||||
displays=($(xrandr | awk '/ connected /{print $1}'))
|
||||
|
||||
if (( ${#displays[@]} > 1 ))
|
||||
then
|
||||
selected_display="$(zenity --list --title 'Select Display' --radiolist --column '' --column 'Display' $(xrandr | awk '/ connected /{print NR,$1}'))"
|
||||
else
|
||||
selected_display="${displays[0]}"
|
||||
fi
|
||||
|
||||
zenity --scale --title "Set brightness of $selected_display" --value=100 --print-partial |
|
||||
while read brightness
|
||||
do
|
||||
xrandr --output "$selected_display" --brightness $(awk '{print $1/100}' <<<"$brightness"})
|
||||
done
|
11
i3/scripts/i3lock.sh
Normal file
11
i3/scripts/i3lock.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
icon="$HOME/.config/i3/icons/lock.png"
|
||||
tmpbg='/tmp/screen.png'
|
||||
|
||||
(( $# )) && { icon=$1; }
|
||||
|
||||
scrot "$tmpbg"
|
||||
convert "$tmpbg" -scale 10% -scale 1000% "$tmpbg"
|
||||
convert "$tmpbg" "$icon" -gravity center -composite -matte "$tmpbg"
|
||||
i3lock -u -i "$tmpbg"
|
3
i3/scripts/screenshot.sh
Normal file
3
i3/scripts/screenshot.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
gnome-screenshot -i
|
8
i3/scripts/startup.sh
Normal file
8
i3/scripts/startup.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# start Google Drive client
|
||||
insync start
|
||||
|
||||
# Wait for the programs to start then remove attention (e.g red blinking)
|
||||
sleep 1
|
||||
wmctrl -r "Enpass" -b remove,demands_attention
|
Reference in New Issue
Block a user