diff options
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/open | 4 | ||||
-rwxr-xr-x | .local/bin/shorts/adbs | 6 | ||||
-rwxr-xr-x | .local/bin/shorts/mk | 5 | ||||
-rwxr-xr-x | .local/bin/shorts/windowshot | 6 | ||||
-rwxr-xr-x | .local/bin/statusbar/disk-io | 93 | ||||
-rwxr-xr-x | .local/bin/statusbar/disk_usage | 123 | ||||
-rwxr-xr-x | .local/bin/statusbar/i3weather | 3 |
7 files changed, 236 insertions, 4 deletions
diff --git a/.local/bin/open b/.local/bin/open index 5936451..69dcb9c 100755 --- a/.local/bin/open +++ b/.local/bin/open @@ -7,7 +7,7 @@ for file in "$@"; do *.pdf|*.djvu|*.epub) setsid -f zathura "$file" 2>/dev/null ;; *.png|*.jpg|*.jpeg|*.webp) setsid -f nsxiv "$file" ;; - *.gif|*.mkv|*.mp3|*.mp4|*.webm|*.ogg) ${PLAYER:-mpv --sub-auto=fuzzy} "$file" ;; + *.gif|*.mkv|*.mp3|*.mp4|*.webm|*.ogg) ${PLAYER:-mpv --no-config --sub-auto=fuzzy} "$file" ;; *.html) ${BROWSER:-w3m} "$file" ;; *.pl.txt) fpl "$file" ;; *.txt|*.description) ${PAGER:-less} "$file" ;; @@ -31,7 +31,7 @@ for file in "$@"; do application/sc) sc-im "$file" ;; application/x-executable) "$file" ;; image/*) setsid -f nsxiv "$file" ;; - video/*|audio/*) ${PLAYER:- mpv --sub-auto=fuzzy} "$file" ;; + video/*|audio/*) ${PLAYER:- mpv --no-config --sub-auto=fuzzy} "$file" ;; *) xdg-open "$file" || exit [ -n "$DISPLAY" ] && notify-send "⚠️ open: unknown filetype" "$filetype" diff --git a/.local/bin/shorts/adbs b/.local/bin/shorts/adbs index bca7733..20bba2b 100755 --- a/.local/bin/shorts/adbs +++ b/.local/bin/shorts/adbs @@ -1,3 +1,7 @@ #!/bin/sh -adb -s "${ADB_DEVICE}" shell "$@" +if [ -n "$ADB_DEVICE" ]; then + adb -s "${ADB_DEVICE}" shell "$@" +else + adb shell "$@" +fi diff --git a/.local/bin/shorts/mk b/.local/bin/shorts/mk new file mode 100755 index 0000000..392320f --- /dev/null +++ b/.local/bin/shorts/mk @@ -0,0 +1,5 @@ +#!/bin/sh + +# make a file in specified path + +mkdir -pv "$(dirname "$1")" && touch "$1" diff --git a/.local/bin/shorts/windowshot b/.local/bin/shorts/windowshot new file mode 100755 index 0000000..c654cc7 --- /dev/null +++ b/.local/bin/shorts/windowshot @@ -0,0 +1,6 @@ +#!/bin/sh + +image="${XDG_PICTURES_DIR:-$HOME/Pictures}/xwindow.jpg" +import -window "$(xdotool selectwindow)" "$image" +# dragon-drop --and-exit "$image" +xclip -sel clipboard -t image/png -i "$image" diff --git a/.local/bin/statusbar/disk-io b/.local/bin/statusbar/disk-io new file mode 100755 index 0000000..daf8e58 --- /dev/null +++ b/.local/bin/statusbar/disk-io @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2016 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to monitor disk io + +label="${LABEL:-""}" +dt="${DT:-5}" +MB_only="${MB_ONLY:-0}" +kB_only="${KB_ONLY:-0}" +width="${WIDTH:-4}" +MB_precision="${MB_PRECISION:-1}" +kB_precision="${KB_PRECISION:-0}" +regex="${REGEX:-$BLOCK_INSTANCE}" +regex="${regex:-/^(s|h)d[a-zA-Z]+/}" +threshold="${THRESHOLD:-0}" +warn_color="${WARN_COLOR:-#FF0000}" +sep="${SEPARATOR:-/}" +unit_suffix="${SUFFIX:-B/s}" +align="${ALIGN--}" + +function list_devices { + echo "Devices iostat reports that match our regex:" + iostat | awk '$1~/^(s|h)d[a-zA-Z]+/{print $1}' +} + +while getopts L:t:w:p:P:R:s:ST:C:lLMmKkh opt; do + case "$opt" in + L) label="$OPTARG" ;; + t) dt="$OPTARG" ;; + w) width="$OPTARG" ;; + p) kB_precision="$OPTARG" ;; + P) MB_precision="$OPTARG" ;; + R) regex="$OPTARG" ;; + s) sep="$OPTARG" ;; + S) unit_suffix="" ;; + T) threshold="$OPTARG" ;; + C) warn_color="$OPTARG" ;; + l) list_devices; exit 0 ;; + M|m) MB_only=1 ;; + K|k) kB_only=1 ;; + h) printf \ +"Usage: disk-io [-t time] [-w width] [-p kB_precision] [-P MB_precision] [-R regex] [-s separator] [-S] [-T threshold [-C warn_color]] [-k|-M] [-l] [-h] +Options: +-L\tLabel to put in front of the text. Default: $label +-t\tTime interval in seconds between measurements. Default: $dt +-w\tThe width of printed floats. Default: $width +-p\tThe precision of kB/s floats. Default: $kB_precision +-P\tThe precision of MB/s floats. Default: $MB_precision +-R\tRegex that devices must match. Default: $regex +-s\tSeparator to put between rates. Default: $sep +-S\tShort units, omit B/s in kB/s and MB/s. +-T\tRate in kB/s to exceed to trigger a warning. Default: not enabled +-C\tColor to change the blocklet to warn the user. Default: $warn_color +-l\tList devices that iostat reports +-M\tDo not switch between MB/s and kB/s, use only MB/s +-k\tDo not switch between MB/s and kB/s, use only kB/s +-h\tShow this help text +" && exit 0;; + esac +done + +iostat -dyz "$dt" | awk -v sep="$sep" " + BEGIN { + rx = wx = 0; + } + { + if(\$0 == \"\") { + if ($threshold > 0 && (rx >= $threshold || wx >= $threshold)) { + printf \"<span color='$warn_color'>\"; + } + printf \"$label\"; + if(!$kB_only && ($MB_only || rx >= 1024 || wx >= 1024)) { + printf \"%$align$width.${MB_precision}f%s%$width.${MB_precision}f M$unit_suffix\", rx/1024, sep, wx/1024; + } + else { + printf \"%$align$width.${kB_precision}f%s%$width.${kB_precision}f k$unit_suffix\", rx, sep, wx; + } + if ($threshold > 0 && (rx >= $threshold || wx >= $threshold)) { + printf \"</span>\"; + } + printf \"\n\"; + fflush(stdout); + } + else if(\$1~/^Device:?/) { + rx = wx = 0; + } + else if(\$1~$regex) { + rx += \$3; + wx += \$4; + } + }" diff --git a/.local/bin/statusbar/disk_usage b/.local/bin/statusbar/disk_usage new file mode 100755 index 0000000..b129fc9 --- /dev/null +++ b/.local/bin/statusbar/disk_usage @@ -0,0 +1,123 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# MIT License + +# Copyright (c) 2017 Christian Schläppi + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import sys +import subprocess + + +def get_disk_stats(mp): + stat = os.statvfs(mp) + + total = stat.f_blocks * stat.f_frsize / 1024 ** 3 + avail = stat.f_bavail * stat.f_frsize / 1024 ** 3 + used = total - avail + + return { + 'avail': avail, + 'total': total, + 'used': used, + 'perc_used': 100 * used / total + } + + +def launch_ncdu(mp): + cmd = [ + '/usr/bin/sakura', + '-t', + 'pop-up', + '-e', + '/usr/bin/ncdu %s' % mp, + '-x', + ] + + subprocess.Popen( + cmd, + stdout=open(os.devnull, 'w'), + stderr=subprocess.STDOUT + ) + + +def parse_args(): + args = { + 'warn_threshold': 80, + 'crit_threshold': 90, + 'warn_color': '#d6af4e', + 'crit_color': '#d64e4e', + 'format': '{used:.1f}G/{total:.1f}G ({perc_used:.1f}%) - {avail:.1f}G' + } + + try: + for arg in sys.argv[1:]: + key, value = arg.split('=') + args[key] = int(value) if value.isdigit() else value + except (KeyError, ValueError): + # ValuError in case user does something weird + pass + + return args + + +def get_instance(): + p = os.getenv('BLOCK_INSTANCE') + if p and os.path.exists(p): + return p + + return os.getenv('HOME') + + +def main(): + + output_color = '' + args = parse_args() + m_point = get_instance() + stats = get_disk_stats(m_point) + + # get some more info when not called by i3blocks + if not os.getenv('BLOCK_NAME'): + print('Args: %s' % args) + print('Stats: %s' % stats) + print('Mount Point: %s' % m_point) + + # print stats with format if given + print(args['format'].format(**stats)) + print() + + # determine color + if args['crit_threshold'] > int(stats['perc_used']) >= args['warn_threshold']: + output_color = args['warn_color'] + elif stats['perc_used'] >= args['crit_threshold']: + output_color = args['crit_color'] + + print(output_color) + + # handle click-event + _button = os.getenv('BLOCK_BUTTON') + if _button and int(_button) == 1: + launch_ncdu(m_point) + + +if __name__ == '__main__': + main() diff --git a/.local/bin/statusbar/i3weather b/.local/bin/statusbar/i3weather index 2d34149..d008deb 100755 --- a/.local/bin/statusbar/i3weather +++ b/.local/bin/statusbar/i3weather @@ -1,5 +1,6 @@ #!/bin/sh -# i3block for displaying the current temperature, humidity and precipitation, if wttr.in i unavailable then WEATHER UNAVAILABLE will be displayed +# weather module for i3blocks +# output is set to 'WEATHER UNAVAILABLE' in case wttr.in is unreachable case "$BLOCK_BUTTON" in '') ;; |