From 614e6269026c71b0a07ba340fb0cc7230fd622aa Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Wed, 25 Dec 2024 21:14:35 +0100 Subject: [PATCH] Update scripts. --- backuper | 20 ++++++------- cue2chd | 8 +++++ day | 44 +++++++++++++++++++++++++++ external-monitor.sh | 8 ++--- gaming-time | 72 ++++++++++++++++++++++----------------------- mouse_detect.sh | 10 +++---- note | 39 ++++++++++++++++++++++++ ns | 13 ++++++++ pblog | 39 ++++++++++++++++++++++++ t | 26 ---------------- toggle-xrandr | 6 ++-- vpn | 17 ----------- 12 files changed, 201 insertions(+), 101 deletions(-) create mode 100755 cue2chd create mode 100755 day create mode 100755 note create mode 100755 ns create mode 100755 pblog delete mode 100755 t delete mode 100755 vpn diff --git a/backuper b/backuper index 13de763..e2a5657 100755 --- a/backuper +++ b/backuper @@ -1,17 +1,17 @@ #!/bin/env bash -copy () { - while read -r Line; do - echo "Syncing $(basename "$Line")" - rsync -ahAX -v --delete "$Line" "$HOME"/.local/backup - done <<< "$(cat "$HOME"/.config/rsync/sync-list)" +copy() { + while read -r Line; do + echo "Syncing $(basename "$Line")" + rsync -ahAX -v --delete "$Line" "$HOME"/.local/backup + done <<<"$(cat "$HOME"/.config/rsync/sync-list)" } -encrypt () { - x=$(date +%d.%m.%y) - cd "$HOME/.local" || exit 1 - [ ! -d "$HOME/.local/cloud" ] || mkdir -p "$HOME/.local/cloud" - tar cv -I"zstd -19 -T0" "backup" | age -r "age1chj26ez7ucr2smkr8sfc9ddaa0fcyfljh5f5uk5kuyd8ctahs9wslfs708" > "$HOME/.local/cloud/backup-$x.tar.zst.age" +encrypt() { + x=$(date +%d.%m.%y) + cd "$HOME/.local" || exit 1 + [ ! -d "$HOME/.local/cloud" ] || mkdir -p "$HOME/.local/cloud" + tar cv -I"zstd -19 -T0" "backup" | age -r "age1chj26ez7ucr2smkr8sfc9ddaa0fcyfljh5f5uk5kuyd8ctahs9wslfs708" >"$HOME/.local/cloud/backup-$x.tar.zst.age" } [ -z "$*" ] && exit 1 diff --git a/cue2chd b/cue2chd new file mode 100755 index 0000000..b6eaede --- /dev/null +++ b/cue2chd @@ -0,0 +1,8 @@ +#!/bin/sh + +for File in *.cue +do + [ -f "$File" ] || continue + chdman createcd -i "$File" -o "${File%.cue}.chd" + rm -v "$File" "${File%.cue}"*.bin +done diff --git a/day b/day new file mode 100755 index 0000000..821d931 --- /dev/null +++ b/day @@ -0,0 +1,44 @@ +#!/bin/sh + +# Based on day script from mischavandenburg +# url: https://github.com/mischavandenburg/dotfiles/blob/main/scripts/day + +today=$(date +"%Y-%m-%d") +tomorrow=$(date -d "tomorrow" '+%Y-%m-%d') +yesterday=$(date -d "yesterday" '+%Y-%m-%d') +file="$SECOND_BRAIN"'/periodic/daily/'"$today.md" + +cd "$SECOND_BRAIN" || exit 1 + +new_note() { + touch "$file" + + # Give me a nice format + cat <"$file" +# $today + +[[$yesterday]] - [[$tomorrow]] + +## Intention + +What do I want to achieve today and tomorrow? + +## Tracking + +- [ ] Cycle +- [ ] Strength training +- [ ] Watch a movie or tv show episode +- [ ] Play/finish a game +- [ ] Post a blog post +- [ ] Check servers +- [ ] Check backups + +## Log +EOF +} + +if [ ! -f "$file" ]; then + new_note +fi + +nvim '+ normal Gzzo' "$file" diff --git a/external-monitor.sh b/external-monitor.sh index f725aec..01b23d3 100755 --- a/external-monitor.sh +++ b/external-monitor.sh @@ -1,13 +1,13 @@ #!/bin/sh -if xrandr | grep 'HDMI-A-0' | grep connected >/dev/null; then +if xrandr | grep 'HDMI-A-0' | grep disconnected >/dev/null; then + # Just enable tearfree + xrandr --output eDP --set TearFree on +else # Turn off laptop monitor xrandr --output eDP --off # Make sure it's running at 144hz xrandr --output HDMI-A-0 --mode 1920x1080 --rate 144 # Enable tear free xrandr --output HDMI-A-0 --set TearFree on -else - # Just enable tearfree - xrandr --output eDP --set TearFree on fi diff --git a/gaming-time b/gaming-time index a6f8ecf..d56c753 100755 --- a/gaming-time +++ b/gaming-time @@ -1,53 +1,53 @@ #!/bin/sh -disableCronJobs () { - crontab -l | sed '2 s/./#&/' | crontab +disableCronJobs() { + crontab -l | sed '2 s/./#&/' | crontab } -enableCronJobs () { - crontab -l | sed '2s/^.//' | crontab +enableCronJobs() { + crontab -l | sed '2s/^.//' | crontab } -wayland_off () { - start-program wbg ~/pics/wallpapers/spooky_spill.jpg - start-program waybar +wayland_off() { + start-program wbg ~/pics/wallpapers/spooky_spill.jpg + start-program waybar } -wayland_on () { - kill-nicely wbg - kill-nicely waybar +wayland_on() { + kill-nicely wbg + kill-nicely waybar } -x11_off () { - start-program picom - # start-program polybar top -r - start-program xmobar ~/.config/xmobar/xmobarrc - start-program unclutter --timeout 5 - toggle-xrandr on - sleep 2 - start-program trayer-srg --edge top --align right --widthtype request --padding 6 --iconspacing 7 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x303446 --height 24 -l +x11_off() { + start-program picom + # start-program polybar top -r + start-program xmobar ~/.config/xmobar/xmobarrc + # start-program unclutter --timeout 5 + toggle-xrandr on + sleep 2 + start-program trayer --edge top --align right --widthtype request --padding 6 --iconspacing 7 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 --tint 0x303446 --height 24 -l } -x11_on () { - kill-nicely picom - # kill-nicely polybar - kill-nicely xmobar - kill-nicely trayer-srg - kill-nicely unclutter - toggle-xrandr off +x11_on() { + kill-nicely picom + # kill-nicely polybar + kill-nicely xmobar + kill-nicely trayer + # kill-nicely unclutter + toggle-xrandr off } if [ -f "$HOME"/.cache/gaming.lock ]; then - [ "$XDG_SESSION_TYPE" = "wayland" ] && wayland_off || x11_off - start-program transmission-daemon - start-program syncthing - rm "$HOME"/.cache/gaming.lock - quick-notify "Gaming Time" "OFF" + [ "$XDG_SESSION_TYPE" = "wayland" ] && wayland_off || x11_off + # start-program transmission-daemon + start-program syncthing + rm "$HOME"/.cache/gaming.lock + quick-notify "Gaming Time" "OFF" else - [ "$XDG_SESSION_TYPE" = "wayland" ] && wayland_on || x11_on - transmission-remote --exit - syncthing cli operations shutdown - kill-nicely ferdium - touch "$HOME"/.cache/gaming.lock - quick-notify "Gaming Time" "ON" + [ "$XDG_SESSION_TYPE" = "wayland" ] && wayland_on || x11_on + # transmission-remote --exit + syncthing cli operations shutdown + kill-nicely ferdium + touch "$HOME"/.cache/gaming.lock + quick-notify "Gaming Time" "ON" fi diff --git a/mouse_detect.sh b/mouse_detect.sh index 7c503cb..0878946 100755 --- a/mouse_detect.sh +++ b/mouse_detect.sh @@ -1,17 +1,17 @@ #!/bin/sh -if [ $XDG_SESSION_TYPE = "wayland" ]; then - if riverctl list-inputs | grep -i 'mouse' | grep -i 'MOSART' >> /dev/null ; then +if [ "$XDG_SESSION_TYPE" = "wayland" ]; then + if riverctl list-inputs | grep -i 'mouse' | grep -i 'MOSART' >>/dev/null; then riverctl input pointer-1267-12610-ELAN0515:01_04F3:3142_Touchpad events disabled else riverctl input pointer-1267-12610-ELAN0515:01_04F3:3142_Touchpad events enabled fi exit 0 else - if xinput list | grep -i 'mouse' | grep -i 'MOSART' >> /dev/null; then - exec `xinput disable ELAN0515:01\ 04F3:3142\ Touchpad` + if xinput list | grep -i 'mouse' | grep -i 'MOSART' >>/dev/null; then + exec $(xinput disable ELAN0515:01\ 04F3:3142\ Touchpad) else - exec `xinput enable ELAN0515:01\ 04F3:3142\ Touchpad` + exec $(xinput enable ELAN0515:01\ 04F3:3142\ Touchpad) fi exit 0 fi diff --git a/note b/note new file mode 100755 index 0000000..ef47165 --- /dev/null +++ b/note @@ -0,0 +1,39 @@ +#!/bin/sh + +if [ $# -eq 0 ]; then + cd "$SECOND_BRAIN"/notes || exit 1 + nvim . + exit 0 +fi + +open_file() { + cd "$SECOND_BRAIN"/notes || exit 1 + nvim "${1}.md" +} + +remove_file() { + cd "$SECOND_BRAIN"/notes || exit 1 + if [ -f "${1}.md" ]; then + rm "${1}.md" + else + echo "File didn't exist" + fi +} + +if [ $# -eq 1 ]; then + open_file "$1" + exit 0 +elif [ $# -ne 2 ]; then + echo "You need to provide action and file name." + exit 1 +fi + +case "$1" in +rm) + remove_file "$2" + exit 0 + ;; +*) + exit 1 + ;; +esac diff --git a/ns b/ns new file mode 100755 index 0000000..74e8d5a --- /dev/null +++ b/ns @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ $# -ne 1 ]; then + echo "Provide a script name" + exit 1 +else + name="$1" +fi + +touch "$name" +chmod +x "$name" +echo "#!/bin/sh" > "$name" +nvim "+ normal Gzzo" "$name" diff --git a/pblog b/pblog new file mode 100755 index 0000000..66278a5 --- /dev/null +++ b/pblog @@ -0,0 +1,39 @@ +#!/bin/sh + +if [ $# -eq 0 ]; then + cd "$SECOND_BRAIN"/blog || exit 1 + nvim . + exit 0 +fi + +open_file() { + cd "$SECOND_BRAIN"/blog || exit 1 + nvim "${1}.md" +} + +remove_file() { + cd "$SECOND_BRAIN"/blog || exit 1 + if [ -f "${1}.md" ]; then + rm "${1}.md" + else + echo "File didn't exist" + fi +} + +if [ $# -eq 1 ]; then + open_file "$1" + exit 0 +elif [ $# -ne 2 ]; then + echo "You need to provide action and file name." + exit 1 +fi + +case "$1" in +rm) + remove_file "$2" + exit 0 + ;; +*) + exit 1 + ;; +esac diff --git a/t b/t deleted file mode 100755 index 3f28719..0000000 --- a/t +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -[ "$1" ] && result=$(zoxide query $1) || result=$(zoxide query -l | fzf --prompt "Choose directory: ") - -[ -z "$result" ] && exit 0 - -name=$(basename $result) - -session=$(tmux list-sessions | grep $name | awk '{print $1}' | sed 's/.$//') - -if [ -z "$TMUX" ]; then - if [ -z "$session" ]; then - cd $result - tmux new-session -s $name - else - tmux attach -t $session - fi -else - if [ -z "$session" ]; then - cd $result - tmux new-session -d -s $name - tmux switch-client -t $name - else - tmux switch-client -t $session - fi -fi diff --git a/toggle-xrandr b/toggle-xrandr index dc4f7b5..25c9f4b 100755 --- a/toggle-xrandr +++ b/toggle-xrandr @@ -1,10 +1,10 @@ #!/bin/sh doIt() { - if xrandr | grep 'HDMI-A-0' | grep connected >/dev/null; then - xrandr --output HDMI-A-0 --set TearFree "$1" + if xrandr | grep 'HDMI-A-0' | grep disconnected >/dev/null; then + xrandr --output eDP --set TearFree "$1" else - xrandr --output eDP --set TearFree "on" + xrandr --output HDMI-A-0 --set TearFree "$1" fi } diff --git a/vpn b/vpn deleted file mode 100755 index bc0c5ab..0000000 --- a/vpn +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -up () { - transmission-remote --exit - sudo wg-quick up $1 - exit -} - -down () { - sudo wg-quick down $1 - start-program transmission-daemon - exit -} - -[ "$2" = "up" ] && up $1 -[ "$2" = "down" ] && down $1 -exit 1