aboutsummaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
Diffstat (limited to 'local')
-rwxr-xr-xlocal/bin/asus-fan28
-rwxr-xr-xlocal/bin/email-unread33
-rwxr-xr-xlocal/bin/mxrandr119
-rwxr-xr-xlocal/bin/project-test43
-rwxr-xr-xlocal/bin/steam10
-rwxr-xr-xlocal/bin/system-backup75
-rwxr-xr-xlocal/bin/vim-project-gen4
-rwxr-xr-xlocal/sbin/newmail-notify23
-rwxr-xr-xlocal/sbin/syncemail48
-rwxr-xr-xlocal/sbin/user-service.sh106
10 files changed, 0 insertions, 489 deletions
diff --git a/local/bin/asus-fan b/local/bin/asus-fan
deleted file mode 100755
index 09e54f1..0000000
--- a/local/bin/asus-fan
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-# TODO this probably should be auto detected, because hwmon number can change
-HWMON=/sys/devices/platform/asus-nb-wmi/hwmon/hwmon1
-
-if [ "$(whoami)" != "root" ]; then
- echo "Run $0 only with root privileges"
- exit -1
-fi
-
-case "$1" in
- -h|--help)
- echo "Usage: $0 -h|full|auto"
- echo "This script controls asus hwmon"
- echo " full - Full throttle"
- echo " auto - Automatic hardware control"
- ;;
- full)
- echo 1 > $HWMON/pwm1_enable
- echo 255 > $HWMON/pwm1
- ;;
- auto)
- echo 0 > $HWMON/pwm1_enable
- ;;
- *)
- echo "Unknown or no option given!"
- exit -2
- ;;
-esac
diff --git a/local/bin/email-unread b/local/bin/email-unread
deleted file mode 100755
index dec7d04..0000000
--- a/local/bin/email-unread
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use File::Find;
-
-use constant EMAIL => glob("~/.mail");
-my $IGNORE = "(Spam|trash|Important)";
-
-my $V = (shift || "") eq "-s";
-
-opendir(EDIR, EMAIL) or die $!;
-while (readdir EDIR) {
- next if /^\./ or not (-d EMAIL."/$_");
- our $count = 0;
-
- sub new_dir {
- my $path = substr $File::Find::name, 1 + length EMAIL;
- $path =~ s/\/new$//;
- return if $_ ne "new" or $path =~ /$IGNORE/;
- my $cnt = 0;
- opendir(NDIR, "$File::Find::name") or die $!;
- while (readdir NDIR) {
- $cnt += 1 unless /^\./;
- }
- closedir(NDIR);
- print "$path: $cnt\n" if not $V and $cnt > 0;
- $count += $cnt;
- }
- find(\&new_dir, EMAIL."/$_");
-
- print "$_: $count\n" if $V and $count > 0;
-}
-closedir(EDIR);
diff --git a/local/bin/mxrandr b/local/bin/mxrandr
deleted file mode 100755
index 81ae511..0000000
--- a/local/bin/mxrandr
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-
-# get info from xrandr
-connectedOutputs=$(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
-activeOutput=$(xrandr | grep -E " connected (primary )?[1-9]+" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
-disconnectedOutputs=$(xrandr | grep -E " disconnected (primary )?[1-9]+" | awk '{print $1}')
-
-cmd="xrandr "
-cmd_def=$cmd
-
-INTERNAL=eDP-1
-HDMI=HDMI-1
-VGA=VGA-1
-
-for device in "$disconnectedOutputs"; do
- if [ -n "$defice" ]; then
- if [[ "$activeOutput" == *"$device"* ]]; then
- cmd=$cmd" --output $device --off"
- fi
- fi
-done
-
-function only_internal {
- cmd=$cmd" --output $INTERNAL --auto --primary"
- cmd=$cmd" --output $HDMI --off"
- cmd=$cmd" --output $VGA --off"
-}
-
-function internal_vga {
- cmd=$cmd" --output $INTERNAL --auto --primary"
- cmd=$cmd" --output $HDMI --off"
- cmd=$cmd" --output $VGA --auto --right-of $INTERNAL"
-}
-
-function internal_hdmi {
- cmd=$cmd" --output $INTERNAL --auto --right-of $HDMI"
- cmd=$cmd" --output $HDMI --auto --primary"
- cmd=$cmd" --output $VGA --off"
-}
-
-function internal_hdmi_vga {
- cmd=$cmd" --output $INTERNAL --auto --right-of $HDMI"
- cmd=$cmd" --output $HDMI --auto --primary"
- cmd=$cmd" --output $VGA --auto --left-of $HDMI"
-}
-
-function cmd_exec {
- if [ "$cmd" != "$cmd_def" ]; then
- echo $cmd
- `$cmd`
- fi
-}
-
-
-if [ $# -le 1 ]; then
- if [[ "$connectedOutputs" == *"$HDMI"* ]]; then
- if [[ "$connectedOutputs" == *"$VGA"* ]]; then
- internal_hdmi_vga
- else
- internal_hdmi
- fi
- else
- if [[ "$connectedOutputs" == *"$VGA"* ]]; then
- internal_vga
- else
- only_internal
- fi
- fi
- cmd_exec
- exit
-fi
-
-if [ "$2" != "mode" ]; then
- if [[ "$connectedOutputs" != *"$2"* ]]; then
- echo No $2 display known
- exit
- fi
-fi
-
-case "$1" in
- toggle)
- case "$2" in
- $INTERNAL)
- if [[ "$activeOutput" == *"$INTERNAL"* ]]; then
- cmd=$cmd" --output $INTERNAL --off"
- else
- if [[ "$activeOutput" == *"$HDMI"* ]]; then
- cmd=$cmd" --output $INTERNAL --auto --right-of $HDMI"
- else
- cmd=$cmd" --output $INTERNAL --auto --primary"
- fi
- fi
- ;;
- $HDMI)
- if [[ "$activeOutput" == *"$HDMI"* ]]; then
- cmd=$cmd" --output $HDMI --off"
- else
- if [[ "$activeOutput" == *"$VGA"* ]]; then
- cmd=$cmd" --output $HDMI --auto --primary"
- else
- cmd=$cmd" --output $HDMI --auto --right-of $INTERNAL"
- fi
- fi
- ;;
- $VGA)
- if [[ "$activeOutput" == *"$VGA"* ]]; then
- cmd=$cmd" --output $VGA --off"
- else
- if [[ "$activeOutput" == *"$HDMI"* ]]; then
- cmd=$cmd" --output $VGA --auto --left-of $HDMI"
- else
- cmd=$cmd" --output $VGA --auto --right-of $INTERNAL"
- fi
- fi
- ;;
- esac
- ;;
-esac
-cmd_exec
diff --git a/local/bin/project-test b/local/bin/project-test
deleted file mode 100755
index a0591d8..0000000
--- a/local/bin/project-test
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-# Executes given command on all commits from current one to given one.
-set -e
-
-print_help() {
- echo "Executes given command for each commit. In default it executes"
- echo "for 10 previous commands."
- echo
- echo "Usage: project-test [OPTION...] [--] COMMAND"
- echo " -r,--ref [REF]"
- echo " Git reference to go to"
- echo " -c,--count [COUNT]"
- echo " Tests given count of references back from current one."
-}
-
-while [ -n "$1" ]; do
- case $1 in
- -r|--ref)
- shift
- REF=$1
- ;;
- -c|--count)
- shift
- REF=HEAD~$1
- ;;
- --)
- shift
- break
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-[ -n "$REF" ] || REF=HEAD~10
-
-while read -r rev; do
- git checkout "$rev"
- git submodule update
- eval $@
-done < <(git rev-list "$REF"..HEAD)
diff --git a/local/bin/steam b/local/bin/steam
deleted file mode 100755
index b573daf..0000000
--- a/local/bin/steam
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-#export STEAM_RUNTIME=0
-export STEAM_RUNTIME_PREFER_HOST_LIBRARIES=0
-# Workaround for dbus fatal termination related coredumps (SIGABRT)
-# https://github.com/ValveSoftware/steam-for-linux/issues/4464
-export DBUS_FATAL_WARNINGS=0
-# Override some libraries as these are what games linked against.
-export LD_LIBRARY_PATH="/usr/lib/steam:/usr/lib32/steam"
-#export LD_PRELOAD="/usr/lib/steam:/usr/lib32/steam /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/libstdc++.so.6 /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4/libgcc_s.so.1 /usr/lib64/libxcb.so.1 /usr/lib64/libgpg-error.so"
-exec /usr/bin/steam "$@"
diff --git a/local/bin/system-backup b/local/bin/system-backup
deleted file mode 100755
index dfa2c09..0000000
--- a/local/bin/system-backup
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# vim:ft=sh
-# New line separated list of all directories to backup
-DIRS="/etc
-/home
-/home_hdd"
-# Name of the machine used in backup subvolumes
-MNAME=asus
-# Path where backup will be mounted
-MPATH=/media/backup
-# UUID of disk
-UUID=b162ea95-38bb-42c6-b36a-1be98c65392c
-# Mount additional arguments
-MARGS="-o compress=lzo"
-# If disk is encrypted
-CRYPT=true
-####################################################################
-# Check if running as root
-if [ `id -u` -ne "0" ]; then
- echo Please run this as root.
- exit 1
-fi
-set -e
-
-# Mount disk
-PART=$(lsblk -fpl | grep "$UUID" | awk '{print $1}')
-if [ -z "$PART" ]; then
- echo Disk not detected. Exiting
- exit -1
-fi
-if $CRYPT; then
- echo -e "\e[1;33mDecrypting filesystem\e[0m"
- # TODO what if already opened
- cryptsetup open "$PART" backup || (echo Decryption failed && exit -2)
- PART=/dev/mapper/backup
- echo $PART
-fi
-echo -e "\e[1;33mMounting\e[0m"
-mkdir -p "$MPATH"
-mount $MARGS "$PART" "$MPATH" || (echo Mount failed && exit -3)
-
-[ -d "$MPATH"/@"$MNAME" ] || (echo There seems to be no subvolume $MNAME && exit -4)
-
-# Do backup
-while read -r DIR; do
- echo -e "\e[1;33mBacking up: $DIR\e[0m"
- rsync -aAxXS --delete --progress "$DIR" "$MPATH"/@"$MNAME"/ || [ $? -eq 24 ]
- # We ignore exit code if rsync detects vanished source file
-done <<< "$DIRS"
-
-# Do snapshot (read only)
-(cd "$MPATH"; btrfs subvolume snapshot -r @asus @asus-$(date -u +%y%m%d))
-
-# Remove snapshots older than 2 months
-# TODO ensure that at least five stays
-(cd "$MPATH"
-for s in @"$MNAME"-*; do
- if [ $(expr $(date +%s) - $(stat -c %Y "$s")) -gt 5529600 ]; then
- btrfs subvolume delete "$s"
- fi
-done)
-
-# Unmount disk
-sync -f "$MPATH"/@"$MNAME"
-umount "$MPATH" || (echo Unmount failed. Unmount by hand. && exit -5)
-if $CRYPT; then
- cryptsetup close backup || (echo Encryption close failed. Do by hand. && exit -6)
-fi
-
-# Store when we did last backup and update i3blocks status
-date +"%s" > /home/cynerd/.backup_date
-pkill -RTMIN+13 i3blocks
-
-echo
-echo -e "\e[1;34mBackup finished\e[0m"
diff --git a/local/bin/vim-project-gen b/local/bin/vim-project-gen
deleted file mode 100755
index 6a50ba5..0000000
--- a/local/bin/vim-project-gen
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-# Generates ctags and cscope files for project.
-ctags -R -f .tags
-#cscope -Rbq -f .cscope.out
diff --git a/local/sbin/newmail-notify b/local/sbin/newmail-notify
deleted file mode 100755
index 7c6b803..0000000
--- a/local/sbin/newmail-notify
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-cd ~/.mail
-
-if [ -f notify-notified ]; then
- NOTIFIED=`cat notify-notified`
- rm notify-notified
-fi
-
-for account in `ls`; do
- if cd "$account"/INBOX/new; then
- for m in `ls`; do
- echo $m
- echo $m >> ~/.mail/notify-notified
- if echo "$NOTIFIED" | grep "$m" >/dev/null; then continue; fi
- FROM=`grep -E "^From: " "$m" | sed 's/^From: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- TO=`grep -E "^To: " "$m" | sed 's/^To: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- SUBJECT=`grep -E "^Subject: " "$m" | sed 's/^Subject: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- notify-send "$TO: $FROM" "$SUBJECT"
- done
- fi
- cd ~/.mail
-done
diff --git a/local/sbin/syncemail b/local/sbin/syncemail
deleted file mode 100755
index 3cb56a4..0000000
--- a/local/sbin/syncemail
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/python2
-# This starts offlineimap, but first it requests passwords from pass
-import os
-import sys
-import subprocess
-import daemon
-import lockfile
-import syslog
-from offlineimap import OfflineImap
-
-pidfile = '/tmp/syncemail-%d.pid' % os.getuid()
-
-# Check if not already running
-def check_running():
- if os.access(pidfile, os.F_OK):
- with open(pidfile, "r") as f:
- pid = f.readline()
- if os.path.exists('/proc/%s' % pid):
- sys.exit(0)
-check_running()
-
-
-accounts = [
- ["email", "mail/cynerd@email.cz"],
- ]
-
-for acc in accounts:
- pproc = subprocess.Popen("pass " + acc[1],
- stdout=subprocess.PIPE, shell=True)
- output = pproc.stdout.read().rstrip()
- if pproc.wait() != 0:
- print("Password receive failed.")
- sys.exit(1)
- sys.argv.append('-k')
- sys.argv.append('Repository_' + acc[0] + '-remote:remotepass=' + output)
-
-# Define out logger and redirect stdout and stderr to it
-class logstd:
- def write(self, data):
- syslog.syslog(data)
-
-with daemon.DaemonContext():
- check_running()
- with open(pidfile, "w") as f:
- f.write("%s" % os.getpid())
- syslog.openlog('syncemail')
- sys.stderr = sys.stdout = logstd()
- OfflineImap().run()
diff --git a/local/sbin/user-service.sh b/local/sbin/user-service.sh
deleted file mode 100755
index 632272c..0000000
--- a/local/sbin/user-service.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/sh
-set -e
-
-[ -z "$1" ] && {echo "Run this script only from user-service file!" && exit 1}
-
-# Name of service
-NAME="$(basename "$1")"
-SERVICE="$1"
-
-# Source input file
-. "$1"
-shift
-
-OP="status"
-Q=true
-# Parse arguments
-while [ -n "$1" ]; do
- case "$1" in
- -h|--help)
- echo "User service: $NAME"
- echo " $description"
- echo "$SERVICE [OPTION]... OPERATION"
- echo " Options:"
- echo " -q - be quiet"
- echo " Operations:"
- echo " status - show status of service"
- echo " start - start service"
- echo " stop - stop service"
- echo " restart - restart service"
- echo " ifrestart - restart service if it's running"
- ;;
- -q)
- Q=false
- ;;
- status|start|stop|restart)
- OP="$1"
- ;;
- *)
- echo "Unknown argument: $1"
- exit 1
- ;;
- esac
- shift
-done
-
-case "$OP" in
- status)
- if status; then
- $Q && echo "Service $NAME is running"
- exit 0
- else
- $Q && echo "Service $NAME is not running"
- exit 1
- fi
- ;;
- start)
- $Q && echo -n "Starting service $NAME..."
- if start; then
- $Q && echo " ok"
- else
- $Q && echo " fail"
- exit 1
- fi
- ;;
- stop)
- $Q && echo -n "Stopping service $NAME..."
- if stop; then
- $Q && echo " ok"
- else
- $Q && echo " fail"
- exit 1
- fi
- ;;
- restart)
- $Q && echo "Restarting service $NAME..."
- if ! stop; then
- $Q && echo " stop failed"
- exit 1
- fi
- if start; then
- $Q && echo " ok"
- else
- $Q && echo " start failed"
- exit 1
- fi
- ;;
- ifrestart)
- $Q && echo "Restarting service $NAME..."
- if status; then
- if ! stop; then
- $Q && echo " stop failed"
- exit 1
- fi
- if start; then
- $Q && echo " ok"
- else
- $Q && echo " start failed"
- exit 1
- fi
- fi
- ;;
- *)
- echo "Invalid operation!"
- exit 3
- ;;
-esac