aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-06-08 22:01:23 +0200
committerKarel Kočí <cynerd@email.cz>2022-06-08 22:01:23 +0200
commit3c905d717a331b9be6d7036624378d0617234a82 (patch)
tree59e8aea77ace1b2e6bae66b02b28eebce7924a43
parentdf97cf3f26055928ed88b8be5f8251f55f1fcb79 (diff)
downloadmyconfigs-3c905d717a331b9be6d7036624378d0617234a82.tar.gz
myconfigs-3c905d717a331b9be6d7036624378d0617234a82.tar.bz2
myconfigs-3c905d717a331b9be6d7036624378d0617234a82.zip
Update i3blocks
-rw-r--r--config/alacritty.yml2
-rw-r--r--config/i3blocks/config1
-rwxr-xr-xconfig/i3blocks/scripts/bandwidth116
-rwxr-xr-xconfig/i3blocks/scripts/iface61
-rw-r--r--config/nix/nix.conf4
-rw-r--r--config/user-dirs.conf10
-rwxr-xr-xlocal/bin/elektroline0027
m---------private0
-rw-r--r--vim/ftplugin/c.vim2
9 files changed, 195 insertions, 28 deletions
diff --git a/config/alacritty.yml b/config/alacritty.yml
index 046e1f5..75b2cd1 100644
--- a/config/alacritty.yml
+++ b/config/alacritty.yml
@@ -12,7 +12,7 @@ scrolling:
multiplier: 3
font:
- size: 8.5
+ size: 8
colors:
primary:
diff --git a/config/i3blocks/config b/config/i3blocks/config
index 9cd983e..6b8acc8 100644
--- a/config/i3blocks/config
+++ b/config/i3blocks/config
@@ -42,6 +42,7 @@ interval=2
separator=false
[bandwidth]
+command=~/.config/i3blocks/scripts/bandwidth
interval=2
[ssid]
diff --git a/config/i3blocks/scripts/bandwidth b/config/i3blocks/scripts/bandwidth
new file mode 100755
index 0000000..9b92274
--- /dev/null
+++ b/config/i3blocks/scripts/bandwidth
@@ -0,0 +1,116 @@
+#!/usr/bin/env bash
+# Copyright (C) 2012 Stefan Breunig <stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de>
+# Copyright (C) 2014 kaueraal
+# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Get custom IN and OUT labels if provided by command line arguments
+while [[ $# -gt 1 ]]; do
+ key="$1"
+ case "$key" in
+ -i|--inlabel)
+ INLABEL="$2"
+ shift;;
+ -o|--outlabel)
+ OUTLABEL="$2"
+ shift;;
+ esac
+ shift
+done
+
+[[ -z "$INLABEL" ]] && INLABEL="IN "
+[[ -z "$OUTLABEL" ]] && OUTLABEL="OUT "
+
+# Use the provided interface, otherwise the device used for the default route.
+if [[ -z $INTERFACE ]] && [[ -n $BLOCK_INSTANCE ]]; then
+ INTERFACE=$BLOCK_INSTANCE
+elif [[ -z $INTERFACE ]]; then
+ for version in 4 6; do
+ INTERFACE=$(ip -$version r | sed -n 's/^default.*dev \([^ ]*\).*/\1/p')
+ [ -z "$INTERFACE" ] || break
+ done
+fi
+
+# Exit if there is no default route
+[[ -z "$INTERFACE" ]] && exit
+
+# Issue #36 compliant.
+if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || \
+ (! [ "$TREAT_UNKNOWN_AS_UP" = "1" ] &&
+ ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ])
+then
+ echo "$INTERFACE down"
+ echo "$INTERFACE down"
+ echo "#FF0000"
+ exit 0
+fi
+
+# path to store the old results in
+path="/tmp/$(basename $0)-${INTERFACE}"
+
+# grabbing data for each adapter.
+read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes"
+read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes"
+
+# get time
+time="$(date +%s)"
+
+# write current data if file does not exist. Do not exit, this will cause
+# problems if this file is sourced instead of executed as another process.
+if ! [[ -f "${path}" ]]; then
+ echo "${time} ${rx} ${tx}" > "${path}"
+ chmod 0666 "${path}"
+fi
+
+
+# read previous state and update data storage
+read old < "${path}"
+echo "${time} ${rx} ${tx}" > "${path}"
+
+# parse old data and calc time passed
+old=(${old//;/ })
+time_diff=$(( $time - ${old[0]} ))
+
+# sanity check: has a positive amount of time passed
+[[ "${time_diff}" -gt 0 ]] || exit
+
+# calc bytes transferred, and their rate in byte/s
+rx_diff=$(( $rx - ${old[1]} ))
+tx_diff=$(( $tx - ${old[2]} ))
+rx_rate=$(( $rx_diff / $time_diff ))
+tx_rate=$(( $tx_diff / $time_diff ))
+
+# shift by 10 bytes to get KiB/s. If the value is larger than
+# 1024^2 = 1048576, then display MiB/s instead
+
+# incoming
+echo -n "$INLABEL"
+rx_kib=$(( $rx_rate >> 10 ))
+if hash bc 2>/dev/null && [[ "$rx_rate" -gt 1048576 ]]; then
+ printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`"
+else
+ echo -n "${rx_kib}K"
+fi
+
+echo -n " "
+
+# outgoing
+echo -n "$OUTLABEL"
+tx_kib=$(( $tx_rate >> 10 ))
+if hash bc 2>/dev/null && [[ "$tx_rate" -gt 1048576 ]]; then
+ printf '%sM\n' "`echo "scale=1; $tx_kib / 1024" | bc`"
+else
+ echo "${tx_kib}K"
+fi
diff --git a/config/i3blocks/scripts/iface b/config/i3blocks/scripts/iface
index abac9c0..ffa576e 100755
--- a/config/i3blocks/scripts/iface
+++ b/config/i3blocks/scripts/iface
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
@@ -17,38 +17,61 @@
#------------------------------------------------------------------------
-# Locate current default interface, but use only wlp (wifi) or enp (ethernet)
-# TODO probably also add connection over phone
-IF=$(ip route | awk '/^default .* (wlp|wlo|enp)/ { print $5 ; exit }')
+# Use the provided interface, otherwise the device used for the default route.
+IF="${IFACE:-$BLOCK_INSTANCE}"
+for version in 4 6; do
+ IF="${IF:-$(ip -$version route | sed -n 's/^default.*dev \([^ ]*\).*/\1/p')}"
+done
+
+# Exit if there is no default route
+[[ -z "$IF" ]] && exit
#------------------------------------------------------------------------
# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless
# connection (think desktop), the corresponding block should not be displayed.
[[ ! -d /sys/class/net/${IF} ]] && exit
-# Note this passes if IF is empty!
#------------------------------------------------------------------------
-# If no IF is selected then we want see down, not anything else.
-if [ -z "$IF" ] || [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then
+AF=${ADDRESS_FAMILY:-"inet6\?"}
+LABEL="${LABEL:-}"
+
+for flag in "$1" "$2"; do
+ case "$flag" in
+ -4)
+ AF=inet ;;
+ -6)
+ AF=inet6 ;;
+ -L)
+ if [[ "$IF" = "" ]]; then
+ LABEL="iface"
+ else
+ LABEL="$IF:"
+ fi ;;
+ esac
+done
+
+if [[ "$IF" = "" ]] || [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then
+ echo "${LABEL} down" # full text
+ echo "${LABEL} down" # short text
+ echo \#FF0000 # color
exit
fi
-case $1 in
- -4)
- AF=inet ;;
- -6)
- AF=inet6 ;;
- *)
- AF=inet6? ;;
-esac
-
-# Use the first global scope address
-IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit")
+# Use the first global scope address that matches limitation and preffer not local one)
+while read -r ipaddr; do
+ case "$ipaddr" in
+ ""|169\.*|f*)
+ IPADDR="${IPADDR:-$ipaddr}"
+ continue # try another one
+ esac
+ IPADDR="$ipaddr"
+ break
+done <<<"$(ip addr show "$IF" | sed -n 's/.*inet6\? \([^/]\+\).* scope global.*/\1/p')"
case $BLOCK_BUTTON in
- 3) echo -n "$IPADDR" | xclip -q -se c ;;
+ 3) echo -n "$IPADDR" | xclip -q -se c ;;
esac
#------------------------------------------------------------------------
diff --git a/config/nix/nix.conf b/config/nix/nix.conf
index bea0e44..5ba0911 100644
--- a/config/nix/nix.conf
+++ b/config/nix/nix.conf
@@ -4,5 +4,5 @@ experimental-features = nix-command flakes
extra-platforms = armv7l-linux aarch64-linux
extra-sandbox-paths = /usr/bin/qemu-arm /usr/bin/qemu-aarch64
-substituters = https://cache.nixos.org https://thefloweringash-armv7.cachix.org
-trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= thefloweringash-armv7.cachix.org-1:v+5yzBD2odFKeXbmC+OPWVqx4WVoIVO6UXgnSAWFtso=
+substituters = https://cache.nixos.org https://thefloweringash-armv7.cachix.org https://arm.cachix.org
+trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= thefloweringash-armv7.cachix.org-1:v+5yzBD2odFKeXbmC+OPWVqx4WVoIVO6UXgnSAWFtso= arm.cachix.org-1:K3XjAeWPgWkFtSS9ge5LJSLw3xgnNqyOaG7MDecmTQ8=
diff --git a/config/user-dirs.conf b/config/user-dirs.conf
index 2f8b053..ea9337c 100644
--- a/config/user-dirs.conf
+++ b/config/user-dirs.conf
@@ -1,8 +1,8 @@
-XDG_DESKTOP_DIR="$HOME"
+XDG_DESKTOP_DIR="$HOME/"
XDG_DOWNLOAD_DIR="$HOME/downloads"
-XDG_TEMPLATES_DIR="$HOME/templates"
-XDG_PUBLICSHARE_DIR="$HOME/share"
+XDG_TEMPLATES_DIR="$HOME/"
+XDG_PUBLICSHARE_DIR="$HOME/"
XDG_DOCUMENTS_DIR="$HOME/documents"
XDG_MUSIC_DIR="$HOME/music"
-XDG_PICTURES_DIR="$HOME/pictures"
-XDG_VIDEOS_DIR="$HOME/videos"
+XDG_PICTURES_DIR="$HOME/images"
+XDG_VIDEOS_DIR="$HOME/video"
diff --git a/local/bin/elektroline00 b/local/bin/elektroline00
new file mode 100755
index 0000000..6ddbc0f
--- /dev/null
+++ b/local/bin/elektroline00
@@ -0,0 +1,27 @@
+#!/bin/bash
+path="/media/elektroline"
+
+usage() {
+ echo "Usage: $0 [OPTION].." >&2
+}
+
+umount="n"
+while getopts "u" opt; do
+ case "$opt" in
+ u)
+ umount="y"
+ ;;
+ *)
+ usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ "$umount" = "n" ]; then
+ sudo mkdir -p "$path"/{company,elektro_doc}
+ sudo mount.cifs -o username=kkoci "//Elektroline00/company" "$path/company"
+ sudo mount.cifs -o username=kkoci "//Elektroline00/elektro_doc" "$path/elektro_doc"
+else
+ sudo umount "$path/company" "$path/elektro_doc"
+fi
diff --git a/private b/private
-Subproject 7fe7f19db8c895b59985231d88c2f4b243f4cd9
+Subproject c5c5030068d0f290fd729aedb6c78bc855b5c8c
diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim
index 4eed046..df078c6 100644
--- a/vim/ftplugin/c.vim
+++ b/vim/ftplugin/c.vim
@@ -1,6 +1,6 @@
let b:ale_linters = ['ccls', 'cppcheck', 'flawfinder']
let b:ale_fixers = ['clang-format', 'remove_trailing_lines', 'trim_whitespace']
-let g:ale_c_ccls_init_options = {'cache': {'directory': '/tmp/ccls/cache'}}
+let g:ale_c_ccls_init_options = {'cache': {'directory': '/tmp/ccls/cache'}, 'compilationDatabaseDirectory': 'build'}
let g:ale_c_parse_compile_commands = 1
nmap <F8> :ALENext<cr>