├── lockscreen.sh ├── savepower.sh ├── udevil_open_dir.sh ├── functions.sh ├── proxy ├── ssh_sample.sh └── http_sample.conf ├── unpackgbk.sh ├── random-wallpaper-from-unsplash.sh ├── move_dir.sh ├── random_wallpaper.sh ├── killer.sh ├── vps ├── backup.sh └── dropbox_uploader.sh ├── remove_wallpaper.sh ├── punzip.php ├── create_webapp.sh ├── vpnmgr.sh ├── karabiner-elements-profile-switcher.php ├── xosd_brightness.sh ├── dpms-sitter.sh ├── wm.sh ├── README.mkd ├── xosd_volume.sh ├── udev.py ├── switch_hosts.sh ├── dualhead.sh ├── evilclaw ├── prxmgr.sh └── yyets.py /lockscreen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Lock screen 3 | 4 | if grep Ubuntu /etc/issue > /dev/null 2>&1; then 5 | gnome-screensaver-command -l 6 | fi 7 | -------------------------------------------------------------------------------- /savepower.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Description: Set cpufreq to powersave mode, dual core only 3 | # Depends on: cpufreq 4 | 5 | for i in 0 1; do sudo cpufreq-set -c $i -g powersave; done 6 | -------------------------------------------------------------------------------- /udevil_open_dir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Description: Open dir with ROX when usb disks is plugged in. 3 | # Author: Donie Leigh 4 | 5 | export DISPLAY=:0.0 6 | export XAUTHORITY=~/.Xauthority 7 | rox ${2##* } >> /tmp/z.joy 2>&1 8 | -------------------------------------------------------------------------------- /functions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | roar() { 4 | echo "$@" >&2 5 | } 6 | die() { 7 | test $# -gt 1 && s="$2" || s=1 8 | roar "$1" && exit "$s" 9 | } 10 | 11 | trim() { 12 | local var=$1 13 | var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters 14 | var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters 15 | echo -n "$var" 16 | } 17 | strip_file_extension() { 18 | echo ${1%.*} 19 | } 20 | -------------------------------------------------------------------------------- /proxy/ssh_sample.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/expect 2 | # An Expect script which establishes an SSH proxy listening port 1080. 3 | # Lenin Lee 4 | # HOST: The SSH server address or hostname. 5 | # LOGIN_NAME: The login name. 6 | # PASSWORD: The login password. 7 | 8 | set timeout 60 9 | 10 | spawn /usr/bin/ssh -D 1080 -g LOGIN_NAME@HOST 11 | 12 | expect { 13 | "password:" { 14 | send "PASSWORD\r" 15 | } 16 | } 17 | 18 | interact { 19 | timeout 60 { 20 | send " " 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /unpackgbk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Unzip .zip packages which encoded in GBK 3 | # Prerequisites: 7z, convmv 4 | 5 | PKG=$1 6 | DIR=`basename $PKG` 7 | DIR=${DIR%.*} 8 | TMP=`mktemp -d --tmpdir='.' 'unpack.XXXXXX'` 9 | LC_ALL=zh_CN.GBK 7z e $PKG -o$TMP 10 | if [ "$TMP" != "" -a -d "$TMP" ]; then 11 | cd "$TMP" 12 | convmv --notest -f gbk -t utf8 * 13 | cnt=`ls|wc -l` 14 | [ $cnt -eq 1 ] && mv * .. && cd .. && rmdir "$TMP" 15 | [ $cnt -gt 1 ] && ! [ -d $DIR ] && cd .. && mv "$TMP" "$DIR" || echo "$DIR already exists or failed renaming the temp dir." >&2 16 | fi 17 | -------------------------------------------------------------------------------- /random-wallpaper-from-unsplash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CMD=/usr/bin/unsplash-wallpaper 4 | DIR=/tmp/random-wallpaper-from-unsplash 5 | 6 | if [[ ! -x $CMD ]]; then 7 | echo "unsplash-wallpaper not found" >&2 8 | exit 1 9 | fi 10 | 11 | if [[ ! -d $DIR ]]; then 12 | mkdir -p $DIR 13 | if [[ $? -ne 0 ]]; then 14 | exit 1 15 | fi 16 | fi 17 | 18 | $CMD random -d $DIR 19 | if [[ $? -ne 0 ]]; then 20 | echo "Failed downloading wallpaper." >&2 21 | exit 1 22 | fi 23 | 24 | mv $DIR/wallpaper-* $HOME/.wallpaper 25 | 26 | feh --bg-scale $HOME/.wallpaper 27 | -------------------------------------------------------------------------------- /move_dir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Move directories, handling conditions when the target already exits 3 | # Author: Donie Leigh 4 | 5 | OVERWRITE=0 6 | while getopts 'o' OPT; do 7 | case "$OPT" in 8 | "o") OVERWRITE=1; shift;; 9 | esac 10 | done 11 | if [ $# -ne 2 ] || ! [ -d "$1" ] || ([ -e "$2" ] && ! [ -d "$2" ]); then 12 | echo "Usage: $0 [OPTIONS] SRC_DIR TARGET_DIR" >&2 13 | exit 1 14 | fi 15 | ! test -e "$2" && mv "$1" "$2" && exit 0 16 | if [ $OVERWRITE -eq 1 ]; then 17 | cp -rf "$1"/. "$2"/ && rm -rf "$1" 18 | else 19 | cp -rf "$1" "$2" && rm -rf "$1" 20 | fi 21 | -------------------------------------------------------------------------------- /random_wallpaper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WALLPAPER_DIR="/home/monk/images" 4 | WALLPAPER_LINK="/home/monk/.wallpaper" 5 | WALLPAPER_FILE=`readlink -f "$WALLPAPER_LINK"` 6 | 7 | IMG_COUNT=`ls $WALLPAPER_DIR/*.{jpg,png}|wc -l` 8 | 9 | while true; do 10 | RAND=$((RANDOM % IMG_COUNT + 1)) 11 | IMG=`ls $WALLPAPER_DIR/*.{jpg,png}|sed -n ${RAND}p` 12 | # echo "$IMG" >> ~/log.txt 13 | # echo ${RAND}/${IMG_COUNT} >> ~/log.txt 14 | if [[ "$IMG" == "$WALLPAPER_FILE" ]]; then 15 | continue 16 | fi 17 | 18 | ln -sf "$IMG" "$WALLPAPER_LINK" 19 | feh --bg-scale "$WALLPAPER_LINK" 20 | break 21 | done 22 | -------------------------------------------------------------------------------- /killer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Kill all processes matching the given keyword, sweet for those started with long commandlines. 3 | # Caution: This script may cause serious problems if abused. 4 | 5 | ps aux|grep -v $0|grep -v grep|grep $1 6 | 7 | while [ 1 -eq 1 ]; do 8 | echo 9 | echo "Kill them all ? (y/N)" 10 | read order 11 | case $order in 12 | n|N|'') 13 | echo 'Task abandoned.' 14 | exit 15 | ;; 16 | y|Y) 17 | ps aux|grep -v $0|grep -v grep|grep $1|awk '{ print $2 }'|xargs sudo kill -9 18 | echo 'Processes killed.' 19 | exit 20 | ;; 21 | esac 22 | done 23 | -------------------------------------------------------------------------------- /vps/backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR="/root" 4 | NOW=$(date +"%Y%m%d") 5 | TMP_PATH='/tmp' 6 | DOCKER_ID_TTRSS='39cec6a7dcb7' 7 | TTRSS_DB="$TMP_PATH/ttrss.sql" 8 | BAK_FILE_NAME="vps-$NOW.tar.gz" 9 | BAK_FILE="$TMP_PATH/$BAK_FILE_NAME" 10 | DROPBOX_DIR="" 11 | 12 | docker exec "$DOCKER_ID_TTRSS" /usr/bin/pg_dump ttrss > "$TTRSS_DB" 13 | echo "数据库备份完成,打包网站数据中..." 14 | tar cfzP "$BAK_FILE" "$TTRSS_DB" 15 | echo "所有数据打包完成,准备上传..." 16 | # 用脚本上传到dropbox 17 | "$SCRIPT_DIR"/dropbox_uploader.sh upload "$BAK_FILE" "$DROPBOX_DIR/$BAK_FILE_NAME" 18 | if [ $? -eq 0 ];then 19 | echo "上传完成" 20 | else 21 | echo "上传失败,重新尝试" 22 | fi 23 | 24 | # 删除本地的临时文件 25 | rm -f "$TTRSS_DB" "$BAK_FILE" 26 | -------------------------------------------------------------------------------- /remove_wallpaper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Remove the current wallpaper 3 | # Author: Donie Leigh 4 | 5 | WALLPAPER_LINK=~/.wallpaper 6 | WALLPAPER_FILE=`readlink -f "$WALLPAPER_LINK"` 7 | RAND_WALLPAPER_SCRIPT=~/bin/random_wallpaper 8 | 9 | error() { # Alert error message 10 | zenity --error --text="$1" 11 | } 12 | confirm() { # Ask for confirmation 13 | zenity --question --text="$1" 14 | } 15 | 16 | ! test -f "$WALLPAPER_LINK" && error "$WALLPAPER_LINK does not exist." && exit 1 17 | ! test -f "$WALLPAPER_FILE" && error "$WALLPAPER_FILE does not exist." && exit 1 18 | 19 | confirm "Are you sure to delete $WALLPAPER_FILE ?" 20 | if [ $? -eq 0 ]; then 21 | /bin/rm -f "$WALLPAPER_FILE" 22 | "$RAND_WALLPAPER_SCRIPT" 23 | fi 24 | -------------------------------------------------------------------------------- /punzip.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 4 | 5 | APP_DIR="$HOME/bin" 6 | APP_NAME=`zenity --entry \ 7 | --title="Input App Name" \ 8 | --text="Enter name of the app:" \ 9 | --entry-text "sample"` 10 | APP_URL=`zenity --entry \ 11 | --title="Input App URL" \ 12 | --text="Enter URL of the app:" \ 13 | --entry-text "sample"` 14 | APP_FILE="$APP_DIR/$APP_NAME" 15 | 16 | die() 17 | { 18 | echo "$@" >&2 && exit 1 19 | } 20 | 21 | ! [[ "$APP_NAME" =~ ^[a-zA-Z0-9_]+$ ]] && die "Invalid app name, only letters, numbers and _ are allowed." 22 | [ -e "$APP_DIR/$APP_NAME" ] && die "An app with the same name already exists." 23 | 24 | SCRIPT=$(cat <