More config cleanup
Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
parent
005c4f29b6
commit
8d3f9c8a1d
22 changed files with 44 additions and 27 deletions
33
system/.local/bin/gw2.sh
Executable file
33
system/.local/bin/gw2.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# gw2.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Starts Guild Wars 2 inside Wine.
|
||||
#
|
||||
# USAGE:
|
||||
# ./gw2.sh
|
||||
# Set custom wineprefix
|
||||
export WINEPREFIX="${HOME}/Games/Guild_Wars_2/"
|
||||
|
||||
# Set wine to 64-bit
|
||||
export WINEARCH=win64
|
||||
|
||||
# Optimize performance
|
||||
export __GL_THREADED_OPTIMIZATIONS=0
|
||||
export __GL_SYNC_TO_VBLANK=0
|
||||
export __GL_YIELD="NOTHING"
|
||||
|
||||
# Disable debug messages
|
||||
export WINEDEBUG=-all
|
||||
export LOGFILE=/dev/null
|
||||
|
||||
# Enable esync
|
||||
export WINEESYNC=1
|
||||
|
||||
# Run it using optirun
|
||||
optirun -b primus wine64 "${WINEPREFIX}/drive_c/Program Files/Guild Wars 2/Gw2-64.exe" -dx9single -mapLoadInfo
|
18
system/.local/bin/increase_volume.sh
Executable file
18
system/.local/bin/increase_volume.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# increase_volume.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script uses pamixer to increase the volume by 5% as long
|
||||
# as the current volume is less than 150%. I call this script
|
||||
# using custom i3 keybindings.
|
||||
#
|
||||
# USAGE:
|
||||
# ./increase_volume.sh
|
||||
if [[ $(pamixer --get-volume) -lt 150 ]]; then
|
||||
pamixer -i 5 --allow-boost
|
||||
fi
|
36
system/.local/bin/music.sh
Executable file
36
system/.local/bin/music.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# music.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Prints out the title of the current playing song using cmus-remote.
|
||||
#
|
||||
# USAGE:
|
||||
# ./music.sh
|
||||
|
||||
QUERY="$(cmus-remote -Q)"
|
||||
|
||||
STATUS="$(echo "$QUERY" | grep -e "status " | cut -d " " -f 2)"
|
||||
ARTIST="$(echo "$QUERY" | grep -e " artist " | cut -d " " -f 3-)"
|
||||
ALBUM="$(echo "$QUERY" | grep -e " album " | cut -d " " -f 3-)"
|
||||
TITLE="$(echo "$QUERY" | grep -e " title " | cut -d " " -f 3-)"
|
||||
position="$(echo "$QUERY" | grep -e "position " | cut -d " " -f 2)"
|
||||
duration="$(echo "$QUERY" | grep -e "duration " | cut -d " " -f 2)"
|
||||
|
||||
if [ "$STATUS" != "playing" ]; then
|
||||
OUTPUT="Not playing"
|
||||
else
|
||||
pos_minutes=$(printf "%02d" $(("$position" / 60)))
|
||||
pos_seconds=$(printf "%02d" $(("$position" % 60)))
|
||||
|
||||
dur_minutes=$(printf "%02d" $(("$duration" / 60)))
|
||||
dur_seconds=$(printf "%02d" $(("$duration" % 60)))
|
||||
|
||||
OUTPUT="$ARTIST | $ALBUM | $TITLE | $pos_minutes:$pos_seconds / $dur_minutes:$dur_seconds"
|
||||
fi
|
||||
|
||||
echo "$OUTPUT"
|
41
system/.local/bin/power.sh
Executable file
41
system/.local/bin/power.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# power.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Displays a power menu using zenity.
|
||||
#
|
||||
# USAGE:
|
||||
# ./power.sh
|
||||
|
||||
TEXT="Choose action"
|
||||
WIDTH=400
|
||||
HEIGHT=300
|
||||
ACTIONS=(
|
||||
"Reboot"
|
||||
"Shutdown"
|
||||
"Performance Mode"
|
||||
"Powersave Mode"
|
||||
)
|
||||
|
||||
action=$(zenity --list --width="${WIDTH}" --height="${HEIGHT}" --text="${TEXT}" --column="Action" "${ACTIONS[@]}")
|
||||
|
||||
echo "$action"
|
||||
if [ "${action}" == "Reboot" ]
|
||||
then
|
||||
systemctl reboot
|
||||
elif [ "${action}" == "Shutdown" ]
|
||||
then
|
||||
systemctl poweroff
|
||||
elif [ "${action}" == "Performance Mode" ]
|
||||
then
|
||||
gksudo "cpupower frequency-set -g performance"
|
||||
elif [ "${action}" == "Powersave Mode" ]
|
||||
then
|
||||
gksudo "cpupower frequency-set -g powersave"
|
||||
fi
|
||||
|
16
system/.local/bin/resolution.sh
Executable file
16
system/.local/bin/resolution.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# resolution.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This is the script that is used to setup my monitors. This script
|
||||
# is used by i3 and lightdm.
|
||||
#
|
||||
# USAGE:
|
||||
# ./resolution.sh
|
||||
#xrandr --setprovideroutputsource modesetting NVIDIA-0
|
||||
xrandr --output HDMI3 --off --output HDMI2 --off --output HDMI-1 --mode 1280x1024 --pos 80x56 --rotate normal --output eDP-1 --primary --mode 1920x1080 --pos 1360x0 --rotate normal --output DP3 --off --output DP2 --off --output DP1 --off
|
15
system/.local/bin/screenlock.sh
Executable file
15
system/.local/bin/screenlock.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# screenlock.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script locks the screen using i3lock-fancy. This script is called
|
||||
# using a custom i3 keybinding.
|
||||
#
|
||||
# USAGE:
|
||||
# ./screenlock.sh
|
||||
i3lock-fancy -f "Noto Sans"
|
23
system/.local/bin/server.sh
Executable file
23
system/.local/bin/server.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# server.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script starts / stops the Apache and MariaDB servers.
|
||||
#
|
||||
# USAGE:
|
||||
# ./server.sh start|stop
|
||||
if [ "${1}" == "start" ]; then
|
||||
sudo systemctl start httpd.service
|
||||
sudo systemctl start mariadb.service
|
||||
elif [ "${1}" == "stop" ]; then
|
||||
sudo systemctl stop httpd.service
|
||||
sudo systemctl stop mariadb.service
|
||||
else
|
||||
echo "${1} is an unknown option"
|
||||
exit 0
|
||||
fi
|
55
system/.local/bin/submodule_update.sh
Executable file
55
system/.local/bin/submodule_update.sh
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# submodule_update.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Updates the submodules in all Git repositories in this folder and creates a
|
||||
# new commit and pushes it. Only when there are no staged changes pending.
|
||||
#
|
||||
# USAGE:
|
||||
# ./submodule_update.sh
|
||||
. utils.sh
|
||||
|
||||
START_DIR=$(pwd)
|
||||
|
||||
print_header "Updating submodules"
|
||||
|
||||
|
||||
while IFS= read -r -d '' dir
|
||||
do
|
||||
cd "$dir" || exit 1
|
||||
cd .. || exit 1
|
||||
print_section "Checking $(pwd)"
|
||||
|
||||
if [ -z "$(git status --porcelain)" ]
|
||||
then
|
||||
print_log "No pending changes"
|
||||
print_log "Updating submodules"
|
||||
git pl > /dev/null 2>&1
|
||||
|
||||
# Check if any changes are available
|
||||
if [ -z "$(git status --porcelain)" ]
|
||||
then
|
||||
print_log "No updates found"
|
||||
else
|
||||
print_log "Updates found"
|
||||
print_log "Creating commit"
|
||||
git a > /dev/null 2>&1
|
||||
git c -m "Update submodules" > /dev/null 2>&1
|
||||
print_log "Pushing commit"
|
||||
git p > /dev/null 2>&1
|
||||
print_log "Commit was pushed"
|
||||
fi
|
||||
else
|
||||
print_log "Pending changes. Ignoring"
|
||||
fi
|
||||
|
||||
echo -e ""
|
||||
|
||||
cd "${START_DIR}" || exit 1
|
||||
|
||||
done < <(find . -name .git -type d -prune -print0)
|
26
system/.local/bin/twitch.sh
Executable file
26
system/.local/bin/twitch.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# twitch.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script loads a Twitch livestream in a local video player
|
||||
# using streamlink.
|
||||
#
|
||||
# USAGE:
|
||||
# ./twitch.sh USERNAME [RESOLUTION]
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Please enter a username!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $2 ]]; then
|
||||
resolution="best"
|
||||
else
|
||||
resolution="${2}"
|
||||
fi
|
||||
|
||||
streamlink "https://twitch.tv/${1}" "${resolution}"
|
22
system/.local/bin/upgrade.sh
Executable file
22
system/.local/bin/upgrade.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# upgrade.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script upgrades all pacman packages and globally installed
|
||||
# npm packages.
|
||||
#
|
||||
# USAGE:
|
||||
# ./upgrade.sh
|
||||
. utils.sh
|
||||
|
||||
print_header "Upgrading system"
|
||||
print_section "Update arch packages"
|
||||
yay -Syu --devel
|
||||
|
||||
print_section "Update npm packages"
|
||||
npm update -g
|
105
system/.local/bin/utils.sh
Executable file
105
system/.local/bin/utils.sh
Executable file
|
@ -0,0 +1,105 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# utils.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script provides functions and variables that I use in my other scripts.
|
||||
# It is not supposed to be run directly but to be sourced by other scripts.
|
||||
#
|
||||
# USAGE:
|
||||
# Source this script in the needed script.
|
||||
#######################################
|
||||
# Directory variables
|
||||
#######################################
|
||||
DIR="$( cd "$(dirname "${BASH_SOURCE[0]}" )" && cd ../../../ && pwd)"
|
||||
SYSTEM_DIR="${DIR}/system"
|
||||
PACKAGES_DIR="${DIR}/packages"
|
||||
|
||||
#######################################
|
||||
# Bash color code variables
|
||||
#######################################
|
||||
RESET='\033[0m'
|
||||
GREEN='\033[32m'
|
||||
RED='\033[31m'
|
||||
BLUE='\033[34m'
|
||||
YELLOW='\033[33m'
|
||||
|
||||
#######################################
|
||||
# Helper functions
|
||||
#######################################
|
||||
# Function to display fancy headers
|
||||
# USAGE: print_header TITLE
|
||||
function print_header() {
|
||||
echo -e "\n${GREEN}╔══════════════════════════════════════════════════════════════════════════════╗"
|
||||
echo -e "║ $(printf "%-77s" "${1}")║"
|
||||
echo -e "╚══════════════════════════════════════════════════════════════════════════════╝${RESET}"
|
||||
}
|
||||
|
||||
# Function to print a info message with the current time and to send
|
||||
# a notification using notify-send.
|
||||
# USAGE: print_notify TITLE MESSAGE
|
||||
function print_notify() {
|
||||
notify-send "${1}" "${2}"
|
||||
echo -e "${YELLOW}[$(date "+%H:%M:%S")] ${1} ${2}${RESET}"
|
||||
}
|
||||
|
||||
# Prints a section title.
|
||||
# USAGE: print_section TITLE
|
||||
function print_section() {
|
||||
echo -e "${YELLOW}┌──────────────────────────────────────────────────────────────────────────────┐"
|
||||
echo -e "│ $(printf "%-77s" "${1}")│"
|
||||
echo -e "└──────────────────────────────────────────────────────────────────────────────┘${RESET}"
|
||||
}
|
||||
|
||||
function print_log() {
|
||||
echo -e "• $1"
|
||||
}
|
||||
|
||||
# Creates the given directory in the home directory
|
||||
# USAGE: create_directory DIRECTORY
|
||||
function create_directory() {
|
||||
print_log "Creating directory ${YELLOW}${HOME}/${1}${RESET}"
|
||||
mkdir -p "${HOME}/${1}"
|
||||
}
|
||||
|
||||
# Creates a symlink of the given file from the home directory to here.
|
||||
# USAGE: create_link FILE
|
||||
function create_link() {
|
||||
print_log "Linking ${YELLOW}${HOME}/${1}${RESET} -> ${YELLOW}${SYSTEM_DIR}/${1}${RESET}"
|
||||
rm -rf "${HOME:?}/$1"
|
||||
ln -fs "${SYSTEM_DIR}/${1}" "${HOME}/${1}"
|
||||
}
|
||||
|
||||
# Function to set owner and permission of a file
|
||||
# USAGE: set_permission OWNER PERMISSION FILE
|
||||
function set_permission() {
|
||||
print_log "Changing owner of ${YELLOW}${3}${RESET} to ${YELLOW}${1}${RESET}"
|
||||
sudo chown -R "${1}" "${3}"
|
||||
print_log "Changing permission of ${YELLOW}${3}${RESET} to ${YELLOW}${2}${RESET}"
|
||||
sudo chmod -R "${2}" "${3}"
|
||||
}
|
||||
|
||||
# Function to add a user to a group
|
||||
# USAGE add_to_group USER GROUP
|
||||
function add_to_group() {
|
||||
print_log "Add user ${YELLOW}${1}${RESET} to group ${YELLOW}${2}${RESET} "
|
||||
sudo gpasswd -a "${1}" "${2}" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to enable a service
|
||||
# USAGE: enable_service SERVICE
|
||||
function enable_service() {
|
||||
print_log "Enabling service ${YELLOW}${1}${RESET}"
|
||||
sudo systemctl enable "${1}"
|
||||
}
|
||||
|
||||
# Function to copy a udev rule to /etc/udev/rules.d/
|
||||
# USAGE: copy_udev_rules FILE
|
||||
function copy_udev_rule() {
|
||||
print_log "Copying ${YELLOW}$(basename "${1}")${RESET} to ${YELLOW}/etc/udev/rules.d/${RESET}"
|
||||
sudo cp "${1}" "/etc/udev/rules.d/"
|
||||
}
|
30
system/.local/bin/watch.sh
Executable file
30
system/.local/bin/watch.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT NAME:
|
||||
# watch.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Severin Kaderli <severin.kaderli@gmail.com>
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script watches a file for changes and if it changes it
|
||||
# executes the given command.
|
||||
#
|
||||
# USAGE:
|
||||
# ./watch.sh FILE COMMAND...
|
||||
. utils.sh
|
||||
|
||||
# The file to watch
|
||||
FILE="${1}"
|
||||
FILENAME=$(basename "${FILE}")
|
||||
|
||||
# The rest of the arguments is the command
|
||||
shift
|
||||
COMMAND="${*}"
|
||||
|
||||
print_section "Watching ${FILE}"
|
||||
while inotifywait -qq -e close_write "${FILE}";
|
||||
do
|
||||
print_notify "${FILENAME} has changed" "Executing command"
|
||||
$COMMAND
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue