commit 5255e68f739705107cc9ec9c8b4f05a2fe1c3273
parent 0f28b474aedb9b594e9098e2cf4a6d9a58d45b2b
Author: Martin J. KlΓΆckner <64109770+mjkloeckner@users.noreply.github.com>
Date: Fri, 31 Mar 2023 12:55:11 -0300
Merge pull request #2 from mjkloeckner/inspiron
Removed unused, update and add new scripts
Diffstat:
42 files changed, 331 insertions(+), 268 deletions(-)
diff --git a/backlight b/backlight
@@ -1 +0,0 @@
-17
diff --git a/clipmenu_centered b/clipmenu_centered
@@ -15,5 +15,4 @@ dmenufont='DejaVuSansMono Nerd Font:style=Regular:size=8'
dmenucmds="-i -l 30 -h 14 -z 750 -bw 2 -c $@"
-clipmenu $dmenucmds -nb $col_gray1 -nf $col_gray3 -sb $col_darkmagenta \
- -sf $col_gray4 -fn "$dmenufont"
+clipmenu $dmenucmds -nb $col_gray1 -nf $col_gray3 -sb $col_darkmagenta -sf $col_gray4 -fn "$dmenufont"
diff --git a/count.sh_ b/count.sh_
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-x=0
-while [ $x -lt 500000 ]; do echo "$x"; x=$((x+1)); done
diff --git a/create-new-repo b/create-new-repo
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-repos_dir="/var/www/git"
-
-while true; do
- printf "new repository name: "
- read -r repo_name;
- repo_name=$(echo -n $repo_name | sed 's/ /-/g'):
-
- case $repo_name in
- *[\/\!\&\(\)\{\}\[\]@\#$%^*_+?]* ) \
- echo 'name containing invalid character' ;;
- * ) break;
- esac
-done
-
-echo "creating new repository: \"$repo_name\""
-
-mkdir -p "$repos_dir"/"$repo_name"/"$repo_name".git
-
-ln -sf "$repos_dir"/"$repo_name"/"$repo_name".git /home/git
-
-cp "$repos_dir"/dotfiles/dotfiles.git/hooks/post-receive
diff --git a/disablemouseaccel b/disablemouseaccel
@@ -1,10 +1,9 @@
#!/bin/bash
-xinput --set-prop 13 'libinput Accel Profile Enabled' 0, 1
-xinput --set-prop 14 'libinput Accel Profile Enabled' 0, 1
+xinput --set-prop 10 'libinput Accel Profile Enabled' 0, 1
-xinput --set-prop 'Logitech Wireless Mouse' \
- 'libinput Accel Profile Enabled' 0, 1
+xinput --set-prop 'Logitech Wireless Mouse' 'libinput Accel Profile Enabled' 0, 1
xinput --set-prop 'DLLA6AE:00 06CB:75DD Touchpad' 'libinput Tapping Enabled' 1
+
diff --git a/dmenu_centered b/dmenu_centered
@@ -10,5 +10,4 @@ dmenufont='Victor Mono:style=SemiBold:size=9';
# dmenuargs="-h 16 -b -l 10 -c"
dmenuargs="-i -h 16 -b -F $@"
-dmenu_run_history -fn "$dmenufont" -nb $col_gray1 -nf $col_gray3 \
- -sb $col_darkmagenta -sf $col_gray4 $dmenuargs -p "Run:"
+dmenu_run_history -fn "$dmenufont" -nb $col_gray1 -nf $col_gray3 -sb $col_darkmagenta -sf $col_gray4 $dmenuargs -p "Run:"
diff --git a/emojisupport b/emojisupport
@@ -5,8 +5,7 @@ echo "Setting up Noto Emoji font..."
# 1 - install noto-fonts-emoji package
pacman -S noto-fonts-emoji --needed
# pacman -S powerline-fonts --needed
-echo "Recommended system font: inconsolata regular (ttf-inconsolata or \
- powerline-fonts)"
+echo "Recommended system font: inconsolata regular (ttf-inconsolata or powerline-fonts)"
# 2 - add font config to /etc/fonts/conf.d/01-notosans.conf
echo "<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
@@ -45,8 +44,6 @@ echo "<?xml version="1.0"?>
" > /etc/fonts/local.conf
# 3 - update font cache via fc-cache
fc-cache
-echo "Noto Emoji Font installed! You may need to restart applications like \
- chrome. If chrome displays no symbols or no letters, your default font \
- contains emojis."
+echo "Noto Emoji Font installed! You may need to restart applications like chrome. If chrome displays no symbols or no letters, your default font contains emojis."
echo "consider inconsolata regular"
diff --git a/imagestodownload.txt b/imagestodownload.txt
@@ -0,0 +1,3 @@
+https://www.nasa.gov/sites/default/files/thumbnails/image/iss065e002848.jpg
+https://www.nasa.gov/sites/default/files/thumbnails/image/iss065e005888.jpg
+https://www.nasa.gov/sites/default/files/thumbnails/image/iss065e005888.jpg
diff --git a/ip.sh b/ip.sh
@@ -1,14 +1,14 @@
#!/bin/sh
-# Prints your local ip address. If you are connected both via wireless & \
-# ethernet then the ethernet ip is printed by github.com/mjkloeckner
+# Prints your local ip address. Ethernet connection has more priority over WiFi
+# by github.com/mjkloeckner
estatus="$(cat /sys/class/net/e*/operstate)"
-if [ "$estatus" = "down" ];
- then ip=$(ip -o a | awk '/: w.*.inet .*/ { print $4 }' | sed 's/\// /' | \
+if [ "$estatus" = "down" ];
+ then ip=$(ip -o a | awk '/: w.*.inet .*/ { print $4 }' | sed 's/\// /' |\
awk '{ print $1 }');
- else ip=$(ip -o a | awk '/: e.*.inet .*/ { print $4 }' | sed 's/\// /' | \
+ else ip=$(ip -o a | awk '/: e.*.inet .*/ { print $4 }' | sed 's/\// /' |
awk '{ print $1 }');
fi;
diff --git a/keyboardmap b/keyboardmap
@@ -11,8 +11,6 @@
# make CapsLock behave like Ctrl:
# setxkbmap -option ctrl:nocaps
-
-
setxkbmap -option altwin:swap_lalt_lwin,altwin:swap_alt_win,ctrl:nocaps
# make short-pressed Ctrl behave like Escape:
diff --git a/lockscreen b/lockscreen
@@ -1,19 +1,32 @@
#!/bin/bash
-pactlsetvolume -d 1
-pactlsetvolume -i 1
+# pactlsetvolume -d 1
+# pactlsetvolume -i 1
# xset dpms force off
# sleep 5;
+# i3lock -b -c 00000000 -n --wrong-text="" --lock-text="" --lockfailed-text="" \
+# --verif-text="" --verif-text="" --noinput-text="" \
+# -i $HOME/.cache/betterlockscreen/current/wall_dimblur.png \
+# -M --ring-color=8B008B --keyhl-color=ff00ff --verif-color=0000FF \
+# --indicator --pass-media-keys --radius 100.0 --pointer default
+
+# windows 11 lockscreen style (requieres Segoe UI font)
i3lock -b -c 00000000 -n --wrong-text="" --lock-text="" --lockfailed-text="" \
- --verif-text="" --verif-text="" --noinput-text="" \
- -i $HOME/.cache/betterlockscreen/current/wall_dimblur.png \
- -M --ring-color=8B008B --keyhl-color=ff00ff --verif-color=0000FF \
- --indicator --pass-media-keys --radius 100.0 --pointer default
+ --verif-text="" --verif-text="" --noinput-text="" \
+ -i $HOME/.config/scheme/lockscreen-bg \
+ -M --indicator --pointer default \
+ -k --time-str="%H:%M" --date-str="%A, %B %d" --time-size=102 --date-size=26 \
+ --time-font="Segoe UI Variable Static Display:style=Semibold" \
+ --date-font="Segoe UI Variable Static Display:style=Semibold" \
+ --time-pos="ix:iy - 142" --time-color="FFFFFFCC" --date-color="FFFFFFCC" \
+ --bar-indicator --bar-direction 2 --bar-color 00000000 --bar-pos "h" \
+ --bar-step 5 --bar-max-height 5 --bar-periodic-step 5 \
+ --keyhl-color="736654CC"
# Re-enables notifications when the device is unlocked
-dunstctl set-paused false
+# dunstctl set-paused false
pkill -RTMIN+8 dwmblocks
diff --git a/lockscreen-ring b/lockscreen-ring
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Pauses notifications so it wont show during lockscreen
+# dunstctl set-paused true
+
+# xset dpms force off
+
+# sleep 5;
+
+# i3lock -b -c 00000000 -n --wrong-text="" --lock-text="" --lockfailed-text="" --verif-text="" --verif-text="" --noinput-text="" -i $HOME/.cache/betterlockscreen/current/wall_dimblur.png -M --ring-color=8B008B --keyhl-color=ff00ff --verif-color=0000FF --indicator --pass-media-keys --radius 100.0 --pointer default
+i3lock -b -c 00000000 -n --wrong-text="" --lock-text="" --lockfailed-text="" --verif-text="" --verif-text="" --noinput-text="" -i /home/mk/.config/scheme/lockscreen-bg -M --ring-color=8B008B --keyhl-color=ff00ff --verif-color=0000FF --indicator --pass-media-keys --radius 100.0 --pointer default
+
+# Re-enables notifications when the device is unlocked
+# dunstctl set-paused false
+
+# pkill -RTMIN+8 dwmblocks
diff --git a/lockscreen-win11-like b/lockscreen-win11-like
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# pactlsetvolume -d 1
+# pactlsetvolume -i 1
+
+# xset dpms force off
+
+# sleep 5;
+
+# i3lock -b -c 00000000 -n --wrong-text="" --lock-text="" --lockfailed-text="" \
+# --verif-text="" --verif-text="" --noinput-text="" \
+# -i $HOME/.cache/betterlockscreen/current/wall_dimblur.png \
+# -M --ring-color=8B008B --keyhl-color=ff00ff --verif-color=0000FF \
+# --indicator --pass-media-keys --radius 100.0 --pointer default
+
+# windows 11 lockscreen style (requieres Segoe UI font)
+i3lock -b -c 00000000 -n --wrong-text="" --lock-text="" --lockfailed-text="" \
+ --verif-text="" --verif-text="" --noinput-text="" \
+ -i $HOME/.config/scheme/lockscreen-bg \
+ -M --indicator --pointer default \
+ -k --time-str="%H:%M" --date-str="%A, %B %d" --time-size=102 --date-size=26 \
+ --time-font="Segoe UI Variable Static Display:style=Semibold" \
+ --date-font="Segoe UI Variable Static Display:style=Semibold" \
+ --time-pos="ix:iy - 142" --time-color="FFFFFFCC" --date-color="FFFFFFCC" \
+ --bar-indicator --bar-direction 2 --bar-color 00000000 --bar-pos "h" \
+ --bar-step 5 --bar-max-height 5 --bar-periodic-step 5 \
+ --keyhl-color="736654CC"
+
+# Re-enables notifications when the device is unlocked
+# dunstctl set-paused false
+
+pkill -RTMIN+8 dwmblocks
diff --git a/nasa_img_downloader b/nasa_img_downloader
@@ -4,8 +4,5 @@
[ -z "$1" ] && exit 1
-while read line; do
- url="$line";
- imgname=$(echo "$url" | cut -d "/" -f 12); curl -# $url > $imgname;
- echo "\nDownloading: $imgname";
-done < $1
+while read line; do url="$line"; imgname=$(echo "$url" | cut -d "/" -f 12); \
+ curl -# $url > $imgname; echo "\nDownloading: $imgname"; done < $1
diff --git a/nsxiv-rifle b/nsxiv-rifle
@@ -17,7 +17,7 @@ open_img() {
# only go through listfiles() if the file has a valid img extension
if echo "$file" | is_img_extension >/dev/null 2>&1; then
trap 'rm -f $tmp' EXIT
- count="$(listfiles "///${file%/*}" | grep -nF "$file")"
+ count="$(listfiles "${file%/*}" | grep -nF "$file")"
fi
if [ -n "$count" ]; then
nsxiv -i -n "${count%%:*}" "$@" -- < "$tmp"
diff --git a/openbook b/openbook
@@ -12,20 +12,17 @@ col_gray4="#eeeeee"
dir=$HOME/dox/books
pdfviewer=zathura
-dmenufont='DejaVuSansMono Nerd Font:style=Regular:size=8'
-# dmenufont='Victor Mono:style=SemiBold:size=8';
+# dmenufont='DejaVuSansMono Nerd Font:style=Regular:size=8'
+dmenufont='Victor Mono:style=SemiBold:size=9'
# dmenucmds="-i -l 30 -h 14 -z 750 -bw 2 -c $@"
-dmenucmds="-i -l 35 -h 10 -z 850 -bw 2 -c $@"
+dmenucmds="-i -l 30 -h 8 -z 850 -bw 2 -c $@"
-bookname=$(ls $dir | dmenu $dmenucmds -nb $col_gray1 -nf $col_gray3 \
- -sb $col_darkmagenta -sf $col_gray4 -fn "$dmenufont")
+bookname=$(ls $dir | dmenu $dmenucmds -nb $col_gray1 -nf $col_gray3 -sb $col_darkmagenta -sf $col_gray4 -fn "$dmenufont")
[ -z "$bookname" ] && exit
-[ $(file "$dir/$bookname" | cut -d ":" -f 2) = "directory" ] &&
- dir=$dir/$bookname && bookname=$(ls "$dir" | dmenu $dmenucmds \
- -nb $col_gray1 -nf $col_gray3 -sb $col_darkmagenta -sf $col_gray4 \
- -fn "$dmenufont" )
+[ "$(file "$dir/$bookname" | cut -d ":" -f 2)" = "directory" ] &&
+ dir=$dir/$bookname && bookname=$(ls "$dir" | dmenu $dmenucmds -nb $col_gray1 -nf $col_gray3 -sb $col_darkmagenta -sf $col_gray4 -fn "$dmenufont" )
[ -n "$bookname" ] && $pdfviewer "$dir/$bookname"
diff --git a/opendir b/opendir
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-dmenucmds="-i -l 10 -h 14 -z 750 -bw 2 -c $@"
-dirname=$(fd -a | dmenu $dmenucmds)
-
-alacritty --working-directory "$dirname"
diff --git a/pactllowervolume b/pactllowervolume
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-amount_to_increase=$1
-
-current_volume=$(pamixer --get-volume)
-max_volume=$((100 - $amount_to_increase))
-
-(($current_volume<=$max_volume)) && $(pactl set-sink-volume @DEFAULT_SINK@ - $amount_to_increase%)
-
-current_volume=$(pamixer --get-volume)
-notify
-notify-send -h int:value:$current_volume "Volume" -h string:bgcolor:#111111 -h string:fgcolor:#ffffff -i π -t 1500;
diff --git a/pactlraisevolume b/pactlraisevolume
@@ -1,11 +1,8 @@
#!/bin/bash
-amount_to_increase=$1
+AMOUNT_TO_INCREASE=$1
-current_volume=$(pamixer --get-volume)
-max_volume=$((100 - $amount_to_increase))
+CURRENT_VOLUME=$(pamixer --get-volume)
+MAX_VOLUME=$((100 - $AMOUNT_TO_INCREASE))
-(($current_volume<=$max_volume)) && $(pactl set-sink-volume @DEFAULT_SINK@ +$amount_to_increase%)
-
-current_volume=$(pamixer --get-volume)
-notify-send -h int:value:$current_volume "Volume" -h string:bgcolor:#111111 -h string:fgcolor:#ffffff -i π -t 1500;
+(($CURRENT_VOLUME<=$MAX_VOLUME)) && $(pactl set-sink-volume @DEFAULT_SINK@ +$AMOUNT_TO_INCREASE%)
diff --git a/pamixersetvolume b/pamixersetvolume
@@ -1,29 +1,31 @@
-#!/bin/bash
+#!/bin/sh
# amount=$(echo "$1" | cut -d " " -f 2)
# amount=$2
-send_notification() {
- dunstify -r 13123 "$2 Volume $1%" -t 1750
-}
-
-get_icon() {
- if [ "$mute" == "true" ] | [ "$curr" -eq "0" ]; then
- icon="π"
- break;
- elif [ "$curr" -gt "50" ]; then
- icon="π"
- elif [ "$curr" -lt "25" ]; then
- icon="π"
- else
- icon="π"
- fi
-}
+# send_notification() {
+# dunstify -r 13123 "$2 Volume $1%" -t 1750
+# }
+#
+# get_icon() {
+# if [ "$mute" == "true" ] | [ "$curr" -eq "0" ]; then
+# icon="π"
+# break;
+# elif [ "$curr" -gt "50" ]; then
+# icon="π"
+# elif [ "$curr" -lt "25" ]; then
+# icon="π"
+# else
+# icon="π"
+# fi
+# }
pamixer $1 $2 && kill -35 $(pidof dwmblocks)
+# sleep 1
+# pamixer $1 $2 && pkill -RTMIN+1 dwmblocks
-curr=$(pamixer --get-volume)
-mute=$(pamixer --get-mute)
+# curr=$(pamixer --get-volume)
+# mute=$(pamixer --get-mute)
-get_icon
-send_notification $curr $icon
+# get_icon
+# send_notification $curr $icon
diff --git a/pamixertogglemute b/pamixertogglemute
@@ -1,10 +1,10 @@
#!/bin/bash
# amount=$(echo "$1" | cut -d " " -f 2)
-send_notification() {
+# send_notification() {
# dunstify -r 13123 -h "int:value:$1" "$2 Volume ($1%)" -t 2000
- dunstify -r 13123 "$2 Volume $1%" -t 1750
-}
+ # dunstify -r 13123 "$2 Volume $1%" -t 1750
+# }
get_icon() {
if [ "$curr" -gt "50" ]; then
@@ -23,10 +23,11 @@ pactl set-sink-mute @DEFAULT_SINK@ toggle;
if [ "$(pamixer --get-mute)" == "false" ]; then
curr=$(pamixer --get-volume)
get_icon $icon
- send_notification $curr $icon
-else
- send_notification "0" "π"
+ # send_notification $curr $icon
fi
+# else
+ # send_notification "0" "π"
+# fi
kill -35 $(pidof dwmblocks)
diff --git a/scratchpad-attach b/scratchpad-attach
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+tmux ls 2> /dev/null | grep -q scratchpad && tmux attach-session -t scratchpad \
+ || tmux new-session -s scratchpad
diff --git a/setlockscreenbg b/setlockscreenbg
@@ -2,8 +2,9 @@
# Sets the same image used for the wallpaper as the lockscreen background
-imgname=$(grep file $HOME/.config/nitrogen/bg-saved.cfg | cut -c6-)
+# imgname=$(grep file $HOME/.config/nitrogen/bg-saved.cfg | cut -c6-)
+# imgname="/home/mk/pix/wg/1655994685668.jpg"
+imgname="$(grep -o "'.*.[jpg|jpeg|png]'" $HOME/.fehbg)"
+imgname="$(echo $imgname | sed "s/'//g")"
-echo $imgname
-
-betterlockscreen -u "$imgname"
+betterlockscreen -u $imgname
diff --git a/shortpath b/shortpath
@@ -3,4 +3,4 @@
# shortens a path given from stdin
# usage: ./shortpath <long_path_to_be_shorten>
-awk -F '/' '{if(NF > 4){print "β¦/"$(NF-2)"/"$(NF-1)"/"$(NF)}else{print}}' < /dev/stdin
+awk -F '/' '{if(NF > 3){print "β¦/"$(NF-2)"/"$(NF-1)"/"$(NF)}else{print}}' < /dev/stdin
diff --git a/statusbar/sb-battery b/statusbar/sb-battery
@@ -3,18 +3,18 @@
# Prints all batteries, their percentage remaining and an emoji corresponding
# to charge status (π for plugged up, π for discharging on battery, etc.).
-case $BLOCK_BUTTON in
- 3) notify-send "π Battery module" "π: discharging
-π: not charging
-β»: stagnant charge
-π: charging
-β‘: charged
-β: battery very low!
-- Scroll to change adjust xbacklight." ;;
- 4) xbacklight -inc 10 ;;
- 5) xbacklight -dec 10 ;;
- 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
-esac
+# case $BLOCK_BUTTON in
+# 3) notify-send "π Battery module" "π: discharging
+# π: not charging
+# β»: stagnant charge
+# π: charging
+# β‘: charged
+# β: battery very low!
+# - Scroll to change adjust xbacklight." ;;
+# 4) xbacklight -inc 10 ;;
+# 5) xbacklight -dec 10 ;;
+# 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+# esac
if [ ! -e /sys/class/power_supply/BAT?* ]; then
status="π " && printf "%s%s" "$status" "AC" && exit 0;
@@ -39,5 +39,9 @@ for battery in /sys/class/power_supply/BAT?*; do
[ "$status" = "π" ] && [ "$capacity" -le 20 ] && status="β"
# Prints the info
- printf "%s%*d%%" "$status" "3" "$capacity";
+ if [ "$capacity" -lt 10 ]; then
+ printf "%s%*d%%" "$status" "2" "$capacity";
+ else
+ printf "%s%*d%%" "$status" "3" "$capacity";
+ fi
done && exit 0
diff --git a/statusbar/sb-clock b/statusbar/sb-clock
@@ -28,4 +28,4 @@ esac
#date "+ %a %b %d %Y $icon: %I:%M%p"
# date "+π
%a %d/%m/%Y $icon %R"
-date "+π
%a %d %b %Y $icon %R"
+date "+$icon %R"
diff --git a/statusbar/sb-cpu b/statusbar/sb-cpu
@@ -9,4 +9,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-sensors | awk '/Core 0/ {print "π‘: " $3}'
+sensors | awk '/Core 0/ {print "π‘ " $3}'
diff --git a/statusbar/sb-date b/statusbar/sb-date
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#case $BLOCK_BUTTON in
+# 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
+# 2) setsid -f "$TERMINAL" -e calcurse ;;
+# 3) notify-send "π
Time/date module" "\- 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" ;;
+# 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+#esac
+
+#date "+ %a %b %d %Y $icon: %I:%M%p"
+# date "+π
%a %d/%m/%Y $icon %R"
+date "+π
%a %d %b %Y"
diff --git a/statusbar/sb-gpu b/statusbar/sb-gpu
@@ -9,7 +9,7 @@
# 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
# esac
-ctemp=$(sensors | awk '/Package id/ {$4 = substr($4, 2, length($4) - 5); print $4}')
+ctemp=$(sensors | awk '/CPU:/ {$2 = substr($2, 2, length($2) - 5); print $2}')
# gtemp=$(sensors | awk '/edge/ {$2 = substr($2, 2, length($2) - 5); print $2}')
# printf "π‘οΈ C$ctempΒ° G$gtempΒ°"
diff --git a/statusbar/sb-internet b/statusbar/sb-internet
@@ -9,7 +9,7 @@ wstatus="$(cat /sys/class/net/w*/operstate)"
if [ "$estatus" = "down" ]; then
if [ "$wstatus" = "down" ]; then
- ip="Disconnected"; icon="π"
+ ip="Disconnected"; icon="β οΈ"
else
ip=$(ip -o a | awk '/: w.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }')
icon="π‘"
@@ -35,6 +35,6 @@ case $speed in
color="^c#00FF00^";;
esac
-[ -z $ip ] && printf "%s %s\n" "$icon" "Connecting" && exit
+[ -z $ip ] && printf "%s %s" "$icon" "Connecting" && exit
printf "%s %s" "$icon" "$ip"
diff --git a/statusbar/sb-internet2 b/statusbar/sb-internet2
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-# Show wifi πΆ and percent strength or π‘ if none.
-# Show π if connected to ethernet or β if none.
-# Show π if a vpn connection is active
-
-case $BLOCK_BUTTON in
- 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
- 3) notify-send "π Internet module" "\- Click to connect
-π‘: no wifi connection
-πΆ: wifi connection with quality
-β: no ethernet
-π: ethernet working
-π: vpn is active
-" ;;
- 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
-esac
-
-case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
- down) wifiicon="π‘: -%" ;;
- up) wifiicon="$(awk '/^\s*w/ { print "πΆ:", int($3 * 100 / 70) "%" }' /proc/net/wireless)" ;;
-esac
-
-case "$(cat /sys/class/net/e*/operstate 2>/dev/null)" in
- down) ip="" ;;
- up) ip="| $(ip -o a | awk '/: e.*.inet .*/ { print $4 }' | sed 's/\// /' | awk '{ print $1 }')" ;;
-
-esac
-
-printf "%s%s%s%s\n" "$wifiicon" "$(sed "s/down//;s/up/ /" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/π/" /sys/class/net/tun*/operstate 2>/dev/null)" "$ip"
diff --git a/statusbar/sb-kbselect b/statusbar/sb-kbselect
@@ -4,7 +4,7 @@
kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
-printf "%s %s" "βοΈ" "${kb^^}"
+printf "%s %s" "βοΈ" "$(echo $kb | tr '[:lower:]' '[:upper:]')"
# case $BLOCK_BUTTON in
# 1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
@@ -15,9 +15,6 @@ printf "%s %s" "βοΈ" "${kb^^}"
# - Left click to change keyboard.";;
# 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
# esac
-<<<<<<< HEAD
-=======
# printf "%s %s" "β¨οΈ" "$kb"
# echo "β¨οΈ: $kb"
->>>>>>> cecb3e8dd633fd5ba597ad536ffabd0c5f29726e
diff --git a/statusbar/sb-volume b/statusbar/sb-volume
@@ -1,25 +1,6 @@
#!/bin/sh
-
-# Prints the current volume or π if muted.
-
-# case $BLOCK_BUTTON in
-# 1) setsid -f "$TERMINAL" -e pulsemixer ;;
-# 2) pamixer -t ;;
-# 4) pamixer --allow-boost -i 1 ;;
-# 5) pamixer --allow-boost -d 1 ;;
-# 3) notify-send "π’ Volume module" "\- Shows volume π, π if muted.
-# - Middle click to mute.
-# - Scroll to change." ;;
-# 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
-# esac
-
-# [ $(pamixer --get-mute) = true ] && echo "π ^c#FF2a2a^0%^d^" && exit
-# [ $(pamixer --get-mute) = true ] && echo "π 0%" && exit
-
-# [ $(awk -F "[][]" '/Left:/ { print $4 }' <(amixer sget Master)) == "off" ] && echo "π 0%" && exit
-
+#
vol="$(pamixer --get-volume)"
-# vol="$(awk -F "[][]" '/Left:/ { $2 - substr($2, 2, lenghth($2) - 1); print $2 }' <(amixer sget Master))"
[ $(pamixer --get-mute) = true ] && printf "π%3d%s" $vol "%" && exit
diff --git a/statusbar/sb-volume-subscribe b/statusbar/sb-volume-subscribe
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+pid=$(pidof dwmblocks)
+
+# Makes grep faster
+export LC_ALL=C
+
+pactl subscribe | grep --line-buffered "sink" \
+ | while read -r UNUSED\_LINE; do kill -35 $pid; done
diff --git a/statusbar/sb-weather b/statusbar/sb-weather
@@ -1,33 +1,136 @@
-#!/bin/sh
+#!/usr/bin/python3
-nc -dzw2 google.com 443 2> /dev/null
+# Dependencies:
+# requests
-if [[ $? -ne 0 ]]; then
- printf "β οΈ Service down\n" ;
- exit;
-fi
+import requests
+import json
+import pathlib
+from datetime import datetime
-# $(nc -dzw2 google.com 443 &> /dev/null) || printf "β οΈ Service down\n" && exit 0
+# TODO: support other units
-curr_time=$(date +"%H%M")
-raw=$(curl -s wttr.in/1876\?format="%d|%S|%t|%C|%c|%m\n" | tr --delete " " | cut -d "|" -f 1,2,3,4,5,6)
+icons_day = {
+ "clear_sky": "βοΈ",
+ "few_clouds": "π€οΈ",
+ "scattered_clouds": "π€",
+ "broken_clouds": "β",
+ "overcast_clouds": "β",
+ "shower_rain": "π§",
+ "very_heavy_rain": "π§",
+ "rain": "π§",
+ "thunderstorm": "β",
+ "snow": "β",
+ "mist": "π«"
+}
-echo $raw | grep -i unknown -q && printf "β οΈ Service down" && exit
+moon_phase = {
+ (0.00, 0.124): "π",
+ (0.124, 0.249): "π",
+ (0.250, 0.374): "π",
+ (0.375, 0.49): "π",
+ (0.50, 0.674): "π",
+ (0.675, 0.749): "π",
+ (0.750, 0.824): "π",
+ (0.825, 0.99): "π",
+ (0.99, 1): "π"
+}
-for i in {0..5}; do
- data[$i]=$(echo -n $raw | cut -d "|" -f $((i + 1)))
-done
+lat = -34.71
+lon = -58.27
+api_key = "5d30773002dbb7a5aaa846b1656965b2"
+units = "metric"
+exclude = "minutely,hourly,alert"
+cache_file_name = "/home/mk/.cache/wthr.json"
-data[2]=$(echo -n ${data[2]} | cut -d "," -f 1)
+# update time in minutes
+update_time = 5
-dusk=$(echo -n ${data[0]} | cut -d ":" -f 1,2 | tr --delete ":")
-sunrise=$(echo -n ${data[1]} | cut -d ":" -f 1,2 | tr --delete ":")
-temp=$(echo -n ${data[2]})
-condition=${data[3]}
-day=${data[4]}
-moon=${data[5]}
-temp=$(echo -n ${data[2]} | tr --delete '+')
+url = "https://api.openweathermap.org/data/2.5/onecall"
+params = {'lat': lat, 'lon': lon, 'appid': api_key, 'units': units, 'exclude': exclude}
-[[ $curr_time -lt $dusk && $curr_time -gt $sunrise ]] &&
- printf "%s %s %s" $day $condition $temp ||
- printf "%s %s %s" $moon $condition $temp
+curr_time = datetime.now().timestamp()
+cache_file = pathlib.Path(cache_file_name)
+
+def cache_update():
+ pass
+
+def cache_fetch():
+ pass
+
+if cache_file.exists() != True:
+ # file doesn't exist, creates one
+ pathlib.Path(cache_file_name).touch()
+ print("cache file created")
+
+ try:
+ res = requests.get(url, params)
+ except (requests.ConnectionError, res):
+ print("β οΈ Service down")
+ quit()
+
+ wthr_dict = json.loads(res.text)
+ with open(cache_file_name,'w') as cache_file:
+ json.dump(wthr_dict, cache_file, indent=4)
+else:
+ # get file modified time
+ mtime = cache_file.stat().st_mtime
+ if (curr_time - mtime) > (update_time * 60):
+ try:
+ res = requests.get(url, params)
+ except (requests.ConnectionError, res):
+ print("β οΈ Service down")
+ quit()
+
+ wthr_dict = json.loads(res.text)
+ with open(cache_file_name,'w') as cache_file:
+ json.dump(wthr_dict, cache_file, indent=4)
+ else:
+ try:
+ with open(cache_file_name,'r') as cache_file:
+ wthr_dict = json.loads(cache_file.read())
+ except ValueError:
+ # file not JSON
+ try:
+ res = requests.get(url, params)
+ except (requests.ConnectionError, res):
+ print("β οΈ Service down")
+ quit()
+
+ wthr_dict = json.loads(res.text)
+ with open(cache_file_name,'w') as cache_file:
+ json.dump(wthr_dict, cache_file, indent=4)
+
+# print(json.dumps(wthr_dict, indent=4, sort_keys=True))
+
+desc = wthr_dict['current']['weather'][0]['description']
+main = wthr_dict['current']['weather'][0]['main']
+# temp = int(wthr_dict['current']['feels_like'])
+temp = int(wthr_dict['current']['temp'])
+icon = icons_day[desc.replace(' ', '_')]
+moon_curr = wthr_dict['daily'][0]['moon_phase']
+curr_time_int = int(datetime.now().strftime('%H%M'))
+sunrise = int(wthr_dict['current']['sunrise'])
+sunset = int(wthr_dict['current']['sunset'])
+
+sunrise = int(datetime.fromtimestamp(sunrise).strftime('%H%M'))
+sunset = int(datetime.fromtimestamp(sunset).strftime('%H%M'))
+
+for range, moon_icon in moon_phase.items():
+ if range[0] <= moon_curr <= range[1]:
+ moon_curr = moon_icon
+ break
+
+night = (0000, sunrise, sunset + 100, 2359)
+sunset = (sunset, sunset + 50)
+dusk = (sunset[1], sunset[1] + 50)
+day = (sunrise, sunset)
+
+if (dusk[0] <= curr_time_int <= dusk[1]) and main == 'Clear':
+ icon = "π"
+elif (sunset[0] <= curr_time_int <= sunset[1]) and (main == 'Clear'):
+ icon = "π"
+elif ((night[0] <= curr_time_int <= night[1]) or (night[2] <= curr_time_int <= night[3])):
+ icon = moon_curr
+
+print("{} {}Β° {}".format(icon, temp, main))
diff --git a/statusbar/sb-weather~ b/statusbar/sb-weather~
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-nc -dzw2 google.com 443 2> /dev/null
-
-if [[ $? -ne 0 ]]; then
- printf "β οΈ Service down\n" ;
- exit;
-fi
-
-# $(nc -dzw2 google.com 443 &> /dev/null) || printf "β οΈ Service down\n" && exit 0
-
-curr_time=$(date +"%H%M")
-raw=$(curl -s wttr.in/1876\?format="%d|%S|%t|%C|%c|%m\n" | tr --delete " " | cut -d "|" -f 1,2,3,4,5,6)
-
-echo $raw | grep -i unknown && printf "β οΈ Service down\n" ;& exit
-
-for i in {0..5}; do
- data[$i]=$(echo -n $raw | cut -d "|" -f $((i + 1)))
-done
-
-data[2]=$(echo -n ${data[2]} | cut -d "," -f 1)
-
-dusk=$(echo -n ${data[0]} | cut -d ":" -f 1,2 | tr --delete ":")
-sunrise=$(echo -n ${data[1]} | cut -d ":" -f 1,2 | tr --delete ":")
-temp=$(echo -n ${data[2]})
-condition=${data[3]}
-day=${data[4]}
-moon=${data[5]}
-temp=$(echo -n ${data[2]} | tr --delete '+')
-
-[[ $curr_time -lt $dusk && $curr_time -gt $sunrise ]] &&
- printf "%s %s %s" $day $condition $temp ||
- printf "%s %s %s" $moon $condition $temp
diff --git a/statusbar/wthr b/statusbar/wthr
@@ -1,5 +1,8 @@
#!/usr/bin/python3
+# Dependencies:
+# requests
+
import requests
import json
import pathlib
@@ -16,7 +19,6 @@ icons_day = {
"shower_rain": "π§",
"very_heavy_rain": "π§",
"rain": "π§",
- "light_rain": "π§οΈ",
"thunderstorm": "β",
"snow": "β",
"mist": "π«"
diff --git a/switchkblayout b/switchkblayout
@@ -7,8 +7,10 @@ kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
case $kb in
# us) setxkbmap es && dunstctl close-all && dunstify -t 2000 -h "string:bgcolor:#111111" "Switched keyboard layout to ES";;
# es) setxkbmap us && dunstctl close-all && dunstify -t 2000 -h "string:bgcolor:#111111" "Switched keyboard layout to US";;
- us) setxkbmap -option altwin:swap_lalt_lwin,altwin:swap_alt_win,ctrl:nocaps es && dunstify -r 1 -t 2000 -h "string:bgcolor:#111111" "Switched keyboard layout to ES π¦π·";;
- es) setxkbmap -option altwin:swap_lalt_lwin,altwin:swap_alt_win,ctrl:nocaps us && dunstify -r 1 -t 2000 -h "string:bgcolor:#111111" "Switched keyboard layout to US πΊπΈ";;
+ # us) setxkbmap -option altwin:swap_lalt_lwin,altwin:swap_alt_win,ctrl:nocaps es && dunstify -r 1 -t 2000 -h "string:bgcolor:#111111" "Switched keyboard layout to ES π¦π·";;
+ # es) setxkbmap -option altwin:swap_lalt_lwin,altwin:swap_alt_win,ctrl:nocaps us && dunstify -r 1 -t 2000 -h "string:bgcolor:#111111" "Switched keyboard layout to US πΊπΈ";;
+ us) setxkbmap -option altwin:swap_lalt_lwin,altwin:swap_alt_win,ctrl:nocaps es;;
+ es) setxkbmap -option altwin:swap_lalt_lwin,altwin:swap_alt_win,ctrl:nocaps us;;
esac
-pkill -RTMIN+4 dwmblocks
+kill -55 $(pidof dwmblocks)
diff --git a/takescreenshot b/takescreenshot
@@ -2,16 +2,13 @@
# Takes a screenshot of the screen and sends a notification with a preview
-FOLDER=~/pictures/screenshots
+FOLDER=~/pix/screenshots
FILENAME=$FOLDER/$(date "+%H-%M-%S_%d-%m-%Y_scrot.png")
-scrot -q 100 $FILENAME
+[ -d $FOLDER ] && scrot -q 100 $FILENAME || $(mkdir $FOLDER && echo "Folder $FOLDER created" && scrot -q 100 $FILENAE)
-convert -brightness-contrast 10x10 $FILENAME -resize 512x512 \
- /tmp/takescreenshot_icon.png
+convert -brightness-contrast 10x10 $FILENAME -resize 512x512 /tmp/takescreenshot_icon.png
-ACTION=$(dunstify -r 1 -t 5000 -h "string:bgcolor:#111111" \
- "Saving screenshot to $FOLDER" -h "string:bgcolor:#111111" \
- "Right click to open" --action=3,Open -i /tmp/takescreenshot_icon.png)
+# ACTION=$(dunstify -r 1 -t 5000 -h "string:bgcolor:#111111" "Saving screenshot to $FOLDER" -h "string:bgcolor:#111111" "Right click to open" --action=3,Open -i /tmp/takescreenshot_icon.png)
-[ $ACTION -eq 3 ] && mimeopen $FILENAME;
+# [ $ACTION -eq 3 ] && xdg-open $FILENAME;
diff --git a/tmux-window b/tmux-window
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+[ "$1" = "" ] && printf " " || printf "$1"
diff --git a/update_net_dwmblock b/update_net_dwmblock
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+kill -57 "$(pidof dwmblocks)"
diff --git a/update_power_dwmblock b/update_power_dwmblock
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+kill -56 "$(pidof dwmblocks)"