From ae31b055c2446e9c466d2712b8a4b38a01693d89 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Mon, 3 Dec 2018 17:20:17 -0500 Subject: [PATCH] Wrote combined setup scripts for user and root --- configs/i3blocks-scripts/wifi | 7 +++- configs/i3blocks/i3blocks.conf | 2 +- dotfiles/vimrc | 2 +- root-setup.sh | 33 ++++++++++++++++ scripts/shortcuts.sh | 4 +- setup.sh | 72 ++++++++++++++++++++++++++++++++++ txt/key_files.txt | 4 +- 7 files changed, 116 insertions(+), 8 deletions(-) create mode 100755 root-setup.sh create mode 100755 setup.sh diff --git a/configs/i3blocks-scripts/wifi b/configs/i3blocks-scripts/wifi index ce3431c..96a6dee 100755 --- a/configs/i3blocks-scripts/wifi +++ b/configs/i3blocks-scripts/wifi @@ -17,17 +17,20 @@ #------------------------------------------------------------------------ INTERFACE="${BLOCK_INSTANCE:-wlan0}" +echo $INTERFACE +# INTERFACE="${INSTANCE}" #------------------------------------------------------------------------ # As per #36 -- It is transparent: e.g. if the machine has no battery or wireless # connection (think desktop), the corresponding block should not be displayed. -[[ ! -d /sys/class/net/${INTERFACE}/wireless ]] || - [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && exit +# [[ ! -d /sys/class/net/${INTERFACE}/wireless ]] || + # [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && exit #------------------------------------------------------------------------ QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') +echo $QUALITY W_inter=$(ip link | grep "[1-9]: wlp" | cut -d " " -f2 | tr -d ':') W_name=$(nmcli d | grep "$W_inter" | awk '{print $4}') diff --git a/configs/i3blocks/i3blocks.conf b/configs/i3blocks/i3blocks.conf index a0fca92..de58962 100644 --- a/configs/i3blocks/i3blocks.conf +++ b/configs/i3blocks/i3blocks.conf @@ -41,7 +41,7 @@ color=#cccccc # [wifi] # label= -# instance=wlp3s0 +# instance=wlp4s0 # interval=10 # unbold this? diff --git a/dotfiles/vimrc b/dotfiles/vimrc index 35305c5..7ef9f07 100644 --- a/dotfiles/vimrc +++ b/dotfiles/vimrc @@ -37,7 +37,7 @@ autocmd Filetype css,htmldjango,html,tex,txt,markdown set tabstop=2 shiftwidth=2 autocmd BufNewFile,BufRead *.md set filetype=markdown autocmd Filetype markdown set textwidth=0 -autocmd BufWritePost key_*.txt !bash ~/linux-config/shortcuts.sh +autocmd BufWritePost key_*.txt !bash ~/linux-config/scripts/shortcuts.sh " }}} commands for file types " diff --git a/root-setup.sh b/root-setup.sh new file mode 100755 index 0000000..09f7f48 --- /dev/null +++ b/root-setup.sh @@ -0,0 +1,33 @@ +#!/bin/zsh + +setup_marble=false + +linux_config_dir=/home/kevin/linux-config +dot_dir=$linux_config_dir/dotfiles +pc=$(hostname) + +# Get directory variables from script. +# List of dotfiles I want to link to system. +dotfiles=(bashrc gitconfig inputrc imwheelrc vimrc Xmodmap Xresources zshrc) +cd $dot_dir +for dotfile in $dotfiles; do + # Remove system dotfile. + rm ~/."$dotfile" + # Link dotfile in repository to system dotfile. + cp "$dot_dir"/"$dotfile" ~/."$dotfile" +done + +# marble mouse {{{ # + +if [[ "$setup_marble" = true ]]; then + config_file_name="10-evdev.conf" + sys_layout_file="/etc/X11/xorg.conf.d/$config_file_name" + config_dir="$linux_config_dir/x/marble-mouse" + + # Remove system file. + sudo rm -rf "$sys_layout_file" + # Link config file in repository to system config location. + sudo cp "$config_dir"/"$config_file_name" "$sys_layout_file" +fi + +# }}} marble mouse # diff --git a/scripts/shortcuts.sh b/scripts/shortcuts.sh index b3112f8..e3d9771 100755 --- a/scripts/shortcuts.sh +++ b/scripts/shortcuts.sh @@ -4,8 +4,8 @@ shellrc="$HOME/.zshrc" # Config locations -folders="$HOME/linux-config/key_dirs.txt" -configs="$HOME/linux-config/key_files.txt" +folders="$HOME/linux-config/txt/key_dirs.txt" +configs="$HOME/linux-config/txt/key_files.txt" # Output locations shell_shortcuts="$HOME/.shortcuts" diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..0a4364a --- /dev/null +++ b/setup.sh @@ -0,0 +1,72 @@ +#!/bin/zsh + +setup_marble=true + +# vars {{{ # + +linux_config_dir=/home/kevin/linux-config +dot_dir=$linux_config_dir/dotfiles +config_dir=$linux_config_dir/configs +sys_config_dir=~/.config +pc=$(hostname) + +# }}} vars # + +# dotfiles {{{ # + +# link files {{{ # + +# Get directory variables from script. +# List of dotfiles I want to link to system. +dotfiles=(bashrc gitconfig inputrc imwheelrc vimrc xinitrc Xmodmap Xresources zshrc) +cd $dot_dir +for dotfile in $dotfiles; do + # Remove system dotfile. + rm ~/."$dotfile" + # Link dotfile in repository to system dotfile. + ln -s "$dot_dir"/"$dotfile" ~/."$dotfile" && echo "Linked .$dotfile." +done + +# }}} link files # + +# setup nvim config {{{ # + +orig_file="$sys_config_dir"/nvim/init.vim +# Remove system dotfile. +rm "$orig_file" +# Link dotfile in repository to system dotfile. +ln -s "$dot_dir"/nvim "$orig_file" && echo "Setup Neovim config." + +# }}} setup nvim config # + +# }}} dotfiles # + +# configs {{{ # + +cd $linux_config_dir +# List of config dirs in system config dir that I want to link to. +config_dirs=(neofetch i3 i3blocks sam-i3blocks ranger) +# config_dirs=(neofetch i3 i3blocks ranger) +for cur_dir in $config_dirs; do + # Remove system file. + rm -rf "$sys_config_dir"/"$cur_dir" + # Link config file in repository to system config location. + ln -s "$config_dir"/"$cur_dir" "$sys_config_dir"/"$cur_dir" && echo "Linked $cur_dir config." +done + +# }}} configs # + +# marble mouse {{{ # + +if [[ "$setup_marble" = true ]]; then + config_file_name="10-evdev.conf" + sys_layout_file="/etc/X11/xorg.conf.d/$config_file_name" + config_dir="$linux_config_dir/x/marble-mouse" + + # Remove system file. + sudo rm -rf "$sys_layout_file" + # Link config file in repository to system config location. + sudo ln -s "$config_dir"/"$config_file_name" "$sys_layout_file" && echo "Setup Marble mouse config." +fi + +# }}} marble mouse # diff --git a/txt/key_files.txt b/txt/key_files.txt index 72c30fc..9ecd38e 100644 --- a/txt/key_files.txt +++ b/txt/key_files.txt @@ -2,8 +2,8 @@ 3 ~/.config/i3/config 3b ~/.config/i3blocks/i3blocks.conf -d ~/linux-config/key_dirs.txt -f ~/linux-config/key_files.txt +d ~/linux-config/txt/key_dirs.txt +f ~/linux-config/txt/key_files.txt r ~/.config/ranger/rc.conf sr ~/linux-config/configs/ranger/shortcuts.conf ss ~/.shortcuts