renew the scripts

This commit is contained in:
Yorick van Pelt 2016-01-31 18:17:44 +01:00
parent 7c79ab3474
commit 3736ff1793
11 changed files with 121 additions and 51 deletions

46
bin/backup.sh Executable file
View file

@ -0,0 +1,46 @@
#!/bin/sh
BACKUP_MACHINE="frumar.yori.cc"
DATE_FORMAT="+%Y-%m-%d"
BACKUP_DIR="/data/yorick/backup"
function is_locked() {
# check for lockfile
if [[ -f /tmp/rbs.lock ]]; then
# process already running?
if [[ "$(ps -p $(cat /tmp/rbs.lock) | wc -l)" -gt 1 ]]; then
echo "locked"
return
fi
fi
echo "unlocked"
}
if [[ $(is_locked) == "locked" ]]; then
echo "process already running, aborting..."
exit 1
fi
# create lockfile
rm -f /tmp/rbs.lock
echo $$ > /tmp/rbs.lock
echo "update local bup index..."
cd $HOME # do it here so that the bupignore paths work without rewriting
ionice -c3 bup index -u $HOME --xdev --exclude-from $HOME/dotfiles/misc/bupignore
# check if backup machine is available
#ping -w 5 -c 1 $BACKUP_MACHINE
#if [ $? -eq 0 ]; then
# start backup
echo "copy bup packs..."
branch="$(hostname)-$(date $DATE_FORMAT)"
ionice -c3 bup save -n $branch $HOME -r $BACKUP_MACHINE:$BACKUP_DIR/home/
#echo "verify bup packs..."
#cd $BACKUP_DIR/home
#ionice -c3 bup -d . fsck -g -vv
#fi
# remove lockfile
rm -f /tmp/rbs.lock

33
bin/byzanz-window Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Delay before starting
DELAY=5
# Sound notification to let one know when recording is about to start (and ends)
beep() {
paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &
}
# Duration and output file
if [ $# -gt 0 ]; then
D="--duration=$@"
else
echo Default recording duration 10s to /tmp/recorded.gif
D="--duration=10 /tmp/recorded.gif"
fi
XWININFO=$(xwininfo)
read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO")
read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO")
read W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO")
read H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO")
echo Delaying $DELAY seconds. After that, byzanz will start
for (( i=$DELAY; i>0; --i )) ; do
echo $i
sleep 1
done
beep
byzanz-record -c --verbose --delay=0 --x=$X --y=$Y --width=$W --height=$H $D
beep

View file

@ -1,16 +1,16 @@
#!/usr/bin/sh
#!/bin/sh
# this script checks if the system is docked with the lid closed
# and if so, sets the correct DPI, disables the laptop screen, sets the DP-3 monitor as primary
# and loads the nvidia config for vsync options and sets the dithering depth to 8
if [ `cat /sys/devices/platform/hp-wmi/dock` -eq 1 ] && [[ `cat /proc/acpi/button/lid/LID/state` == *closed* ]]
if [ `cat /sys/devices/platform/hp-wmi/dock` -eq 1 ] # && [[ `cat /proc/acpi/button/lid/LID/state` == *closed* ]]
then
echo "Using docked configuration with 27\" IPS screen and VGA-screen"
xrandr --output LVDS-0 --off --output DP-3 --primary --output VGA-0 --left-of DP-3 --dpi 108.79/DP-3
nvidia-settings -l -a "0/XVideoSyncToDisplay=1048576"
echo "Xft.dpi: 108.79" | xrdb -merge
xrandr --output DP-3 --primary --preferred --output LVDS-0 --left-of DP-3 --dpi 109/DP-3
nvidia-settings -a "0/XVideoSyncToDisplayID=DP-3"
echo "Xft.dpi: 109" | xrdb -merge
else
echo "Using laptop-only configuration"
xrandr --output LVDS-0 --mode 1920x1080 --primary --rotate normal --pos 0x0 --output VGA-0 --off --output DP-3 --off --dpi 146.86/LVDS-0
nvidia-settings -l
echo "Xft.dpi: 146.86" | xrdb -merge
xrandr --output LVDS-0 --mode 1920x1080 --primary --rotate normal --pos 0x0 --output VGA-0 --off --output DP-3 --off --dpi 146/LVDS-0
nvidia-settings -l -a "0/XVideoSyncToDisplayID=LVDS-0"
echo "Xft.dpi: 146" | xrdb -merge
fi

3
bin/fsize.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
printf '\33]50;%s%d%s\007' "xft:SourceCodePro:pixelsize=" $1 ":antialias=true:hinting=true"

View file

@ -1,16 +0,0 @@
#!/bin/sh
# Credit to Roland Latour
# http://www.freak-search.com/en/thread/4707111/q_volume_control,_xfce
# Find default sink
mute_cmd=$(amixer set Master toggle | egrep 'Playback.*?\[o' | head -n 1)
mute=$(echo "$mute_cmd" | egrep -o '\[o.+\]')
volume=$(echo "$mute_cmd" | sed '{s/://}' | awk '{print $4}')
let volume=($volume * 100 / 65536)
if [[ "$mute" == "[on]" ]]; then
# show the volume
volnoti-show $volume
fi
[[ "$mute" == "[off]" ]] && volnoti-show -m

11
bin/periodic_screenshot.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/zsh
format="%Y-%m-%d_%H-%M_$(hostname).png"
exec="mv \$f $HOME/periodic_screenshot/"
if [[ $(pidof X) -gt 0 ]]; then
DISPLAY=:0.0 xset -b
DISPLAY=:0.0 scrot -m $format -q 10 -e "$exec"
DISPLAY=:0.0 xset b
fi

View file

@ -1,17 +0,0 @@
#!/bin/bash
# Setup filename for the screenshot
myfile=$(date +%Y%m%d%H%M%S).png
#Setup paths to dropbox & full url to new screenshot
dropboxwebpath='http://dl.dropbox.com/u/22989236/temp/' # PUT YOUR DROPBOX USERID HERE
dropboxfileurl=$dropboxwebpath$myfile
# see: http://code.google.com/p/xmonad/issues/detail?id=476
sleep 0.2
# Use scrot to take a screenshot and stick it in your dropbox screenshots folder
scrot $myfile -e 'mv $f ~/Dropbox/Public/temp/' -s
# Put full URL to new screenshot into clipboard
echo $dropboxfileurl | xclip -selection c

17
bin/screenshot_public.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
# Setup filename for the screenshot
myfile=$(date +%Y%m%d%H%M%S).png
webpath='https://pub.yori.cc/screen/'
fileurl=$webpath$myfile
# see: http://code.google.com/p/xmonad/issues/detail?id=476
sleep 0.2
scrot $myfile -e 'mv $f ~/public/screen/' -s
# copy-paste
echo $fileurl | xclip -selection c
cd ~
rsync -LavP --cvs-exclude public pub.yori.cc:

3
bin/vga_setup.sh Executable file
View file

@ -0,0 +1,3 @@
xrandr --output VGA-0 --preferred --left-of LVDS-0 --output LVDS-0 --primary
feh --bg-fill ~/dotfiles/awesome/wallpaper.png
echo "power on" | sudo bluetoothctl

View file

@ -1,5 +0,0 @@
#!/bin/sh
# lower volume by 1%
volume=$(amixer set Master playback 1%- | grep "t: Playback" | sed '{s/://}' | awk '{print $5}' | head -n 1 | cut -c2- | rev | cut -c3- | rev)
volnoti-show $volume

View file

@ -1,5 +0,0 @@
#!/bin/sh
# Raise volume by 1%
volume=$(amixer set Master playback 1%+ | grep "t: Playback" | sed '{s/://}' | awk '{print $5}' | head -n 1 | cut -c2- | rev | cut -c3- | rev)
volnoti-show $volume