~zenomat/scripts

6f922782f03beb050647c521dae7d4276521632f — zenomat 2 years ago b267106
ready to move
11 files changed, 69 insertions(+), 12 deletions(-)

M LICENSE -rw-r--r-- => -rwxr-xr-x
M dmenu_scripts/dmenu_musicdown.sh
M dmenu_scripts/dmenu_screen.sh
M dmenu_scripts/emoji -rw-r--r-- => -rwxr-xr-x
M dmenu_scripts/error.txt -rw-r--r-- => -rwxr-xr-x
M dmenu_scripts/todo -rw-r--r-- => -rwxr-xr-x
A np
M status
M statusbar/eggtimer -rw-r--r-- => -rwxr-xr-x
M statusbar/timer
M statusbar/vpn -rw-r--r-- => -rwxr-xr-x
M LICENSE => LICENSE +0 -0
M dmenu_scripts/dmenu_musicdown.sh => dmenu_scripts/dmenu_musicdown.sh +4 -4
@@ 1,16 1,16 @@
#!/bin/sh -e

musicdir=/root/music
musicdir=$HOME/media/music

url=$(dmenu -i -p "Song URL (Youtube)" <&-)
title=$(dmenu -i -p "Songtitle (Artist - Title)" <&-)
artist=$(echo $title | awk '{ print $1 }')
album=$(dmenu -i -p "Albumtitle" <&-)

if [ ! -d $musicdir/$artist/$album ]; then
    mkdir -p $musicdir/$artist/$album
if [ ! -d "$musicdir"/"$artist"/"$album" ]; then
    mkdir -p "$musicdir"/"$artist"/"$album"
fi
cd $musicdir/$artist/$album
cd "$musicdir"/"$artist"/"$album"

youtube-dl -x --audio-format mp3 --audio-quality 0 --output "$title.%(ext)s" $url
ffmpeg -i "$title.mp3" -acodec copy -metadata title="$(echo $title | awk -F ' - ' '{ print $2 }')" -metadata artist="$artist" -metadata album="$album" "$title.tmp.mp3"

M dmenu_scripts/dmenu_screen.sh => dmenu_scripts/dmenu_screen.sh +2 -2
@@ 6,9 6,9 @@ choice=$(echo -e $options | dmenu -i -p "Which monitor to capture" || exit 1)

case $choice in
    main*)
	import -window root -crop 1920x1080+1680+0 -quality 100 $HOME/$(date +%Y-%m-%d-%H-%M-%T | sed -e 's/:/-/g')-screenshot.jpg
	import -window root -crop 1920x1080+1920+0 -quality 100 $HOME/$(date +%Y-%m-%d-%H-%M-%T | sed -e 's/:/-/g')-screenshot.jpg
	;;
    secondary*)
	import -window root -crop 1680x1050+0+0 -quality 100 $HOME/$(date +%Y-%m-%d-%H-%M-%T | sed -e 's/:/-/g')-screenshot.jpg
	import -window root -crop 1920x1080+0+0 -quality 100 $HOME/$(date +%Y-%m-%d-%H-%M-%T | sed -e 's/:/-/g')-screenshot.jpg
	;;
esac

M dmenu_scripts/emoji => dmenu_scripts/emoji +0 -0
M dmenu_scripts/error.txt => dmenu_scripts/error.txt +0 -0
M dmenu_scripts/todo => dmenu_scripts/todo +0 -0
A np => np +23 -0
@@ 0,0 1,23 @@
#!/bin/sh

title="$1"
date=$(date "+%F")
sanitize_title=$(echo "$title" | tr "[:upper:]" "[:lower:]" | sed "s/[^[:alnum:]]/-/g" | sed "s/-\+/-/g" | sed "s/^-//g" | sed "s/-$//g")
filename="$date-$sanitize_title.md"
desc=$(</dev/null vipe --suffix md)
tags=""
for i in "${@:2}"; do
	tags="$tags, \"$i\""
done

tags=$(echo $tags | cut -b 3-)

printf '%s\n' "---
layout: posts
title: \"$title\"
author: Zeno
excerpt: \"$desc\"
tags: [$tags]
---" > /home/zeno/code/zenopage-jekyll/_drafts/$filename

$EDITOR /home/zeno/code/zenopage-jekyll/_drafts/$filename

M status => status +39 -5
@@ 2,11 2,17 @@

NOTIFICATION=herbe

killall $NOTIFICATION

function volume() {
    pkill herbe
    device=Master
    devicecontextlines=4
    vol=$(amixer | grep $device -A $devicecontextlines | tail -n1 | awk -F ' ' '{{print $4}}' | sed 's/\[//' | sed 's/\]//')
    volumedevice="DAC"
    mutedevice="Speaker"
    if [[ $(amixer get $mutedevice | tail -n1 | awk -F ' ' '{{print $3}}') == "[on]" ]]; then
	vol=$(amixer get $volumedevice | tail -n1 | awk -F ' ' '{{print $5}}' | sed 's/\[//' | sed 's/\]//')
    else
	vol="Muted"
    fi
    $NOTIFICATION $vol
}



@@ 37,8 43,30 @@ function music() {
	    ;;
    esac
    $NOTIFICATION "$playstatus $(mpc | head -n1)\
    \
    [$(mpc | head -n2 | tail -n1 | awk -F ' ' '{{print $3}}')]"

[$(mpc | head -n2 | tail -n1 | awk -F ' ' '{{print $3}}')]"
}

function battery() {
    state=$(cat /sys/class/power_supply/cw2015-battery/status)
    charge=$(cat /sys/class/power_supply/cw2015-battery/capacity)
    time_to_empty=$(date -d@$(cat /sys/class/power_supply/cw2015-battery/time_to_empty_now) -u +%M:%S)
    if [[ $state == "Discharging" ]]; then
	$NOTIFICATION "$charge%

Time remaining: $time_to_empty h"
    else
	$NOTIFICATION "$charge%

Charging"
    fi
}

function backlight() {
    current=$(cat /sys/class/backlight/edp-backlight/brightness)
    max=$(cat /sys/class/backlight/edp-backlight/max_brightness)
    percent=$(awk -v current="$current" -v max="$max" 'BEGIN{printf "%.0f", (current/max)*100}')
    $NOTIFICATION "Backlight at $percent%"
}

case "$1" in


@@ 57,6 85,12 @@ case "$1" in
    music)
	music
	;;
    battery)
	battery
	;;
    backlight)
	backlight
	;;
esac

exit 0

M statusbar/eggtimer => statusbar/eggtimer +0 -0
M statusbar/timer => statusbar/timer +1 -1
@@ 1,1 1,1 @@
568
773

M statusbar/vpn => statusbar/vpn +0 -0