From 333c953fb084ab2c1e351631f0749a4b45209e7a Mon Sep 17 00:00:00 2001 From: Yigit Colakoglu Date: Fri, 12 Nov 2021 16:07:59 +0100 Subject: [PATCH] Edited some scripts, and updated dwm so that it is better --- .config/X11/xinitrc | 2 -- .config/doom/config.el | 3 ++ .config/vim/vimrc | 6 ---- .config/zsh/.zshrc | 7 ++--- .local/bin/backup | 22 +++++++++------ .local/bin/calconsync | 2 +- .local/bin/dmenu-refresh | 7 +++-- .local/bin/dmenu-xrandr | 52 +++++++++++------------------------ .local/share/bookmarks | 3 ++ .local/share/dwm/autostart.sh | 2 +- .local/src/dwm/keybinds.h | 5 ++-- .local/src/dwm/rules.h | 1 + .profile | 6 +--- 13 files changed, 47 insertions(+), 71 deletions(-) diff --git a/.config/X11/xinitrc b/.config/X11/xinitrc index feb96299..0ccbfb80 100755 --- a/.config/X11/xinitrc +++ b/.config/X11/xinitrc @@ -19,8 +19,6 @@ export XSESSION_PID="$$" source ~/.config/config.env - - pactl upload-sample /usr/share/sounds/freedesktop/stereo/bell.oga x11-bell pactl load-module module-x11-bell sample=x11-bell display=$DISPLAY xset b 100 diff --git a/.config/doom/config.el b/.config/doom/config.el index d307425b..85ffe5ff 100644 --- a/.config/doom/config.el +++ b/.config/doom/config.el @@ -38,6 +38,9 @@ user-mail-address "yigit@yigitcolakoglu.com") (setq evil-vsplit-window-right t evil-split-window-below t) +(require 'gas-mode) +(add-to-list 'auto-mode-alist '("\\.S\\'" . gas-mode)) + (require 'bison-mode) (after! bison-mode-hook (setq imenu-create-index-function diff --git a/.config/vim/vimrc b/.config/vim/vimrc index 3c753763..1482b10f 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -205,12 +205,6 @@ if has('nvim') let g:Tlist_WinWidth = 40 " Tlist endif -let hostname = substitute(system('hostname'), '\n', '', '') - -if hostname == "workstation" " Check for remote machine - autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | OSCYankReg " | endif" - set clipboard& clipboard^=unnamed,unnamedplus -endif " Don't clear clipboard on exit autocmd VimLeave * call system("xsel -ib", getreg('+')) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 7d25f81a..8bf763b1 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -101,11 +101,8 @@ local paste_widgets=( vi-put-{before,after} ) -# Use X11 Clipboard -if command -v xclip; then - x11-clip-wrap-widgets copy $copy_widgets - x11-clip-wrap-widgets paste $paste_widgets -fi +x11-clip-wrap-widgets copy $copy_widgets +x11-clip-wrap-widgets paste $paste_widgets # create a zkbd compatible hash; # to add other keys to this hash, see: man 5 terminfo diff --git a/.local/bin/backup b/.local/bin/backup index ec8b4214..8d4ced87 100755 --- a/.local/bin/backup +++ b/.local/bin/backup @@ -5,14 +5,18 @@ # crontab for regular backups # Config -readonly SSH_HOST=192.168.1.8 -readonly SSH_USER=yigit +readonly SSH_HOST=192.168.1.34 +readonly SSH_USER=pi readonly SSH_KEY="/home/yigit/.ssh/id_skeleton" -readonly RSYNC_PROFILE="$SSH_USER@$SSH_HOST:~/snapshots" +readonly BACKUP_DESTINATION="~/snapshots/backups" +readonly RSYNC_PROFILE="$SSH_USER@$SSH_HOST:$BACKUP_DESTINATION" + +[ $(id -u) != "0" ] && printf "This program must be run as root!\n" && exit alias ssh_cmd="ssh -i \"$SSH_KEY\" $SSH_USER@$SSH_HOST" [ -f "$XDG_CACHE_HOME/dbus_settings" ] && "$XDG_CACHE_HOME/dbus_settings" # Load the dbus settings for current session + displays="$(ps -u $(id -u) -o pid= \ | xargs -I PID -r cat /proc/PID/environ 2> /dev/null \ | tr '\0' '\n' \ @@ -48,18 +52,18 @@ timeout 3 ssh -i "$SSH_KEY" $SSH_USER@$SSH_HOST id < /dev/null > /dev/null 2> /d while IFS= read -r DIR do LINK="--link-dest=/home/$SSH_USER/snapshots/tatooine/last$DIR/" - ssh -i "$SSH_KEY" $SSH_USER@$SSH_HOST mkdir -p "~/snapshots/$DEVICE/$date$DIR" < /dev/null + ssh -i "$SSH_KEY" $SSH_USER@$SSH_HOST mkdir -p "$BACKUP_DESTINATION/$DEVICE/$date$DIR" < /dev/null rsync --exclude '.cache' "$@" -e "ssh -i $SSH_KEY" $OPT "$LINK" "$DIR/" "${SNAP}$date$DIR/" done << EOF $DIRS EOF # Remove symlink to previous snapshot -ssh_cmd rm -f "~/snapshots/$DEVICE/last" < /dev/null +ssh_cmd rm -f "$BACKUP_DESTINATION/$DEVICE/last" < /dev/null # Create new symlink to latest snapshot for the next backup to hardlink -ssh -i "$SSH_KEY" $SSH_USER@$SSH_HOST ln -s "~/snapshots/$DEVICE/$date" "~/snapshots/$DEVICE/last" < /dev/null +ssh -i "$SSH_KEY" $SSH_USER@$SSH_HOST ln -s "$BACKUP_DESTINATION/$DEVICE/$date" "$BACKUP_DESTINATION/$DEVICE/last" < /dev/null -pidof slock > /dev/null && { - shutdown -h now -} +# pidof slock > /dev/null && { # Shutdown if screen inhibition is enabled +# shutdown -h now +# } diff --git a/.local/bin/calconsync b/.local/bin/calconsync index 97d103bf..580f3f6a 100755 --- a/.local/bin/calconsync +++ b/.local/bin/calconsync @@ -7,7 +7,7 @@ eval "$(grep -h -- \ "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" "$HOME/.pam_environment" 2>/dev/null)" export CALCURSE_CALDAV_PASSWORD=$(pass show Server/drive.yigitcolakoglu.com/yigitcolakoglu) -calcurse-caldav +calcurse-caldav --lockfile $(mktemp) # Prevent lock file conflicts tmpfile=$(mktemp) diff --git a/.local/bin/dmenu-refresh b/.local/bin/dmenu-refresh index 01f91921..4256c870 100755 --- a/.local/bin/dmenu-refresh +++ b/.local/bin/dmenu-refresh @@ -14,7 +14,7 @@ dwmblocks mconnect dunst clipmenud -quark +darkhttpd devmon emacs mpd @@ -63,8 +63,9 @@ case $selection in --exec-on-unmount "/sbin/notify-send 'īŠ’ drive unmounted' '%l (%f) from %d '" \ --no-unmount --no-gui & ;; - quark) - sudo systemctl restart quark + darkhttpd) + killall -9 darkhttpd + darkhttpd $HOME/.local/share/startpage/dist --port 9999 --daemon --addr 127.0.0.1 ;; esac diff --git a/.local/bin/dmenu-xrandr b/.local/bin/dmenu-xrandr index 30e66d50..8f7a9ad0 100755 --- a/.local/bin/dmenu-xrandr +++ b/.local/bin/dmenu-xrandr @@ -5,7 +5,6 @@ # external commands: cat, cut, dmenu, grep, sed, xrandr # Released under GPLv2 # -# TODO: add dpi support typeset XRANDR_TXT # readonly; stdout of running xrandr without any options typeset -A OUTPUT_CONFIGURED # key=connected output name @@ -92,41 +91,6 @@ function main() { prompt='Select primary output:' output="$(menu_select "${prompt}" ${(k)=OUTPUT_CONFIGURED})" - if [ "$(pidof x11vnc)" ]; then - killvnc="$(printf "no\nyes" | dmenu -p "Would you like to kill existing vnc display?")" - if [ "$killvnc" = "yes" ]; then - xrandr --output HDMI2 --off - killall -9 x11vnc - vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect a remote display?")" - fi - else - vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect a remote display?")" - fi - if [ "$vnc" = "yes" ]; then - echo "1920x1080" | dmenu -p "Please enter resolution:" | read resolution - [ "$resolution" ] || exit 1 - printf "normal\nleft" | dmenu -p "Please enter rotation:" | read rotation - [ "$rotation" ] || exit 1 - xrandr --output HDMI2 --off - h=$(echo "$resolution" | cut -d'x' -f1) - w=$(echo "$resolution" | cut -d'x' -f2) - modeline="$(gtf $h $w 60 | tail -n 2 | xargs | sed 's/Modeline [^ ]*//g'| xargs)" - name="${h}x${w}_$$.00" - wlan="$(ip -o -4 addr list wlan0 | awk '{print $4}' | cut -d/ -f1)" - eth="$(ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)" - bash -c "xrandr --newmode \"$name\" $modeline" - if [ "$rotation" = "normal" ]; then - clip="${h}x${w}+0+0" - else - clip="${w}x${h}+0+0" - fi - xrandr --addmode HDMI2 "$name" - xrandr --output HDMI2 --rotation $rotation --mode $name --left-of $output && { x11vnc \ - -repeat -clip $clip & } || notify-send -a "Display Manager" "An issue occured" - pidof x11vnc && notify-send -t 60000 -a "ī”‚ Network info" "$(echo -e "wlan0: $wlan\neth0: $eth\nRunning on port 5900")" - daily-update -f - fi - [ "$output" = "eDP1" ] && bail 1 position='--primary' @@ -152,6 +116,22 @@ function main() { xrandr_cmd+=" --output ${output} ${position} ${rotation} ${mode}" done + if [ "$(pidof x11vnc)" ]; then + killvnc="$(printf "no\nyes" | dmenu -p "Would you like to kill existing vnc display?")" + if [ "$killvnc" = "yes" ]; then + xrandr --output HDMI2 --off + killall -9 x11vnc + vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect to your ipad?")" + fi + else + vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect to your ipad?")" + fi + + if [ "$vnc" = "yes" ]; then + $HOME/.local/bin/ipad_xrandr.sh + pidof x11vnc && notify-send -t 60000 -a "ī”‚ Network info" "$(echo -e "wlan0: $wlan\neth0: $eth\nRunning on port 5900")" + fi + # forcibly '--off' disconnected outputs for output in ${DISCONNECTED_OUTPUTS}; do xrandr_cmd+=" --output ${output} --off" diff --git a/.local/share/bookmarks b/.local/share/bookmarks index f3c5f03a..170af403 100644 --- a/.local/share/bookmarks +++ b/.local/share/bookmarks @@ -4,3 +4,6 @@ https://my.tudelft.nl https://queue.tudelft.nl https://weblab.tudelft.nl https://stackoverflow.com/c/tud-cs/questions +https://tudelft.zoom.us/j/98183250143?pwd=SXI4dUhBS0NxM1g2czd0azJTVitUdz09#success +https://collegerama.tudelft.nl/Mediasite/Channel/eemcs-bsc-cse/browse/null/most-recent/null/0/17117c0553d341f588d577f39bfe09ae14 +https://wiki.fr1nge.xyz diff --git a/.local/share/dwm/autostart.sh b/.local/share/dwm/autostart.sh index 1cad54db..6aa5ffc4 100755 --- a/.local/share/dwm/autostart.sh +++ b/.local/share/dwm/autostart.sh @@ -34,7 +34,7 @@ restart_if_fails "picom --no-fading-openclose" restart_if_fails "xbanish" # Start emacs -restart_if_fails "emacs --daemon && emacsclient -c --eval \"(delete-frame)\"" +# restart_if_fails "emacs --daemon && emacsclient -c --eval \"(delete-frame)\"" ~/.local/bin/firefox-sync & ~/.local/bin/mailsync & diff --git a/.local/src/dwm/keybinds.h b/.local/src/dwm/keybinds.h index c1f4cd8d..f2f527c2 100644 --- a/.local/src/dwm/keybinds.h +++ b/.local/src/dwm/keybinds.h @@ -46,11 +46,10 @@ static const char *notification[] = {"/home/yigit/.local/bin/dunst_toggle.sh", " static const char *screensaver[] = {"/home/yigit/.local/bin/screensaver_toggle", "-t",NULL}; -static const char *online_class[] = {"/home/yigit/.local/bin/tedportal",NULL}; +static const char *toolbelt[] = {"/home/yigit/.local/bin/toolbelt", NULL}; static const char *bwmenu[] = {"/home/yigit/.local/bin/password_manager", NULL}; - static const char *wallabag[] = {"/home/yigit/.local/bin/dmenu-wallabag", "-s", NULL}; static const char *wiki[] = {"/home/yigit/.local/bin/dmenu-arch", NULL}; @@ -152,7 +151,7 @@ static Key keys[] = { { MODKEY|Mod1Mask, XK_r, spawn, {.v = record } }, { MODKEY|ShiftMask, XK_w, spawn, {.v = wallabag} }, { MODKEY, XK_w, spawn, {.v = wiki} }, - { MODKEY, XK_t, spawn, {.v = online_class} }, + { MODKEY, XK_t, spawn, {.v = toolbelt } }, { MODKEY|ShiftMask, XK_m, spawn, {.v = mconnect} }, { MODKEY|ShiftMask, XK_l, spawn, {.v = wc } }, { MODKEY|ShiftMask, XK_d, spawn, {.v = udevil} }, diff --git a/.local/src/dwm/rules.h b/.local/src/dwm/rules.h index cf77d57e..d03b6e30 100644 --- a/.local/src/dwm/rules.h +++ b/.local/src/dwm/rules.h @@ -44,6 +44,7 @@ static const Rule rules[] = { { "htop" , NULL , NULL , 0 , 1 , "50% 50% 1200W 600H" , 0 , 0 , -1 }, { "Pavucontrol" , NULL , NULL , 0 , 1 , "50% 50% 1200W 600H" , 0 , 0 , -1 }, { "Zathura" , NULL , NULL , 0 , 0 , NULL , 0 , 1 , -1 }, +{ "Qemu-system-x86_64", NULL , NULL , 0 , 1 , NULL , 0 , 1 , -1 }, { "spfeh" , NULL , NULL , SPTAG(1) , 1 , NULL , 0 , 0 , -1 }, { NULL , "spterm" , NULL , SPTAG(0) , 1 , NULL , 0 , 0 , -1 }, { NULL , "spmutt" , NULL , SPTAG(2) , 1 , NULL , 0 , 0 , -1 }, diff --git a/.profile b/.profile index fd9da1ad..e76ee1c3 100755 --- a/.profile +++ b/.profile @@ -94,15 +94,11 @@ case "$(readlink -f /sbin/init)" in esac # Setup SSH -if [ ! "$SSH_AUTH_SOCK" ] && [ $(hostnamectl hostname) != "workstation" ]; then +if [ ! "$SSH_AUTH_SOCK" ]; then eval "$(ssh-agent | head -n 2)" grep -slR "PRIVATE" ~/.ssh/ | xargs ssh-add > /dev/null 2> /dev/null fi -if [ $(hostnamectl hostname) = "workstation" ]; then # Server specific setup - ssh-add ~/.ssh/id_skeleton > /dev/null 2> /dev/null -fi - # Start xinit if logged in from tty1 if [ "$DISPLAY" = "" ] && [ "$(tty)" = /dev/tty1 ]; then if [ "$DBUS_SESSION_BUS_ADDRESS" = "" ] && [ ! $(command -v dbus-run-session) = "" ]; then