diff options
| -rw-r--r-- | .bashrc | 8 | ||||
| -rw-r--r-- | .bmdirs | 1 | ||||
| -rw-r--r-- | .config/ranger/rc.conf | 3 | ||||
| -rw-r--r-- | .config/ranger/shortcuts.conf | 0 | ||||
| -rw-r--r-- | .profile | 4 | ||||
| -rw-r--r-- | .scripts/cron/IMPORTANT_NOTE.md | 11 | ||||
| -rwxr-xr-x | .scripts/cron/checkup | 4 | ||||
| -rwxr-xr-x | .scripts/cron/getforecast | 6 | ||||
| -rwxr-xr-x | .scripts/i3cmds/displayselect | 41 | ||||
| -rwxr-xr-x | .scripts/i3cmds/dmenumount | 7 | ||||
| -rwxr-xr-x | .scripts/i3cmds/dmenurecord | 8 | ||||
| -rwxr-xr-x | .scripts/i3cmds/ducksearch | 13 | ||||
| -rwxr-xr-x | .scripts/i3cmds/showclip | 4 | ||||
| -rwxr-xr-x | .scripts/i3cmds/tutorialvids | 2 | ||||
| -rwxr-xr-x | .scripts/statusbar/clock | 5 | ||||
| -rwxr-xr-x | .scripts/statusbar/mpdupdate | 9 | ||||
| -rwxr-xr-x | .scripts/statusbar/pacpackages | 5 | ||||
| -rwxr-xr-x | .scripts/statusbar/weather | 9 | ||||
| -rwxr-xr-x | .scripts/tools/dmenuhandler | 2 | ||||
| -rwxr-xr-x | .scripts/tools/shortcuts | 22 |
20 files changed, 102 insertions, 62 deletions
@@ -9,11 +9,9 @@ stty -ixon # Disable ctrl-s and ctrl-q. shopt -s autocd #Allows you to cd into directory merely by typing the directory name. HISTSIZE= HISTFILESIZE= # Infinite history. -# Setting Bash prompt. Capitalizes username and host if root user (my root user uses this same config file). -if [ "$EUID" -ne 0 ] - then export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \[$(tput setaf 5)\]\W\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]" - else export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]ROOT\[$(tput setaf 2)\]@\[$(tput setaf 4)\]$(hostname | awk '{print toupper($0)}') \[$(tput setaf 5)\]\W\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]" -fi +export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \[$(tput setaf 5)\]\W\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]" + +[ -f "$HOME/.shortcuts" ] && source "$HOME/.shortcuts" # Load shortcut aliases export GPG_TTY=$(tty) @@ -8,4 +8,3 @@ vv ~/Videos cf ~/.config sc ~/.scripts mn /mnt -e /etc diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf index 9e67b37..ecd7373 100644 --- a/.config/ranger/rc.conf +++ b/.config/ranger/rc.conf @@ -515,3 +515,6 @@ map Tn eval fm.open_console('shell eyeD3 -n "" ' + fm.thisfile.relative_path, po #Downloading map ytv console shell youtube-dl -ic%space map yta console shell youtube-dl -xic%space + +# Source shortcuts +source ~/.config/ranger/shortcuts.conf diff --git a/.config/ranger/shortcuts.conf b/.config/ranger/shortcuts.conf new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.config/ranger/shortcuts.conf @@ -25,10 +25,10 @@ export LESS_TERMCAP_ue=$'\E[0m' # reset underline [ ! -f ~/.shortcuts ] && shortcuts >/dev/null 2>&1 -[ -f ~/.bashrc ] && source "$HOME/.bashrc" +echo "$0" | grep "bash$" >/dev/null && [ -f ~/.bashrc ] && source "$HOME/.bashrc" # Start graphical server if i3 not already running. [ "$(tty)" = "/dev/tty1" ] && ! pgrep -x i3 >/dev/null && exec startx -# Switch escape and caps and use wal colors if tty: +# Switch escape and caps if tty: sudo -n loadkeys ~/.scripts/ttymaps.kmap 2>/dev/null diff --git a/.scripts/cron/IMPORTANT_NOTE.md b/.scripts/cron/IMPORTANT_NOTE.md new file mode 100644 index 0000000..4568a77 --- /dev/null +++ b/.scripts/cron/IMPORTANT_NOTE.md @@ -0,0 +1,11 @@ +# Important Note + +These cronjobs have components that require information about your current display to display notifications correctly. + +When you add them as cronjobs, I recommend you precede the command with commands as those below: + +``` +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; . $HOME/.profile; then_command_goes_here +``` + +This ensures that notifications will display, xdotool commands will function and environmental varialbes will work as well. diff --git a/.scripts/cron/checkup b/.scripts/cron/checkup index c823b32..4838948 100755 --- a/.scripts/cron/checkup +++ b/.scripts/cron/checkup @@ -1,9 +1,5 @@ #!/bin/sh # Syncs repositories and downloads updates, meant to be run as a cronjob. -# For notifications, must export DBUS_SESSION_BUS_ADDRESS. -# See my cronjob below and mimic it: -# -# 9 12 * * * eval "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"; /home/luke/.scripts/cron/checkup ping -q -w 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit diff --git a/.scripts/cron/getforecast b/.scripts/cron/getforecast new file mode 100755 index 0000000..2760c89 --- /dev/null +++ b/.scripts/cron/getforecast @@ -0,0 +1,6 @@ +#!/bin/sh +# Updates weather forecast +ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit +location="$1"; [ -z "$location" ] || location="$location+" +curl -s "wttr.in/$location" > ~/.weatherreport +pkill -RTMIN+5 i3blocks && notify-send "🌞 Weather forecast updated." diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect index c9a2bd9..0bd612e 100755 --- a/.scripts/i3cmds/displayselect +++ b/.scripts/i3cmds/displayselect @@ -6,14 +6,41 @@ # I plan on adding a routine from multi-monitor setups later. twoscreen() { # If multi-monitor is selected and there are two screens. - primary=$(echo "$screens" | dmenu -i -p "Select primary display:") - secondary=$(echo "$screens" | grep -v "$primary") - direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") - xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto - } + + mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") + # Mirror displays using native resolution of external display and a scaled + # version for the internal display + if [ "$mirror" = "yes" ]; then + external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:") + internal=$(echo "$screens" | grep -v "$external") + + res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + + res_ext_x=$(echo $res_external | sed 's/x.*//') + res_ext_y=$(echo $res_external | sed 's/.*x//') + res_int_x=$(echo $res_internal | sed 's/x.*//') + res_int_y=$(echo $res_internal | sed 's/.*x//') + + scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l) + scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l) + + xrandr --output "$external" --auto --scale 1.0x1.0 \ + --output "$internal" --auto --same-as "$external" \ + --scale "$scale_x"x"$scale_y" + else + + primary=$(echo "$screens" | dmenu -i -p "Select primary display:") + secondary=$(echo "$screens" | grep -v "$primary") + direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") + xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0 + fi + } morescreen() { # If multi-monitor is selected and there are more than two screens. - primary=$(echo "$screens" | dmenu -i -p "asdf") + primary=$(echo "$screens" | dmenu -i -p "Select primary display:") secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:") direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?") tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:") @@ -38,7 +65,7 @@ chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p case "$chosen" in "manual selection") arandr ; exit ;; "multi-monitor") multimon ;; - *) xrandr --output "$chosen" --auto $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; esac # Fix feh background if screen size/arangement has changed. diff --git a/.scripts/i3cmds/dmenumount b/.scripts/i3cmds/dmenumount index 431141f..4de7438 100755 --- a/.scripts/i3cmds/dmenumount +++ b/.scripts/i3cmds/dmenumount @@ -19,7 +19,12 @@ mountusb() { \ chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')" sudo -A mount "$chosen" && notify-send "$chosen mounted." && exit 0 getmount "/mnt /media /mount /home -maxdepth 5 -type d" - sudo -A mount "$chosen" "$mp" && notify-send "$chosen mounted to $mp." + partitiontype="$(lsblk -no "fstype" "$chosen")" + case "$partitiontype" in + "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; + *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" 741 "$mp";; + esac + notify-send "$chosen mounted to $mp." } mountandroid() { \ diff --git a/.scripts/i3cmds/dmenurecord b/.scripts/i3cmds/dmenurecord index d5ed889..7f0ea72 100755 --- a/.scripts/i3cmds/dmenurecord +++ b/.scripts/i3cmds/dmenurecord @@ -52,7 +52,7 @@ video() { ffmpeg \ } webcamhidef() { ffmpeg \ - -f v412 \ + -f v4l2 \ -i /dev/video0 \ -video_size 1920x1080 \ "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & @@ -61,7 +61,7 @@ webcamhidef() { ffmpeg \ } webcam() { ffmpeg \ - -f v412 \ + -f v4l2 \ -i /dev/video0 \ -video_size 640x480 \ "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & @@ -85,8 +85,8 @@ askrecording() { \ screencast) screencast;; audio) audio;; video) video;; - webcam) webcamrecord;; - "webcam (hi-def)") webcamrecord;; + webcam) webcam;; + "webcam (hi-def)") webcamhidef;; esac } diff --git a/.scripts/i3cmds/ducksearch b/.scripts/i3cmds/ducksearch index 13a1e19..d69f3fb 100755 --- a/.scripts/i3cmds/ducksearch +++ b/.scripts/i3cmds/ducksearch @@ -1,15 +1,22 @@ -#!/bin/sh +#!/bin/bash # Gives a dmenu prompt to search DuckDuckGo. # Without input, will open DuckDuckGo.com. +# URLs will be directly handed to the browser. # Anything else, it search it. +browser=${BROWSER:-firefox} pgrep -x dmenu && exit choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1 if [ "$choice" = "🦆" ]; then - $BROWSER "https://duckduckgo.com" + $browser "https://duckduckgo.com" else - $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" + # Detect if url + if [[ "$choice" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$ ]]; then + $browser "$choice" + else + $browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" + fi fi diff --git a/.scripts/i3cmds/showclip b/.scripts/i3cmds/showclip index 5764487..9f8a6b9 100755 --- a/.scripts/i3cmds/showclip +++ b/.scripts/i3cmds/showclip @@ -9,7 +9,7 @@ clip=$(xclip -o -selection clipboard) prim=$(xclip -o -selection primary) -[ "$prim" != "" ] && notify-send "<b>Clipboard:</b> +[ "$clip" != "" ] && notify-send "<b>Clipboard:</b> $clip" -[ "$clip" != "" ] && notify-send "<b>Primary:</b> +[ "$prim" != "" ] && notify-send "<b>Primary:</b> $prim" diff --git a/.scripts/i3cmds/tutorialvids b/.scripts/i3cmds/tutorialvids index 2743bfc..1449cbe 100755 --- a/.scripts/i3cmds/tutorialvids +++ b/.scripts/i3cmds/tutorialvids @@ -15,4 +15,4 @@ urlview https://www.youtube.com/watch?v=IgzpAjFgbCw colorschemes with pywal https://www.youtube.com/watch?v=Es79N_9BblE vi mode in shell https://www.youtube.com/watch?v=GqoJQft5R2E " -mpv "$(echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 5 | awk '{print $1}')\s" | sed 's/.*\t//')" +echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 20 | awk '{print $1}')\s" | sed 's/.*\t//' | xargs -r mpv diff --git a/.scripts/statusbar/clock b/.scripts/statusbar/clock index caed51a..587e3c9 100755 --- a/.scripts/statusbar/clock +++ b/.scripts/statusbar/clock @@ -3,10 +3,9 @@ date '+%Y %b %d (%a) %I:%M%p' case $BLOCK_BUTTON in - 1) pgrep -x dunst >/dev/null && notify-send "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" ;; + 1) pgrep -x dunst >/dev/null && notify-send "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "$(calcurse -d3)" ;; 2) "$TERMINAL" -e calcurse ;; 3) pgrep -x dunst >/dev/null && notify-send "<b>📅 Time/date module:</b> -- Left click to show month via \`cal\` +- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\` - Middle click opens calcurse if installed" ;; esac - diff --git a/.scripts/statusbar/mpdupdate b/.scripts/statusbar/mpdupdate new file mode 100755 index 0000000..84c7ab1 --- /dev/null +++ b/.scripts/statusbar/mpdupdate @@ -0,0 +1,9 @@ +#!/bin/sh + +[ "$(pgrep -x "$(basename "$0")" | wc -l)" -gt 2 ] && exit + +while : ; do + pgrep -x mpd || exit + mpc idle > /dev/null + pkill -RTMIN+11 i3blocks ; +done diff --git a/.scripts/statusbar/pacpackages b/.scripts/statusbar/pacpackages index 1207e2c..9e1ef22 100755 --- a/.scripts/statusbar/pacpackages +++ b/.scripts/statusbar/pacpackages @@ -8,8 +8,11 @@ case $BLOCK_BUTTON in 1) $TERMINAL -e popupgrade ;; + 2) notify-send "$(/usr/bin/pacman -Qu)" ;; 3) pgrep -x dunst >/dev/null && notify-send "<b>Upgrade module:</b> -📦: number of upgradable packages" ;; +📦: number of upgradable packages +- Left click to upgrade packages +- Middle click to show upgradable packages" ;; esac diff --git a/.scripts/statusbar/weather b/.scripts/statusbar/weather index 4b7bbb6..00abda2 100755 --- a/.scripts/statusbar/weather +++ b/.scripts/statusbar/weather @@ -1,6 +1,5 @@ #!/bin/sh -### This is only if your location isn't automatically detected, otherwise you can leave it blank. -location="" +[ "$(stat -c %y .weatherreport | awk '{print $1}')" != "$(date '+%Y-%m-%d')" ] && getforecast case $BLOCK_BUTTON in 1) $TERMINAL -e less -Srf ~/.weatherreport ;; @@ -11,12 +10,6 @@ case $BLOCK_BUTTON in 🌞: Daily high" ;; esac -[ "$location" != "" ] && location="$location+" - -ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit - -curl -s wttr.in/$location > ~/.weatherreport - printf "%s" "$(sed '16q;d' ~/.weatherreport | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')" sed '13q;d' ~/.weatherreport | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' diff --git a/.scripts/tools/dmenuhandler b/.scripts/tools/dmenuhandler index f00178b..9da9d57 100755 --- a/.scripts/tools/dmenuhandler +++ b/.scripts/tools/dmenuhandler @@ -8,7 +8,7 @@ case "$(printf "copy url\\nmpv\\nmpv (loop)\\nqueue download\\n\\nqueue youtube- "mpv (loop)") setsid mpv -quiet --loop "$1" >/dev/null 2>&1 & ;; "queue download") tsp curl -LO "$1" >/dev/null 2>&1 ;; "queue youtube-dl") tsp youtube-dl --write-metadata -ic "$1" >/dev/null 2>&1 ;; - browser) setsid "$TRUEBROWSER" "$1" >/dev/null 2>&1 & ;; + browser) setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;; feh) setsid feh "$1" >/dev/null 2>&1 & ;; w3m) w3m "$1" >/dev/null 2>&1 ;; "mpv (float)") setsid mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;; diff --git a/.scripts/tools/shortcuts b/.scripts/tools/shortcuts index 5ccb114..0ec0463 100755 --- a/.scripts/tools/shortcuts +++ b/.scripts/tools/shortcuts @@ -1,12 +1,4 @@ #!/bin/bash - -# Shell rc file (i.e. bash vs. zsh, etc.) -shellrc="$HOME/.bashrc" - -# Bookmark file locations -bmdirs="$HOME/.bmdirs" -bmfiles="$HOME/.bmfiles" - # Output locations. Unactivated progs should go to /dev/null. shell_shortcuts="$HOME/.shortcuts" ranger_shortcuts="$HOME/.config/ranger/shortcuts.conf" @@ -15,24 +7,16 @@ fish_shortcuts="/dev/null" # Remove, prepare files rm -f "$ranger_shortcuts" "$qute_shortcuts" 2>/dev/null -#echo "abbr \\" > "$fish_shortcuts" +echo "abbr \\" > "$fish_shortcuts" echo "alias \\" > "$shell_shortcuts" -# Ensure text of argument 1 exists in the file argument 2 -ensure() { (grep "$1" "$2")>/dev/null 2>&1 || echo "$1" >> "$2" ;} - -ensure "source $shell_shortcuts" "$shellrc" -ensure "source $HOME/.config/ranger/shortcuts.conf" "$HOME/.config/ranger/rc.conf" -#ensure "config.source('shortcuts.py')" "$HOME/.config/qutebrowser/config.py" -#ensure "source $HOME/.config/fish/shortcuts.fish" "$HOME/.config/fish/config.fish" - # Format the `bmdirs` file in the correct syntax and sent it to all three configs. -sed "s/#.*$//;/^$/d" "$bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ +sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ >(awk '{print $1, "\"cd " $2 "; and ls -a\" \\"}' >> "$fish_shortcuts") \ >(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \ | awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts" # Format the `configs` file in the correct syntax and sent it to both configs. -sed "s/#.*$//;/^$/d" "$bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ +sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ >(awk '{print $1, "\"$EDITOR "$2"\" \\"}' >> "$fish_shortcuts") \ | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" |
