diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/androidbackup.sh | 143 | ||||
-rwxr-xr-x | bin/atmux | 122 | ||||
-rwxr-xr-x | bin/autostart | 23 | ||||
-rwxr-xr-x | bin/backup-settings | 19 | ||||
-rwxr-xr-x | bin/brightness | 23 | ||||
-rwxr-xr-x | bin/check-rt | 11 | ||||
-rwxr-xr-x | bin/check-vanilla | 11 | ||||
-rw-r--r-- | bin/connect_to_jack | 12 | ||||
-rwxr-xr-x | bin/functions.sh | 176 | ||||
-rwxr-xr-x | bin/lid-switch-action | 198 | ||||
-rwxr-xr-x | bin/lightdm-display-setup | 4 | ||||
-rwxr-xr-x | bin/rmcache | 32 | ||||
-rwxr-xr-x | bin/rollback-profile | 69 | ||||
-rwxr-xr-x | bin/screensetup | 17 | ||||
-rwxr-xr-x | bin/secret | 41 | ||||
-rwxr-xr-x | bin/set_volume | 56 | ||||
-rwxr-xr-x | bin/stop_jack | 16 |
17 files changed, 29 insertions, 944 deletions
diff --git a/bin/androidbackup.sh b/bin/androidbackup.sh deleted file mode 100755 index ee95f01..0000000 --- a/bin/androidbackup.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash - -if [ -e $HOME/bin/functions.sh ] -then - . $HOME/bin/functions.sh -else - exit 0 -fi - -## CONFIGURATION -ADB=adb - -function help() -{ - echo "Android data backup/restore" - echo "Usage:" - echo -e "\t [backup|restoredata|restoreapk] [device]" - exit 0 -} - -function _backup() -{ - adb -s $DEVICE pull /data/system/packages.list . - cat packages.list | while read line - do - read name dir <<< $(echo $line | awk '{ print $1 " " $4 }') - #echo $dir - apk=$($ADB shell bash -c "ls /data/app/${name}* 2> /dev/null") - if [ -n $exists ] - then - echo $name $apk - else - echo LALALALALAAA $name - fi - echo "" - done -} - -function _restoreapk() { - mkdir -p done skipped - apps=$(ls -1 | grep -c apk) - num=1 - for i in *.apk - do - if [ $i = "done" -o $i = "skipped" ] - then - continue - fi - echo_green "Application $i ($num/$apps)" - - name=$(echo $i | sed 's/-[0-9].apk//') - existing=$($ADB shell sh -c "ls /data/app*/${name}* 2> /dev/null") - echo $existing - if [ -n "$existing" ] - then - echo $i already installed - mv $i skipped - continue - fi - echo " Restore apk? [1|0] (default 1)" - echo -en " " - read inst - inst=${inst:=1} - - if [ $inst -eq 1 ] - then - $ADB install $i - mv $i done - else - echo -e " Skipping...\n\n" - mv $i skipped - fi - let num=num+1 - done -} - -function _restoredata() -{ - mkdir -p done skipped - apps=$(ls -l | grep -v skipped | grep -v done | grep -c '^d') - num=1 - for i in * - do - if [ $i = "done" -o $i = "skipped" ] - then - continue - fi - - echo_green "Application $i ($num/$apps)" - if [ $(adb shell ls -l /data/data | grep -c $i) -lt 1 ] - then - echo_red " not installed, skipping.\n\n" - mv $i skipped - continue - fi - - echo " Restore data? [1|0] (default 0)" - echo -en " " - read inst - inst=${inst:=0} - - if [ $inst -eq 1 ] - then - if [ $i = "com.android.providers.telephony" ] - then - echo -e "SMS/CALLS" - $ADB push $i/databases/mmssms.db /data/data/$i/databases - $ADB shell chmod 660 /data/data/$i/databases/mmssms.db - $ADB shell toolbox chown 1001:1001 /data/data/$i/databases/mmssms.db - $ADB shell killall system_server - mv $i done - else - own=$($ADB shell ls -l /data/data/ | grep $i | head -n 1 | awk '{ print $3}') - echo -e " User $own\n\n" - mute $ADB push $i /data/data/$i - mute $ADB shell chown $own:$own /data/data/$i/* - mute $ADB shell chown $own:$own /data/data/$i/*/* - mute $ADB shell chown $own:$own /data/data/$i/*/*/* - mv $i done - fi - else - echo -e " Skipping...\n\n" - mv $i skipped - fi - let num=num+1 - done -} - -case $1 in - backup) - _backup - ;; - restoredata) - _restoredata - ;; - restoreapk) - _restoreapk - ;; - *) - help - exit 0 - ;; -esac diff --git a/bin/atmux b/bin/atmux deleted file mode 100755 index 7601693..0000000 --- a/bin/atmux +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash - -if [ -e $HOME/bin/functions.sh ] -then - . $HOME/bin/functions.sh -else - echo "functions.sh not found" - exit 0 -fi - -# override tmux -tmux='tmux' - -## CONFIGURATION -# session name -sn=${1:-atmux} - -# try to attach earlier session -tmux attach-session -t $sn && exit 0 -#or continue - -# default path -case $sn in - # window definitions - # path:command:custom-name - "thesis") - dpath=/home/konni/dropbox/documents/uni/12ss/BA/breite-quellen/thesis - windows="-:-" - windows+="matlab:echo bla" - ;; - "mako") - dpath=/extra/src/cyanogenmod-10.1 - dcmd=". environment_mako" - windows="-:-" - windows+="-:-" - windows+=" device/lge/mako:-" - windows+=" out/target/product/mako:-" - ;; - "ville_dev") - dpath=/extra/src/cyanogenmod-10.1 - dcmd=". environment_ville" - windows="-:-" - windows+=" -:-" - windows+=" device/htc/ville:-" - windows+=" device/htc/msm8960-common:-" - windows+=" kernel/htc/msm8960:-" - windows+=" vendor/htc:-" - windows+=" out/target/product/ville:-" - ;; - "ville") - dpath=/extra/src/cyanogenmod-jellybean - dcmd=". environment_ville" - windows="-:-" - windows+=" -:-" - windows+=" device/htc/ville:-" - windows+=" device/htc/msm8960-common:-" - windows+=" kernel/htc/msm8960:-" - windows+=" vendor/htc:-" - windows+=" out/target/product/ville:-" - ;; - *) - dpath=$HOME - windows="-:-" -esac - - -# enter default path -mute pushd $dpath - -# prepare windows -num=1 -for window in $windows -do - # parse configuration - read wpath wcmd <<< $(echo $window | sed 's/:/\ /g') - - # set path - unset tpath - if [ $wpath != "-" ] - then - tpath=$wpath - fi - - - if [ $num -eq 1 ] - then - # start new session - $tmux new-session -d -s "$sn" $tname - # set default path for new windows - $tmux set-option -t "$sn" default-path $dpath - else - # create new window in session - $tmux new-window -t "$sn:$num" $tname - fi - - # execute default command - if [ -n "$dcmd" ] - then - $tmux send-keys -t "$n:$num" "$dcmd" C-m - fi - - # change path - if [ -n "$tpath" ] - then - $tmux send-keys -t "$n:$num" "cd $tpath" C-m - fi - - # execute custom command - unset tcmd - if [ "$wcmd" != "-" ] - then - tcmd=$wcmd - $tmux send-keys -t "$n:$num" "$tcmd" C-m - fi - - let num=num+1 -done - -# select window #1 and attach to session -$tmux select-window -t "$sn:1" -$tmux attach-session -t "$sn" - diff --git a/bin/autostart b/bin/autostart deleted file mode 100755 index 9d70ad0..0000000 --- a/bin/autostart +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# Auto starting various programs post lightdm - -export DISPLAY=:0 -export XAUTHORITY=/home/dave/.Xauthority - -KERNEL_NAME=$(uname -r) -if [[ "$KERNEL_NAME" != *rt* ]]; then - pid=$(pidof dropbox) - re='^[0-9]+$' - if [[ $pid =~ $re ]];then - echo "Dropbox alread running. Restarting..." - dropbox stop && dropbox start & - else - dropbox start & - fi -# pulseaudio --start & -# nm-applet & -# firewall-applet & -else - pulseaudio --kill & - qjackctl & -fi diff --git a/bin/backup-settings b/bin/backup-settings deleted file mode 100755 index 1a9cc12..0000000 --- a/bin/backup-settings +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/sh - -etcTMP=/tmp/etc.tgz -etcIF=/etc -OF=/home/dave/ownCloud/backup/settings -gpgEND=.gpg - -echo "Backing up /etc directory." -tar cfPz $etcTMP $etcIF -echo "Encrypting compressed directory." -su - dave -c "gpg -e -r 'David Runge <david.runge@frqrec.com>' $etcTMP" -echo "Changing permissions on file." -chown dave:dave $etcTMP$gpgEND -echo "Moving backup to ownCloud." -mv -f $etcTMP$gpgEND $OF -echo "Cleaning up." -rm $etcTMP -echo "Done." - diff --git a/bin/brightness b/bin/brightness deleted file mode 100755 index 192dc4c..0000000 --- a/bin/brightness +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# Script to lower/ raise screen brightness using xbacklight (xorg-xbacklight) - -set -e -u - -export DISPLAY=:0 -x11user=$(w |grep -w :0 | cut -d " " -f1) -export XAUTHORITY=/home/$x11user/.Xauthority -step=5 - -if [ -x /usr/bin/xbacklight ]; then - if [ "$1" = "video/brightnessup" ] && [ $2 = "BRTUP" ]; then - xbacklight -inc "$step" - elif [ "$1" = "video/brightnessdown" ] && [ $2 = "BRTDN" ]; then - xbacklight -dec "$step" - else - exit 1 - fi -else - exit 1 -fi - -exit 0 diff --git a/bin/check-rt b/bin/check-rt deleted file mode 100755 index 5dc04cd..0000000 --- a/bin/check-rt +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/env bash -#Check if the kernel name has -rt in it (we're running Realtime Kernel) - -if [[ $(uname -r) == *-rt* ]];then - echo "Success: Running $(uname -r)." - exit 0 -else - echo "Failure: Running $(uname -r)." - exit 1 -fi - diff --git a/bin/check-vanilla b/bin/check-vanilla deleted file mode 100755 index 6b4bdd4..0000000 --- a/bin/check-vanilla +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/env bash -#Check if the kernel name has -rt in it (we're running Realtime Kernel) - -if [[ $(uname -r) == *-rt* ]];then - echo "Failure: Running $(uname -r)." - exit 1 -else - echo "Success: Running $(uname -r)." - exit 0 -fi - diff --git a/bin/connect_to_jack b/bin/connect_to_jack deleted file mode 100644 index e17ccc2..0000000 --- a/bin/connect_to_jack +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -case "$HOSTNAME" in - "pitheunlord") - jack_connect SuperCollider:out_1 alsa_out:playback_1 & - jack_connect SuperCollider:out_2 alsa_out:playback_2 & - ;; - "beagleclone") - ;; - "dvzrv") - ;; -esac diff --git a/bin/functions.sh b/bin/functions.sh deleted file mode 100755 index 951def5..0000000 --- a/bin/functions.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash -# some functions - -# zsh color output -# echo "$FG[46]$FX[blink]Hello, World" - -function echo_green() { - echo -e '\E[1;32m'$*'\E[0m' -} - -function echo_red() { - echo -e '\E[1;31m'$*'\E[0m' -} - -function echo_magenta() { - echo -e '\E[1;35m'$*'\E[0m' -} - -function echo_cyan() { - echo -e '\E[1;36m'$*'\E[0m' -} - -# log text ... -function log() { - date=`date "+%Y-%m-%d %H:%M:%S"` - if [ -n $VERBOSE ] - then - echo $date $@ | tee -a $LOGFILE - fi - [ -n $LOGFILE ] && echo $date $@ >> $LOGFILE -} - -function log_green() { - date=`date "+%Y-%m-%d %H:%M:%S"` - if [ -n $VERBOSE ] - then - echo_green $date $@ - fi - [ -n $LOGFILE ] && echo $date $@ >> $LOGFILE -} - -function log_red() { - date=`date "+%Y-%m-%d %H:%M:%S"` - if [ -n $VERBOSE ] - then - echo_red $date $@ - fi - [ -n $LOGFILE ] && echo $date $@ >> $LOGFILE -} - -function log_magenta() { - date=`date "+%Y-%m-%d %H:%M:%S"` - if [ -n $VERBOSE ] - then - echo_magenta $date $@ - fi - [ -n $LOGFILE ] && echo $date $@ >> $LOGFILE -} - -function log_cyan() { - date=`date "+%Y-%m-%d %H:%M:%S"` - if [ -n $VERBOSE ] - then - echo_cyan $date $@ - fi - [ -n $LOGFILE ] && echo $date $@ >> $LOGFILE -} - -function notify() { - title="$1" - text="$2" - echo 'naughty.notify({title = "'$title'", text = "'$text'"})' | awesome-client -} - -# mute command -function mute() { - $@ > /dev/null 2> /dev/null -} - -# run pidfile command -function run() { - pidfile=$1 - shift - command=$@ - - exec $command > /dev/null 2> /dev/null & - pid=$! - sleep 0.25 - npid=$(pidof -s $1) - if [ -n "$npid" ] && [ $npid -ne $pid ] - then - pid=$npid - fi - echo $pid > $pidfile - log_green executed $command"\n" -} - -# run_once $pidfile $command[] -function run_once() { - pidfile=/tmp/run/lock/$1 - shift - command=$@ - - mkdir -p $(dirname $pidfile) - - if [ -f $pidfile ]; - then - pid=`head -n 1 $pidfile` - running=$(ps -u $(whoami) -p $pid | grep '^[ ]*'$pid) - if [ -z "$running" ] - then - log_cyan stale pidfile found - rm -f $pidfile - - npid=$(pidof -s $1) - if [ -n "$npid" ] - then - log_green "pidfile updated\n" - echo $npid > $pidfile - else - run $pidfile $command - fi - - else - log_cyan "active pidfile found\n" - fi - else - pid=`ps | grep "$command" | grep -v grep | head -n 1 | awk '{ print $1 }'` - if [ -z "$pid" ] - then - log_green not running - run $pidfile $command - else - log_cyan "pidfile updated\n" - echo $pid > $pidfile - fi - fi -} - -# run_auto $file -function run_auto() { - file=$1 - . $file - - cur_host=`hostname` - case $cur_host in - annoyance|silence|remembrance) - cur_area=private - ;; - c*|s*) - cur_area=unixpool - ;; - esac - - if [ $area != $cur_area -a $area != "any" ] - then - log_magenta invalid_area $(basename $file)"\n" - return - fi - - if [ $host != $cur_host -a $host != "any" ] - then - log_magenta invalid_host $(basename $file)"\n" - return - fi - - if [ $allow_multiple -eq 1 ] - then - log_green run $(basename $file) - run /dev/null $command - else - log_green run_once $(basename $file) - run_once `basename $file` $command - fi -} - diff --git a/bin/lid-switch-action b/bin/lid-switch-action deleted file mode 100755 index a2779b7..0000000 --- a/bin/lid-switch-action +++ /dev/null @@ -1,198 +0,0 @@ -#!/bin/bash -# What action to take on closing the laptop lid, -# depending on whether a screen is attached or not. -# This implies setting HandleLidSwitch=ignore in /etc/systemd/logind.conf -# Call this script from /etc/acpi/handler.sh (or other properly set up script -# for handling button/lid acpi event) with parameter 0 and 1 for close and open respectively - -set -e -u - -# Find current Xsession user through loginctl list-sessions (excluding lightdm) -# TODO: make available for desktop manager, too! -declare x_user="$(loginctl list-sessions --no-legend| sed -e 's/\s\{2,\}/ /g;s/^[[:space:]]*//' | \ - cut -d ' ' -f 3| grep -v "lightdm"|uniq)" - -# Fail if there is no user set -if [ -z "$x_user" ]; then - echo "error no user!" - exit 1 -fi - -# Export Xorg DISPLAY and XAUTHORITY -# TODO: Get number of X DISPLAY from tmp -#declare x_display="/tmp/.X11-unix/X*" -export DISPLAY=:0 -export XAUTHORITY=/home/$x_user/.Xauthority - -# Define the log file -declare log="/home/$x_user/.cache/$(basename $0)" -if [[ ! -w "$log" ]]; then - touch "$log" - chown ${x_user}:${x_user} "$log" -# exec > "$log" 2>&1 -fi - -declare -a arguments=( ) -declare -a connections=( ) -declare -a active_connections=( ) -declare -a available_connections=( ) -declare -a non_primary=( "eDP1" ) -declare -a pan=( "DP2-1" "eDP1" ) -declare -a pan_vertical=( 'empty' 'empty' ) # with empty placeholders! -declare internal="eDP1" -declare current_primary="" -declare action="" - -# declare keywords (xrandr arguments) -declare pre_output=" --output " -declare post_auto=" --auto " -declare post_primary=" --primary " -declare post_pos_rightof=" --right-of" -declare post_pos_leftof=" --left-of" -declare post_off=" --off " - -function setup_xscreen() -{ - local outputs=( ) - local connection_counter=0 - case "$action" in - "open") - if [ ${#available_connections[@]} -gt 1 ]; then - for connection in ${pan[@]} - do - echo "$connection" >> $log - set +e - find_component_in "$connection" ${available_connections[@]} - if [ $? -eq 0 ]; then - echo "$connection is amongst the available outputs." >> $log - # adding --output argument - outputs=( ${outputs[@]:+${outputs[@]}} "$pre_output" ) - # adding name of output - outputs=( ${outputs[@]:+${outputs[@]}} "$connection" ) - # check whether output should not be primary in a multi output setup - find_component_in "$connection" ${non_primary[@]} - if [ $? -eq 0 ]; then - echo "$connection is setup for non-primary." >> $log - else - echo "$connection is NOT setup for non-primary." >> $log - # adding --primary argument - outputs=( ${outputs[@]:+${outputs[@]}} "$post_primary" ) - fi - if [ $connection_counter -gt 0 ]; then - # adding a --right-of <connection before this one> argument - outputs=( ${outputs[@]:+${outputs[@]}} "$post_pos_rightof" "${pan[$((connection_counter-1))]}" ) - fi - # adding --auto argument - outputs=( ${outputs[@]:+${outputs[@]}}"$post_auto" ) - connection_counter=$(( $connection_counter + 1 )) - fi - set -e - done - fi - ;; - "close") - if [ ${#available_connections[@]} -gt 1 ]; then - for connection in ${pan[@]} - do - echo "$connection" >> $log - set +e - find_component_in "$connection" ${available_connections[@]} - if [ $? -eq 0 ]; then - echo "$connection is amongst the available outputs." >> $log - # adding --output argument - outputs=( ${outputs[@]:+${outputs[@]}} "$pre_output" ) - # adding name of output - outputs=( ${outputs[@]:+${outputs[@]}} "$connection" ) - # if the connection is not the internal output - if [ $connection != $internal ]; then - # check whether output should not be primary in a multi output setup - find_component_in "$connection" ${non_primary[@]} - if [ $? -eq 0 ]; then - echo "$connection is setup for non-primary." >> $log - else - echo "$connection is NOT setup for non-primary." >> $log - # adding --primary argument - outputs=( ${outputs[@]:+${outputs[@]}} "$post_primary" ) - fi - if [ $connection_counter -gt 0 ]; then - # adding a --right-of <connection before this one> argument - outputs=( ${outputs[@]:+${outputs[@]}} "$post_pos_rightof" "${pan[$((connection_counter-1))]}" ) - fi - # adding --auto argument - outputs=( ${outputs[@]:+${outputs[@]}}"$post_auto" ) - connection_counter=$(( $connection_counter + 1 )) - else - # adding a --off argument for the interal screen - outputs=( ${outputs[@]:+${outputs[@]}} "$post_off" ) - fi - fi - set -e - done - fi - ;; - esac -echo "Calling: xrandr ${outputs[@]}" >> $log -xrandr ${outputs[@]} -} - -function find_component_in() -{ - local -r component=$1 - shift - local value - for value in "$@" - do - [[ $value == "$component" ]] && return 0 - done - return 1 -} - -function get_current_x_information() -{ - # get current xrandr settings - current_xrandr=$(xrandr) - # get current primary output from xrandr - current_primary=$(echo "$current_xrandr" | \ - grep -wE '(\bconnected.*primary.*[0-9]{1,5}\x[0-9]{1,5}\+[0-9]{1,5}\+[0-9]{1,5})' | \ - cut -d ' ' -f 1) - echo "Current primary output: $current_primary" >> $log - # get all current active connections - active_connections=( "${active_connections[@]:+${active_connections[@]}}" $(echo "$current_xrandr" | \ - grep -wE '(\bconnected.*[0-9]{1,5}\x[0-9]{1,5}\+[0-9]{1,5}\+[0-9]{1,5})' | cut -d ' ' -f 1) ) - echo "Current active connections: ${active_connections[@]}" >> $log - # get all currently available connections - available_connections=( "${available_connections[@]:+${available_connections[@]}}" $(echo "$current_xrandr" | \ - grep -wE '(\bconnected.*)' | cut -d ' ' -f 1) ) - echo "Currently available connections: ${available_connections[@]}" >> $log - # get all available connections - connections=( "${connections[@]:+${connections[@]}}" $(echo "$current_xrandr"| grep -v 'Screen' | cut -d ' ' -f 1)) - echo "All current connections: ${connections[@]}" >> $log -} - -function get_action() -{ - arguments=( "${arguments[@]:+${arguments[@]}}" "${@:+$@}" ) -# echo "${@:+$@}" >> $log -# echo "${arguments[@]:+${arguments[@]}}" >> $log - if [ ${#arguments[@]} -gt 0 ];then - if [ "${arguments[0]}" = "button/lid" ]; then - case "${arguments[2]}" in - "open") - action="open" - ;; - "close") - action="close" - ;; - esac - elif [ "${arguments[0]}" = "login" ]; then - action="open" - fi - fi - echo "Action set: $action" >> $log -} - -# pass arguments to the script to the get_action function -get_action "${@:+$@}" -get_current_x_information -setup_xscreen - diff --git a/bin/lightdm-display-setup b/bin/lightdm-display-setup deleted file mode 100755 index 94ce0a5..0000000 --- a/bin/lightdm-display-setup +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# Script to run as lightdm "display-setup-script" - -runuser -l dave -c 'autorandr -c' diff --git a/bin/rmcache b/bin/rmcache deleted file mode 100755 index acba953..0000000 --- a/bin/rmcache +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -USERDIR=$1 - -echo "rmcache cleaning up: $USERDIR" - -caches=".cache/chromium" -caches+=" .cache/thumbnails" -## take care of the whitespace! -caches+=" .config/chromium/Default/*Index*" -caches+=" .thumbnails" -caches+=" .opera/cache4" -caches+=" .opera/cache" -caches+=" .java/deployment/cache" -caches+=" .local/share/Trash" -caches+=" .gnome2/epiphany/mozilla/epiphany/Cache" -caches+=" .adobe/Acrobat/*/Cache" -caches+=" .adobe/Acrobat/*/Temp" -caches+=" .macromedia/Flash_Player/*" -caches+=" .adobe/Flash_Player/AssetCache" -caches+=" .java/deployment/cache" - -pushd $USERDIR > /dev/null - -for cache in $caches -do - echo "removing $cache" - rm -Rf "$cache" - [ $? -eq 0 ] || exit 1 -done - -popd > /dev/null diff --git a/bin/rollback-profile b/bin/rollback-profile deleted file mode 100755 index 81386b3..0000000 --- a/bin/rollback-profile +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -# -# Rollback a thunderbird or firefox profile backup from store location while gpg decrypting -# - -# Checking if firefox and/ or thunderbird are running. -firefoxPID=`ps -C firefox -o pid=` -thunderbirdPID=`ps -C thunderbird -o pid=` - -firefoxTMP=/tmp/firefox.tgz -thunderbirdTMP=/tmp/thunderbird.tgz -firefoxIF=~/.mozilla/firefox/ -thunderbirdIF=~/.thunderbird/ -profileName=dvzrv -backupEND=-rollback -OF=~/ownCloud/backup/web/ -gpgEND=.gpg -tgzEND=.tgz - -case $1 in - "thunderbird") - if [[ -z "$thunderbirdPID" ]] - then - echo "Thunderbird is not running." - echo "Rolling back profile backup." - echo "Copying backup to /tmp and moving old profile to rollback location." - cp $OF$1$tgzEND$gpgEND $thunderbirdTMP$gpgEND - mv $thunderbirdIF$profileName $thunderbirdIF$profileName$backupEND - echo "Decrypting file." - gpg -o $thunderbirdTMP -d $thunderbirdTMP$gpgEND - echo "Extracting files from tar." - tar xzvf $thunderbirdTMP -C $thunderbirdIF - echo "Cleaning up." - rm $thunderbirdTMP $thunderbirdTMP$gpgEND - echo "Done." - else - echo "Thunderbird is still running." - echo "Skipping rollback." - fi - ;; - "firefox") - if [[ -z "$firefoxPID" ]] - then - echo "Firefox is not running." - psdStopped=`systemctl status psd |grep inactive` - if [[ ! -z "$psdStopped" ]]; then - echo "Psd daemon is inactive." - echo "Rolling back profile backup." - echo "Copying backup to /tmp and moving old profile to rollback location." - cp $OF$1$tgzEND$gpgEND $firefoxTMP$gpgEND - mv $firefoxIF$profileName $firefoxIF$profileName$backupEND - echo "Decrypting file." - gpg -o $firefoxTMP -d $firefoxTMP$gpgEND - echo "Extracting files from tar." - tar xzvf $firefoxTMP -C $firefoxIF - echo "Cleaning up." - rm $firefoxTMP $firefoxTMP$gpgEND - echo "Done." - else - echo "Psd service is still running!" - echo "Disable it using: 'systemctl stop psd'." - echo "Skipping rollback." - fi - else - echo "Firefox is still running." - echo "Skipping rollback." - fi - ;; -esac diff --git a/bin/screensetup b/bin/screensetup deleted file mode 100755 index b15d63e..0000000 --- a/bin/screensetup +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -#set dpms and screen blanking -xset +dpms -xset s 360 360 - -# Setup screens - -# get info from xrandr -IFS=$'\r\n' connectedOutputs=($(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")) - -#if more than one screen, setup both, using the external left of the internal as primary -if [ ${#connectedOutputs[@]} -gt 1 ]; then - xrandr --output "${connectedOutputs[0]}" --auto --output "${connectedOutputs[1]}" --auto --primary --left-of "${connectedOutputs[0]}" -fi - - diff --git a/bin/secret b/bin/secret deleted file mode 100755 index 27391ff..0000000 --- a/bin/secret +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# Open and write to a gpg encrypted file -# Will create the file for you if it's not there yet -# -# secret <path/to/file> - -writeback () { - gpg --yes -eq -r "$gpgkey" -o $1 $tmpfile - echo "Encrypted file using gpg public key: $gpgkey" - chmod 600 $1 - echo "Finished working on file: $1." - rm $tmpfile - echo "Removed temp file $tmpfile" -} - -filetotmp () { - gpg --yes -o $tmpfile -d $1 -} - -tmpfile=$(mktemp) -gpgkey="David Runge <david.runge@frqrec.com>" - -# if file is available, use it, else create it -if [[ -f "$1" ]];then - filetotmp $1 - echo "File $1 now in $tmpfile ." -fi - -echo "Opening file in $EDITOR" -# edit decrypted file in /tmp -$EDITOR $tmpfile -if [[ $? -gt 0 ]];then - echo "Something went wrong with $EDITOR ." - echo "Aborting." - rm $tmpfile - echo "Deleted $tmpfile ." -else - # write back the file - writeback $1 -fi diff --git a/bin/set_volume b/bin/set_volume index de980e5..acd6396 100755 --- a/bin/set_volume +++ b/bin/set_volume @@ -1,8 +1,6 @@ #!/usr/bin/env bash -FUNCTIONS=$HOME/bin/functions.sh -[ -e $FUNCTIONS ] || exit 1 -. $FUNCTIONS +set -euo pipefail state_muted="/tmp/$(whoami)/state_muted" state_muted_headphone="" @@ -14,10 +12,10 @@ card_icon="/usr/share/icons/gnome/48x48/devices/audio-speakers.png" # gnome-icon function increase_volume() { - mute amixer $cardselector sset Master 5%+ + amixer $cardselector sset Master 5%+ &>/dev/null local state_master=$(amixer $cardselector sget Master |grep "%" | cut -d'%' -f1 | cut -d '[' -f2 | uniq) #update pactl bluetooth audio to same level if present - if [ $state_bt_headphone = "[on]" ];then + if [ "$state_bt_headphone" = "[on]" ]; then pactl set-sink-volume $name_bt_headphone "$state_master%" fi print_volumes $state_master @@ -25,10 +23,10 @@ function increase_volume() function decrease_volume() { - mute amixer $cardselector sset Master 5%- + amixer $cardselector sset Master 5%- &>/dev/null local state_master=$(amixer $cardselector sget Master |grep "%" | cut -d'%' -f1 | cut -d '[' -f2 | uniq) #update pactl bluetooth audio to same level if present - if [ $state_bt_headphone = "[on]" ];then + if [ "$state_bt_headphone" = "[on]" ];then pactl set-sink-volume $name_bt_headphone "$state_master%" fi print_volumes $state_master @@ -39,7 +37,7 @@ function print_volumes() local state_master=$1 local state_headphone=$(amixer $cardselector sget Headphone |grep "%" | cut -d'%' -f1 | cut -d '[' -f2 | uniq) local state_speaker=$(amixer $cardselector sget Speaker |grep "%" | cut -d'%' -f1 | cut -d '[' -f2 | uniq) - if [ $state_bt_headphone = "[on]" ]; then + if [ "$state_bt_headphone" = "[on]" ]; then send_notify "Master: $state_master% Headphone: $state_headphone% Speaker: $state_speaker% BT Headphone: $state_master%" else send_notify "Master: $state_master% Headphone: $state_headphone% Speaker: $state_speaker%" @@ -53,50 +51,50 @@ function toggle_volume() local state_speaker=$(amixer $cardselector sget Speaker | grep -o '\[o[n|f]*\]' | head -n 1) case "$state_master" in "[on]") - mute amixer $cardselector sset Master mute + amixer $cardselector sset Master mute &>/dev/null state_master="[off]" # if headphones are off already, don't mute, instead save state to tmp file if [ "$state_headphone" = "[off]" ];then echo "headphone [off]" >> "$state_muted" else - mute amixer $cardselector sset Headphone mute + amixer $cardselector sset Headphone mute &>/dev/null state_headphone="[off]" fi # if speakers are off already, don't mute, instead save state to tmp file if [ "$state_speaker" = "[off]" ];then echo "speaker [off]" >> "$state_muted" else - mute amixer $cardselector sset Speaker mute + amixer $cardselector sset Speaker mute &>/dev/null state_speaker="[off]" fi # if present, also mute bluetooth headphone - if [ $state_bt_headphone = "[on]" ]; then + if [ "$state_bt_headphone" = "[on]" ]; then pactl set-sink-mute $name_bt_headphone 1 fi ;; "[off]") - mute amixer $cardselector sset Master unmute + amixer $cardselector sset Master unmute &>/dev/null state_master="[on]" # if headphones are meant to be off, don't unmute them again if [ "$state_muted_headphone" != "[off]" ];then - mute amixer $cardselector sset Headphone unmute + amixer $cardselector sset Headphone unmute &>/dev/null state_headphone="[on]" fi # if headphones are meant to be off, don't unmute them again if [ "$state_muted_speaker" != "[off]" ];then - mute amixer $cardselector sset Speaker unmute + amixer $cardselector sset Speaker unmute &>/dev/null state_speaker="[on]" fi # if present, also unmute bluetooth headphone - if [ $state_bt_headphone = "[on]" ]; then + if [ "$state_bt_headphone" = "[on]" ]; then pactl set-sink-mute $name_bt_headphone 0 fi ;; esac - if [ $state_bt_headphone = "[on]" ]; then - send_notify "Master: $state_master \nHeadphone: $state_headphone \nSpeaker: $state_speaker\nBT Headphone: $state_master" 2000 + if [ "$state_bt_headphone" = "[on]" ]; then + send_notify "Master: $state_master Headphone: $state_headphone Speaker: $state_speaker BT Headphone: $state_master" 2000 else - send_notify "Master: $state_master \nHeadphone: $state_headphone \nSpeaker: $state_speaker" 2000 + send_notify "Master: $state_master Headphone: $state_headphone Speaker: $state_speaker" 2000 fi } @@ -104,9 +102,9 @@ function send_notify() { # allow timeout to be set by 2nd argument local timeout=1000 - if [ $2 -gt 0 ]; then - timeout=$2 - fi +# if [ $2 -gt 0 ]; then +# timeout=$2 +# fi notify-send -t $timeout \ -i /usr/share/icons/gnome/48x48/devices/audio-speakers.png \ "Volume" "$1" @@ -121,16 +119,18 @@ if [ $HOSTNAME = "dvzrv" ];then fi case "$1" in - increase) + "increase") increase_volume ;; - decrease) + "decrease") decrease_volume ;; - toggle) + "toggle") if [ -f "$state_muted" ]; then - state_muted_headphone=$(cat "$state_muted" | grep headphone | cut -d' ' -f2) - state_muted_speaker=$(cat "$state_muted" | grep speaker | cut -d' ' -f2) + set +e + state_muted_speaker="$(cat "$state_muted" | grep speaker | cut -d' ' -f2)" + state_muted_headphone="$(cat "$state_muted" | grep headphone | cut -d' ' -f2)" + set -e rm "$state_muted" else touch "$state_muted" @@ -140,3 +140,5 @@ case "$1" in *) ;; esac + +exit 0 diff --git a/bin/stop_jack b/bin/stop_jack deleted file mode 100755 index f07b6be..0000000 --- a/bin/stop_jack +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -jack_control stop -sleep 3 -jack_control exit - - -exit 0 - -#kill $(pidof jackd) -#case "$HOSTNAME" in -# "beagleclone") -# kill $(pidof jackd) -# kill $(pidof xvfb-run) -# ;; -#esac |