diff options
| author | ivan-boikov <ik.boikov.public@protonmail.com> | 2022-07-10 16:44:04 +0200 |
|---|---|---|
| committer | ivan-boikov <ik.boikov.public@protonmail.com> | 2022-07-10 16:44:04 +0200 |
| commit | cbffe0ea857c27453e72231efa340dc266642715 (patch) | |
| tree | f49d4d93a82cdcf4748c79da6d59382a2d272df9 /scripts | |
| parent | cd2ccfea0782f385b5fda990ba3dc53d8a2e6c73 (diff) | |
1
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/.local/bin/cdmenu | 4 | ||||
| -rwxr-xr-x | scripts/.local/bin/checkzswap | 38 | ||||
| -rwxr-xr-x | scripts/.local/bin/checkzwap | 1 | ||||
| -rwxr-xr-x | scripts/.local/bin/gendunstrc | 35 | ||||
| -rwxr-xr-x | scripts/.local/bin/genzathurarc | 50 | ||||
| -rwxr-xr-x | scripts/.local/bin/getxcolor | 2 | ||||
| -rwxr-xr-x | scripts/.local/bin/setbg | 40 | ||||
| -rwxr-xr-x | scripts/.local/bin/statusbar/sb-music | 16 | ||||
| -rwxr-xr-x | scripts/.local/bin/tablet/osu | 4 |
9 files changed, 150 insertions, 40 deletions
diff --git a/scripts/.local/bin/cdmenu b/scripts/.local/bin/cdmenu index e1a4fdf..c8eee3d 100755 --- a/scripts/.local/bin/cdmenu +++ b/scripts/.local/bin/cdmenu @@ -2,7 +2,7 @@ # colored dmenu for use in scripts getcolor() { - xrdb -query | awk '/*.color'"$1":'/ { print substr($2,2) }' + xrdb -query | awk '/*.'$1:'/ { print substr($2,2) }' } # sync that with dwm's config.h! -dmenu -nb "#$(getcolor 0)" -nf "#$(getcolor 4)" -sb "#$(getcolor 4)" -sf "#$(getcolor 0)" "$@" +dmenu -nb "#$(getcolor background)" -nf "#$(getcolor foreground)" -sb "#$(getcolor foreground)" -sf "#$(getcolor background)" "$@" diff --git a/scripts/.local/bin/checkzswap b/scripts/.local/bin/checkzswap new file mode 100755 index 0000000..905e106 --- /dev/null +++ b/scripts/.local/bin/checkzswap @@ -0,0 +1,38 @@ +#! /bin/sh - + +# https://gist.github.com/phizev/31185a30e7d4984724f1fbbf9c2afe19 + +ENABLED=$(cat /sys/module/zswap/parameters/enabled) +COMPRESSOR=$(cat /sys/module/zswap/parameters/compressor) +ZPOOL=$(cat /sys/module/zswap/parameters/zpool) +PAGE_SIZE=$(getconf PAGE_SIZE) +STORED_PAGES=$(cat /sys/kernel/debug/zswap/stored_pages) +POOL_TOTAL_SIZE=$(cat /sys/kernel/debug/zswap/pool_total_size) + +POOL_SIZE=$(numfmt --to=iec-i $POOL_TOTAL_SIZE) + +if [ "$POOL_TOTAL_SIZE" = "0" ] +then + DECOMPRESSED_SIZE="N/A" + RATIO="N/A" +else + DECOMPRESSED_SIZE=$(echo "$STORED_PAGES * $PAGE_SIZE" | bc | numfmt --to=iec-i) + RATIO=$(echo "scale=3; $STORED_PAGES * $PAGE_SIZE / $POOL_TOTAL_SIZE" | bc -l) +fi + +echo "Zswap enabled: $ENABLED" +echo "Compressor: $COMPRESSOR" +echo "Zpool: $ZPOOL" +echo +echo "Page size: $PAGE_SIZE" +echo "Stored pages: $STORED_PAGES" +echo "Pool size: $POOL_SIZE" +echo "Decompressed size: $DECOMPRESSED_SIZE" +echo "Page compression ratio: $RATIO" + +if [ "$1" = "-v" ] +then + echo + grep -R . /sys/kernel/debug/zswap/ + grep -R . /sys/module/zswap/parameters/ +fi diff --git a/scripts/.local/bin/checkzwap b/scripts/.local/bin/checkzwap deleted file mode 100755 index 902c35c..0000000 --- a/scripts/.local/bin/checkzwap +++ /dev/null @@ -1 +0,0 @@ -doas grep -R . /sys/kernel/debug/zswap diff --git a/scripts/.local/bin/gendunstrc b/scripts/.local/bin/gendunstrc new file mode 100755 index 0000000..10fca2c --- /dev/null +++ b/scripts/.local/bin/gendunstrc @@ -0,0 +1,35 @@ +#!/bin/sh + +# Generates dunst configuration file + +cat <<CONF +[global] + monitor = 0 + follow = keyboard + origin = bottom-right + offset = 0x0 + padding = 10 + transparency = 0 + font = Liberation Mono 10 + format = "<b>%s</b>\n%b" + frame_width=5 + corner_radius=0 + +[urgency_low] + background = "$(getxcolor background:)" + foreground = "$(getxcolor foreground:)" # color7 + frame_color = "$(getxcolor foreground:)" # color7 + timeout = 3 + +[urgency_normal] + background = "$(getxcolor background:)" # color0 + foreground = "$(getxcolor foreground:)" # color4 + frame_color = "$(getxcolor foreground:)" # color4 + timeout = 5 + +[urgency_critical] + background = "$(getxcolor background:)" # color4 + foreground = "$(getxcolor color1:)" # color0 + frame_color = "$(getxcolor color1:)" # color4 + timeout = 20 +CONF diff --git a/scripts/.local/bin/genzathurarc b/scripts/.local/bin/genzathurarc new file mode 100755 index 0000000..ba4f516 --- /dev/null +++ b/scripts/.local/bin/genzathurarc @@ -0,0 +1,50 @@ +#!/bin/sh + +# Generates zathura configuration file + +cat <<CONF +set sandbox none +set statusbar-h-padding 0 +set statusbar-v-padding 0 +set page-padding 1 +set selection-clipboard clipboard +map u scroll half-up +map d scroll half-down +map D toggle_page_mode +map r reload +map R rotate +map K zoom in +map J zoom out +map i recolor +map p print + +set completion-bg "$(getxcolor background:)" +set completion-fg "$(getxcolor foreground:)" +set completion-group-bg "$(getxcolor background:)" +set completion-group-fg "$(getxcolor color2:)" +set completion-highlight-bg "$(getxcolor foreground:)" +set completion-highlight-fg "$(getxcolor background:)" +set default-bg "$(getxcolor background:)" +set default-fg "$(getxcolor foreground:)" +set inputbar-bg "$(getxcolor background:)" +set inputbar-fg "$(getxcolor foreground:)" +set notification-bg "$(getxcolor background:)" +set notification-fg "$(getxcolor foreground:)" +set notification-error-bg "$(getxcolor color1:)" +set notification-error-fg "$(getxcolor foreground:)" +set notification-warning-bg "$(getxcolor color1:)" +set notification-warning-fg "$(getxcolor foreground:)" +set statusbar-bg "$(getxcolor background:)" +set statusbar-fg "$(getxcolor foreground:)" +set index-bg "$(getxcolor background:)" +set index-fg "$(getxcolor foreground:)" +set index-active-bg "$(getxcolor foreground:)" +set index-active-fg "$(getxcolor background:)" +set render-loading-bg "$(getxcolor background:)" +set render-loading-fg "$(getxcolor foreground:)" + +set smooth-scroll true +set window-title-home-tilde true +set statusbar-basename true +set selection-clipboard clipboard +CONF diff --git a/scripts/.local/bin/getxcolor b/scripts/.local/bin/getxcolor new file mode 100755 index 0000000..b4cdd90 --- /dev/null +++ b/scripts/.local/bin/getxcolor @@ -0,0 +1,2 @@ +#!/bin/sh +xrdb -query | grep $1 | awk '{print $2}' diff --git a/scripts/.local/bin/setbg b/scripts/.local/bin/setbg index 795b28f..ab75f70 100755 --- a/scripts/.local/bin/setbg +++ b/scripts/.local/bin/setbg @@ -9,25 +9,25 @@ # Location of link to wallpaper link. bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/wallpapers/bg" -# Configuration files of applications that have their themes changed by pywal. -dunstconf="${XDG_CONFIG_HOME:-$HOME/.config}/dunst/dunstrc" -zathuraconf="${XDG_CONFIG_HOME:-$HOME/.config}/zathura/zathurarc" - -trueloc="$(readlink -f "$1")" && -case "$(file --mime-type -b "$trueloc")" in - image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;; - inode/directory ) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;; - *) notify-send "Error" "Not a valid image." ; exit 1;; -esac - -# If pywal is installed, use it. -if command -v wal >/dev/null 2>&1 ; then - wal -i "$(readlink -f $bgloc)" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 && - pidof dwm >/dev/null && xdotool key super+F12 -# If pywal is removed, return config files to normal. -else - [ -f "$dunstconf.bak" ] && unlink "$dunstconf" && mv "$dunstconf.bak" "$dunstconf" - [ -f "$zathuraconf.bak" ] && unlink "$zathuraconf" && mv "$zathuraconf.bak" "$zathuraconf" -fi +## Configuration files of applications that have their themes changed by pywal. +#dunstconf="${XDG_CONFIG_HOME:-$HOME/.config}/dunst/dunstrc" +#zathuraconf="${XDG_CONFIG_HOME:-$HOME/.config}/zathura/zathurarc" +# +#trueloc="$(readlink -f "$1")" && +#case "$(file --mime-type -b "$trueloc")" in +# image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;; +# inode/directory ) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;; +# *) notify-send "Error" "Not a valid image." ; exit 1;; +#esac +# +## If pywal is installed, use it. +#if command -v wal >/dev/null 2>&1 ; then +# wal -i "$(readlink -f $bgloc)" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 && +# pidof dwm >/dev/null && xdotool key super+F12 +## If pywal is removed, return config files to normal. +#else +# [ -f "$dunstconf.bak" ] && unlink "$dunstconf" && mv "$dunstconf.bak" "$dunstconf" +# [ -f "$zathuraconf.bak" ] && unlink "$zathuraconf" && mv "$zathuraconf.bak" "$zathuraconf" +#fi xwallpaper --zoom "$bgloc" diff --git a/scripts/.local/bin/statusbar/sb-music b/scripts/.local/bin/statusbar/sb-music index 7ea7032..06e7e4d 100755 --- a/scripts/.local/bin/statusbar/sb-music +++ b/scripts/.local/bin/statusbar/sb-music @@ -1,19 +1,5 @@ #!/bin/sh -filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;} - pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 & -case $BLOCK_BUTTON in - 1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause - 2) mpc toggle | filter ;; # right click, pause/unpause - 3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing. -- ⏸ when paused. -- Left click opens ncmpcpp. -- Middle click pauses. -- Scroll changes track.";; # right click, pause/unpause - 4) mpc prev | filter ;; # scroll up, previous - 5) mpc next | filter ;; # scroll down, next - 6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;; - *) mpc status | filter ;; -esac +mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -; diff --git a/scripts/.local/bin/tablet/osu b/scripts/.local/bin/tablet/osu index ef9e319..c46480a 100755 --- a/scripts/.local/bin/tablet/osu +++ b/scripts/.local/bin/tablet/osu @@ -1,4 +1,4 @@ #!/bin/bash notify-send 'Tablet: osu!' -#tabletscale 1280 718 4 87 54 0 10 -tabletscale 1366 768 4 100 50 0 0 +#$HOME/.local/bin/tablet/scale 1366 768 4 100 50 0 0 +$HOME/.local/bin/tablet/scale 1920 1080 4 100 50 0 0 |
