├── suspend.sh ├── autostart_wait.sh ├── run-mailsync.sh ├── setxmodmap-qwerty.sh ├── dwm-status.sh ├── vol-toggle.sh ├── wp-autochange.sh ├── vol-up.sh ├── dualmon.sh ├── vol-down.sh ├── wp-change.sh ├── setxmodmap-colemak.sh ├── sck-tog.sh ├── dwmbar-functions ├── dwm_backlight.sh ├── dwm_date.sh ├── dwm_keyboard.sh ├── dwm_weather.sh ├── dwm_vpn.sh ├── dwm_ccurse.sh ├── dwm_countdown.sh ├── dwm_mail.sh ├── dwm_battery.sh ├── dwm_network.sh ├── dwm_resources.sh ├── dwm_alsa.sh ├── dwm_pulse.sh ├── dwm_cmus.sh └── dwm_transmission.sh ├── install-brew-packages.sh ├── tap-to-click.sh ├── inverse-scroll.sh ├── autostart.sh └── dwm-status-refresh.sh /suspend.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemctl suspend 4 | -------------------------------------------------------------------------------- /autostart_wait.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sleep 10 4 | #xmodmap ~/.Xmodmap & 5 | #fcitx & 6 | -------------------------------------------------------------------------------- /run-mailsync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while :; do 4 | mailsync 5 | sleep 300 6 | done 7 | -------------------------------------------------------------------------------- /setxmodmap-qwerty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | xmodmap ~/.Xmodmap-cn 4 | xset r rate 250 30 5 | 6 | -------------------------------------------------------------------------------- /dwm-status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true 4 | do 5 | bash ./dwm-status-refresh.sh 6 | sleep 2 7 | done 8 | -------------------------------------------------------------------------------- /vol-toggle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/bin/amixer set Master toggle 4 | bash ~/scripts/dwm-status-refresh.sh 5 | -------------------------------------------------------------------------------- /wp-autochange.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true; do 4 | /bin/bash ~/scripts/wp-change.sh 5 | sleep 3m 6 | done 7 | -------------------------------------------------------------------------------- /vol-up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/bin/amixer -qM set Master 5%+ umute 4 | #pactl set-sink-volume @DEFAULT_SINK@ +5% 5 | bash ~/scripts/dwm-status-refresh.sh 6 | -------------------------------------------------------------------------------- /dualmon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | xrandr --auto --output DP-2 --same-as eDP-1 --size 1920x1080 4 | xrandr --auto --output HDMI-1 --right-of DP-2 --size 1920x1080 5 | -------------------------------------------------------------------------------- /vol-down.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/bin/amixer -qM set Master 5%- umute 4 | #pactl set-sink-volume @DEFAULT_SINK@ -5% 5 | bash ~/scripts/dwm-status-refresh.sh 6 | -------------------------------------------------------------------------------- /wp-change.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | feh --recursive --randomize --bg-fill ~/Pictures/wallpapers/ghibili 4 | #feh --recursive --randomize --bg-fill ~/Pictures/wallpapers/view 5 | -------------------------------------------------------------------------------- /setxmodmap-colemak.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | setxkbmap us colemak -option -option caps:swapescape -option ctrl:swap_lalt_lctl -option lv3:ralt_alt 4 | #xmodmap ~/.config/.Xmodmap 5 | xset r rate 250 30 6 | 7 | -------------------------------------------------------------------------------- /sck-tog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | result=$(ps ax|grep -v grep|grep screenkey) 4 | if [ "$result" == "" ]; then 5 | eval "screenkey --bg-color white --font-color black --font SauceCodePro --opacity 0.9 -t 2 &" 6 | else 7 | eval "killall screenkey" 8 | fi 9 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_backlight.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar module to display the current backlight brighness with xbacklight 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: xbacklight 8 | 9 | dwm_backlight () { 10 | printf "%s☀ %.0f%s\n" "$SEP1" "$(xbacklight)" "$SEP2" 11 | } 12 | 13 | dwm_backlight 14 | -------------------------------------------------------------------------------- /install-brew-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | brew install neofetch jesseduffield/lazygit/lazygit git-delta the_silver_searcher ccat ripgrep fzf ncdu tldr neovim fd yarn shellcheck loc rainbarf git-flow 4 | sudo chgrp -R sudo $(brew --prefix)/*; sudo chmod -R g+w $(brew --prefix)/* 5 | yarn global add diagnostic-languageserver 6 | #flutter pub global activate dart_style 7 | 8 | -------------------------------------------------------------------------------- /tap-to-click.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get id of touchpad and the id of the field corresponding to 4 | # tapping to click 5 | id=`xinput list | grep "Touchpad" | cut -d'=' -f2 | cut -d'[' -f1` 6 | tap_to_click_id=`xinput list-props $id | \ 7 | grep "Tapping Enabled (" \ 8 | | cut -d'(' -f2 | cut -d')' -f1` 9 | 10 | # Set the property to true 11 | xinput --set-prop $id $tap_to_click_id 1 12 | -------------------------------------------------------------------------------- /inverse-scroll.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get id of touchpad and the id of the field corresponding to 4 | # natural scrolling 5 | id=`xinput list | grep "Touchpad" | cut -d'=' -f2 | cut -d'[' -f1` 6 | natural_scrolling_id=`xinput list-props $id | \ 7 | grep "Natural Scrolling Enabled (" \ 8 | | cut -d'(' -f2 | cut -d')' -f1` 9 | 10 | # Set the property to true 11 | xinput --set-prop $id $natural_scrolling_id 1 12 | -------------------------------------------------------------------------------- /autostart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /bin/bash ~/scripts/dwm-status.sh & 4 | /bin/bash ~/scripts/wp-autochange.sh & 5 | #picom -o 0.95 -i 0.88 --detect-rounded-corners --vsync --blur-background-fixed -f -D 5 -c -b 6 | picom -b 7 | /bin/bash ~/scripts/tap-to-click.sh & 8 | /bin/bash ~/scripts/inverse-scroll.sh & 9 | /bin/bash ~/scripts/setxmodmap-colemak.sh & 10 | nm-applet & 11 | xfce4-power-manager & 12 | #xfce4-volumed-pulse & 13 | /bin/bash ~/scripts/run-mailsync.sh & 14 | ~/scripts/autostart_wait.sh & 15 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_date.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function that shows the current date and time 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Date is formatted like like this: "[Mon 01-01-00 00:00:00]" 8 | dwm_date () { 9 | printf "%s" "$SEP1" 10 | if [ "$IDENTIFIER" = "unicode" ]; then 11 | printf "📆 %s" "$(date "+%a %d-%m-%y %T")" 12 | else 13 | printf "DAT %s" "$(date "+%a %d-%m-%y %T")" 14 | fi 15 | printf "%s\n" "$SEP2" 16 | } 17 | 18 | dwm_date 19 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_keyboard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function that displays the current keyboard layout 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: xorg-setxkbmap 8 | 9 | dwm_keyboard () { 10 | printf "%s" "$SEP1" 11 | if [ "$IDENTIFIER" = "unicode" ]; then 12 | printf "⌨ %s" "$(setxkbmap -query | awk '/layout/{print $2}')" 13 | else 14 | printf "KEY %s" "$(setxkbmap -query | awk '/layout/{print $2}')" 15 | fi 16 | printf "%s\n" "$SEP2" 17 | } 18 | 19 | dwm_keyboard 20 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_weather.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to print the weather from wttr.in 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: curl 8 | 9 | # Change the value of LOCATION to match your city 10 | dwm_weather() { 11 | LOCATION=city 12 | 13 | printf "%s" "$SEP1" 14 | if [ "$IDENTIFIER" = "unicode" ]; then 15 | printf "%s" "$(curl -s wttr.in/$LOCATION?format=1)" 16 | else 17 | printf "WEA %s" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o "[0-9].*")" 18 | fi 19 | printf "%s\n" "$SEP2" 20 | } 21 | 22 | dwm_weather 23 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_vpn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to show VPN connections (if any are active) 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: NetworkManager-openvpn 8 | 9 | dwm_vpn () { 10 | VPN=$(nmcli -a | grep 'VPN connection' | sed -e 's/\( VPN connection\)*$//g') 11 | 12 | if [ "$VPN" != "" ]; then 13 | printf "%s" "$SEP1" 14 | if [ "$IDENTIFIER" = "unicode" ]; then 15 | printf "🔒 %s" "$VPN" 16 | else 17 | printf "VPN %s" "$VPN" 18 | fi 19 | printf "%s\n" "$SEP2" 20 | fi 21 | } 22 | 23 | 24 | dwm_vpn 25 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_ccurse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to show the closest appointment in calcurse 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: calcurse 8 | 9 | dwm_ccurse () { 10 | APTSFILE="$HOME/.calcurse/apts" 11 | APPOINTMENT=$(head -n 1 "$APTSFILE" | sed -r 's/\[1\] //') 12 | 13 | if [ "$APPOINTMENT" != "" ]; then 14 | printf "%s" "$SEP1" 15 | if [ "$IDENTIFIER" = "unicode" ]; then 16 | printf "💡 %s" "$APPOINTMENT" 17 | else 18 | printf "APT %s" "$APPOINTMENT" 19 | fi 20 | printf "%s\n" "$SEP2" 21 | fi 22 | } 23 | 24 | dwm_ccurse 25 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_countdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_status function that displays the status of countdown.sh 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: https://github.com/joestandring/countdown 8 | 9 | dwm_countdown () { 10 | for f in /tmp/countdown.*; do 11 | if [ -e "$f" ]; then 12 | printf "%s" "$SEP1" 13 | if [ "$IDENTIFIER" = "unicode" ]; then 14 | printf "⏳ %s" "$(tail -1 /tmp/countdown.*)" 15 | else 16 | printf "CDN %s" "$(tail -1 /tmp/countdown.*)" 17 | fi 18 | printf "%s\n" "$SEP2" 19 | 20 | break 21 | fi 22 | done 23 | } 24 | 25 | dwm_countdown 26 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_mail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to display the number of emails in an inbox 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # To count mail in an inbox, change "/path/to/inbox" below to the location of your inbox. For example, "/home/$USER/.mail/new" 8 | 9 | dwm_mail () { 10 | MAILBOX=$(ls /path/to/inbox | wc -l) 11 | 12 | printf "%s" "$SEP1" 13 | if [ "$IDENTIFIER" = "unicode" ]; then 14 | if [ "$MAILBOX" -eq 0 ]; then 15 | printf "📪 %s" "$MAILBOX" 16 | else 17 | printf "📫 %s" "$MAILBOX" 18 | fi 19 | else 20 | printf "MAI %s" "$MAILBOX" 21 | fi 22 | printf "%s\n" "$SEP2" 23 | } 24 | 25 | dwm_mail 26 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_battery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to read the battery level and status 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | dwm_battery () { 8 | # Change BAT1 to whatever your battery is identified as. Typically BAT0 or BAT1 9 | CHARGE=$(cat /sys/class/power_supply/BAT1/capacity) 10 | STATUS=$(cat /sys/class/power_supply/BAT1/status) 11 | 12 | printf "%s" "$SEP1" 13 | if [ "$IDENTIFIER" = "unicode" ]; then 14 | if [ "$STATUS" = "Charging" ]; then 15 | printf "🔌 %s%% %s" "$CHARGE" "$STATUS" 16 | else 17 | printf "🔋 %s%% %s" "$CHARGE" "$STATUS" 18 | fi 19 | else 20 | printf "BAT %s%% %s" "$CHARGE" "$STATUS" 21 | fi 22 | printf "%s\n" "$SEP2" 23 | } 24 | 25 | dwm_battery 26 | 27 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_network.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to show the current network connection/SSID, private IP, and public IP 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: NetworkManager, curl 8 | 9 | dwm_network () { 10 | CONNAME=$(nmcli -a | grep 'Wired connection' | awk 'NR==1{print $1}') 11 | if [ "$CONNAME" = "" ]; then 12 | CONNAME=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -c 5-) 13 | fi 14 | 15 | PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}') 16 | PUBLIC=$(curl -s https://ipinfo.io/ip) 17 | 18 | printf "%s" "$SEP1" 19 | if [ "$IDENTIFIER" = "unicode" ]; then 20 | printf "🌐 %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC" 21 | else 22 | printf "NET %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC" 23 | fi 24 | printf "%s\n" "$SEP2" 25 | } 26 | 27 | dwm_network 28 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to display information regarding system memory, CPU temperature, and storage 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | dwm_resources () { 8 | # Used and total memory 9 | MEMUSED=$(free -h | awk '(NR == 2) {print $3}') 10 | MEMTOT=$(free -h |awk '(NR == 2) {print $2}') 11 | # CPU temperature 12 | CPU=$(sysctl -n hw.sensors.cpu0.temp0 | cut -d. -f1) 13 | # Used and total storage in /home (rounded to 1024B) 14 | STOUSED=$(df -h | grep '/home$' | awk '{print $3}') 15 | STOTOT=$(df -h | grep '/home$' | awk '{print $2}') 16 | STOPER=$(df -h | grep '/home$' | awk '{print $5}') 17 | 18 | printf "%s" "$SEP1" 19 | if [ "$IDENTIFIER" = "unicode" ]; then 20 | printf "💻 MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" 21 | else 22 | printf "STA | MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" 23 | fi 24 | printf "%s\n" "$SEP2" 25 | } 26 | 27 | dwm_resources 28 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_alsa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to show the master volume of ALSA 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: alsa-utils 8 | 9 | dwm_alsa () { 10 | VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") 11 | printf "%s" "$SEP1" 12 | if [ "$IDENTIFIER" = "unicode" ]; then 13 | if [ "$VOL" -eq 0 ]; then 14 | printf "🔇" 15 | elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then 16 | printf "🔈 %s%%" "$VOL" 17 | elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then 18 | printf "🔉 %s%%" "$VOL" 19 | else 20 | printf "🔊 %s%%" "$VOL" 21 | fi 22 | else 23 | if [ "$VOL" -eq 0 ]; then 24 | printf "MUTE" 25 | elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then 26 | printf "VOL %s%%" "$VOL" 27 | elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then 28 | printf "VOL %s%%" "$VOL" 29 | else 30 | printf "VOL %s%%" "$VOL" 31 | fi 32 | fi 33 | printf "%s\n" "$SEP2" 34 | } 35 | 36 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_pulse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to show the master volume of PulseAudio 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: pamixer 8 | 9 | dwm_pulse () { 10 | VOL=$(pamixer --get-volume-human | tr -d '%') 11 | 12 | printf "%s" "$SEP1" 13 | if [ "$IDENTIFIER" = "unicode" ]; then 14 | if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then 15 | printf "🔇" 16 | elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then 17 | printf "🔈 %s%%" "$VOL" 18 | elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then 19 | printf "🔉 %s%%" "$VOL" 20 | else 21 | printf "🔊 %s%%" "$VOL" 22 | fi 23 | else 24 | if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then 25 | printf "MUTE" 26 | elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then 27 | printf "VOL %s%%" "$VOL" 28 | elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then 29 | printf "VOL %s%%" "$VOL" 30 | else 31 | printf "VOL %s%%" "$VOL" 32 | fi 33 | fi 34 | printf "%s\n" "$SEP2" 35 | } 36 | 37 | dwm_pulse 38 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_cmus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function that shows the current artist, track, position, duration, and status from cmus 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: cmus 8 | 9 | dwm_cmus () { 10 | if ps -C cmus > /dev/null; then 11 | ARTIST=$(cmus-remote -Q | grep -a '^tag artist' | awk '{gsub("tag artist ", "");print}') 12 | TRACK=$(cmus-remote -Q | grep -a '^tag title' | awk '{gsub("tag title ", "");print}') 13 | POSITION=$(cmus-remote -Q | grep -a '^position' | awk '{gsub("position ", "");print}') 14 | DURATION=$(cmus-remote -Q | grep -a '^duration' | awk '{gsub("duration ", "");print}') 15 | STATUS=$(cmus-remote -Q | grep -a '^status' | awk '{gsub("status ", "");print}') 16 | SHUFFLE=$(cmus-remote -Q | grep -a '^set shuffle' | awk '{gsub("set shuffle ", "");print}') 17 | 18 | if [ "$IDENTIFIER" = "unicode" ]; then 19 | if [ "$STATUS" = "playing" ]; then 20 | STATUS="▶" 21 | else 22 | STATUS="⏸" 23 | fi 24 | 25 | if [ "$SHUFFLE" = "true" ]; then 26 | SHUFFLE=" 🔀" 27 | else 28 | SHUFFLE="" 29 | fi 30 | else 31 | if [ "$STATUS" = "playing" ]; then 32 | STATUS="PLA" 33 | else 34 | STATUS="PAU" 35 | fi 36 | 37 | if [ "$SHUFFLE" = "true" ]; then 38 | SHUFFLE=" S" 39 | else 40 | SHUFFLE="" 41 | fi 42 | fi 43 | 44 | printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK" 45 | printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60)) 46 | printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) 47 | printf "%s%s\n" "$SHUFFLE" "$SEP2" 48 | fi 49 | } 50 | 51 | dwm_cmus 52 | -------------------------------------------------------------------------------- /dwmbar-functions/dwm_transmission.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A dwm_bar function to show the status of a torrent woth transmission-remote 4 | # Joe Standring 5 | # GNU GPLv3 6 | 7 | # Dependencies: transmission-remote 8 | 9 | dwm_transmission () { 10 | TORRENT=$(transmission-remote -l | sed '2q;d' | sed 's/\(.\) /\1/g') 11 | ID=$(printf "%s" "$TORRENT" | awk '{print $1;}') 12 | STATUS=$(printf "%s" "$TORRENT" | awk '{print $8;}') 13 | ETA=$(printf "%s" "$TORRENT" | awk '{print $4;}') 14 | NAME=$(printf "%s" "$TORRENT" | awk '{for(i=9;i<=NF;++i)print $i}' | tr -d "\n" | head -c 20; printf "...") 15 | DONE=$(printf "%s" "$TORRENT" | awk '{print $2;}') 16 | UP=$(printf "%s" "$TORRENT" | awk '{print $5;}') 17 | DOWN=$(printf "%s" "$TORRENT" | awk '{print $5;}') 18 | 19 | if [ "$ID" != "Sum:" ]; then 20 | printf "%s" "$SEP1" 21 | if [ "$IDENTIFIER" = "unicode" ]; then 22 | case "$STATUS" in 23 | "Idle") 24 | printf "🛑 %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" 25 | ;; 26 | "Seeding") 27 | printf "🌱 %s | ⬆%s ⬇%s" "$NAME" "$UP" "$DOWN" 28 | ;; 29 | "Downloading") 30 | printf "⏬ %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" 31 | ;; 32 | esac 33 | else 34 | case "$STATUS" in 35 | "Idle") 36 | printf "IDLE %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" 37 | ;; 38 | "Seeding") 39 | printf "SEEDING %s | ⬆%s ⬇%s" "$NAME" "$UP" "$DOWN" 40 | ;; 41 | "Downloading") 42 | printf "DOWNLOADING %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" 43 | ;; 44 | esac 45 | fi 46 | printf "%s\n" "$SEP2" 47 | fi 48 | } 49 | 50 | dwm_transmission 51 | -------------------------------------------------------------------------------- /dwm-status-refresh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Screenshot: http://s.natalian.org/2013-08-17/dwm_status.png 3 | # Network speed stuff stolen from http://linuxclues.blogspot.sg/2009/11/shell-script-show-network-speed.html 4 | 5 | # This function parses /proc/net/dev file searching for a line containing $interface data. 6 | # Within that line, the first and ninth numbers after ':' are respectively the received and transmited bytes. 7 | function get_bytes { 8 | # Find active network interface 9 | interface=$(ip route get 8.8.8.8 2>/dev/null| awk '{print $5}') 10 | line=$(grep $interface /proc/net/dev | cut -d ':' -f 2 | awk '{print "received_bytes="$1, "transmitted_bytes="$9}') 11 | eval $line 12 | now=$(date +%s%N) 13 | } 14 | 15 | # Function which calculates the speed using actual and old byte number. 16 | # Speed is shown in KByte per second when greater or equal than 1 KByte per second. 17 | # This function should be called each second. 18 | 19 | function get_velocity { 20 | value=$1 21 | old_value=$2 22 | now=$3 23 | 24 | timediff=$(($now - $old_time)) 25 | velKB=$(echo "1000000000*($value-$old_value)/1024/$timediff" | bc) 26 | if test "$velKB" -gt 1024 27 | then 28 | echo $(echo "scale=2; $velKB/1024" | bc)MB/s 29 | else 30 | echo ${velKB}KB/s 31 | fi 32 | } 33 | 34 | # Get initial values 35 | get_bytes 36 | old_received_bytes=$received_bytes 37 | old_transmitted_bytes=$transmitted_bytes 38 | old_time=$now 39 | 40 | print_volume() { 41 | volume="$(amixer get Master | tail -n1 | sed -r 's/.*\[(.*)%\].*/\1/')" 42 | if test "$volume" -gt 0 43 | then 44 | echo -e "\uE05D${volume}" 45 | else 46 | echo -e "Mute" 47 | fi 48 | } 49 | 50 | print_mem(){ 51 | memfree=$(($(grep -m1 'MemAvailable:' /proc/meminfo | awk '{print $2}') / 1024)) 52 | echo -e "$memfree" 53 | } 54 | 55 | print_temp(){ 56 | test -f /sys/class/thermal/thermal_zone0/temp || return 0 57 | echo $(head -c 2 /sys/class/thermal/thermal_zone0/temp)C 58 | } 59 | 60 | #!/bin/bash 61 | 62 | get_time_until_charged() { 63 | 64 | # parses acpitool's battery info for the remaining charge of all batteries and sums them up 65 | sum_remaining_charge=$(acpitool -B | grep -E 'Remaining capacity' | awk '{print $4}' | grep -Eo "[0-9]+" | paste -sd+ | bc); 66 | 67 | # finds the rate at which the batteries being drained at 68 | present_rate=$(acpitool -B | grep -E 'Present rate' | awk '{print $4}' | grep -Eo "[0-9]+" | paste -sd+ | bc); 69 | 70 | # divides current charge by the rate at which it's falling, then converts it into seconds for `date` 71 | seconds=$(bc <<< "scale = 10; ($sum_remaining_charge / $present_rate) * 3600"); 72 | 73 | # prettifies the seconds into h:mm:ss format 74 | pretty_time=$(date -u -d @${seconds} +%T); 75 | 76 | echo $pretty_time; 77 | } 78 | 79 | get_battery_combined_percent() { 80 | 81 | # get charge of all batteries, combine them 82 | total_charge=$(expr $(acpi -b | awk '{print $4}' | grep -Eo "[0-9]+" | paste -sd+ | bc)); 83 | 84 | # get amount of batteries in the device 85 | battery_number=$(acpi -b | wc -l); 86 | 87 | percent=$(expr $total_charge / $battery_number); 88 | 89 | echo $percent; 90 | } 91 | 92 | get_battery_charging_status() { 93 | 94 | if $(acpi -b | grep --quiet Discharging) 95 | then 96 | echo "🔋"; 97 | else # acpi can give Unknown or Charging if charging, https://unix.stackexchange.com/questions/203741/lenovo-t440s-battery-status-unknown-but-charging 98 | echo "🔌"; 99 | fi 100 | } 101 | 102 | 103 | 104 | print_bat(){ 105 | #hash acpi || return 0 106 | #onl="$(grep "on-line" <(acpi -V))" 107 | #charge="$(awk '{ sum += $1 } END { print sum }' /sys/class/power_supply/BAT*/capacity)%" 108 | #if test -z "$onl" 109 | #then 110 | ## suspend when we close the lid 111 | ##systemctl --user stop inhibit-lid-sleep-on-battery.service 112 | #echo -e "${charge}" 113 | #else 114 | ## On mains! no need to suspend 115 | ##systemctl --user start inhibit-lid-sleep-on-battery.service 116 | #echo -e "${charge}" 117 | #fi 118 | #echo "$(get_battery_charging_status) $(get_battery_combined_percent)%, $(get_time_until_charged )"; 119 | echo "$(get_battery_charging_status) $(get_battery_combined_percent)%, $(get_time_until_charged )"; 120 | } 121 | 122 | print_date(){ 123 | date '+%Y年%m月%d日 %H:%M' 124 | } 125 | 126 | show_record(){ 127 | test -f /tmp/r2d2 || return 128 | rp=$(cat /tmp/r2d2 | awk '{print $2}') 129 | size=$(du -h $rp | awk '{print $1}') 130 | echo " $size $(basename $rp)" 131 | } 132 | 133 | 134 | LOC=$(readlink -f "$0") 135 | DIR=$(dirname "$LOC") 136 | export IDENTIFIER="unicode" 137 | 138 | #. "$DIR/dwmbar-functions/dwm_transmission.sh" 139 | #. "$DIR/dwmbar-functions/dwm_cmus.sh" 140 | #. "$DIR/dwmbar-functions/dwm_resources.sh" 141 | #. "$DIR/dwmbar-functions/dwm_battery.sh" 142 | #. "$DIR/dwmbar-functions/dwm_mail.sh" 143 | #. "$DIR/dwmbar-functions/dwm_backlight.sh" 144 | . "$DIR/dwmbar-functions/dwm_alsa.sh" 145 | #. "$DIR/dwmbar-functions/dwm_pulse.sh" 146 | #. "$DIR/dwmbar-functions/dwm_weather.sh" 147 | #. "$DIR/dwmbar-functions/dwm_vpn.sh" 148 | #. "$DIR/dwmbar-functions/dwm_network.sh" 149 | #. "$DIR/dwmbar-functions/dwm_keyboard.sh" 150 | #. "$DIR/dwmbar-functions/dwm_ccurse.sh" 151 | #. "$DIR/dwmbar-functions/dwm_date.sh" 152 | 153 | get_bytes 154 | 155 | # Calculates speeds 156 | vel_recv=$(get_velocity $received_bytes $old_received_bytes $now) 157 | vel_trans=$(get_velocity $transmitted_bytes $old_transmitted_bytes $now) 158 | 159 | xsetroot -name " 💿 $(print_mem)M ⬇️ $vel_recv ⬆️ $vel_trans $(dwm_alsa) [ $(print_bat) ]$(show_record) $(print_date) " 160 | 161 | # Update old values to perform new calculations 162 | old_received_bytes=$received_bytes 163 | old_transmitted_bytes=$transmitted_bytes 164 | old_time=$now 165 | 166 | exit 0 167 | --------------------------------------------------------------------------------