From ba480949ccd5f00f9cfdcae15b67ffb895965833 Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 25 Feb 2018 21:27:13 +0100 Subject: moved to i3-gaps and i3blocks --- i3blocks.conf | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++ i3wm.conf | 44 ++++++++++++++++++---- install | 16 ++++++++ install.config | 1 + scripts/battery.sh | 60 ++++++++++++++++++++++++++++++ scripts/eth.sh | 15 ++++++++ scripts/wifi.sh | 42 +++++++++++++++++++++ 7 files changed, 277 insertions(+), 8 deletions(-) create mode 100644 i3blocks.conf create mode 100755 scripts/battery.sh create mode 100755 scripts/eth.sh create mode 100755 scripts/wifi.sh diff --git a/i3blocks.conf b/i3blocks.conf new file mode 100644 index 0000000..54dc8d6 --- /dev/null +++ b/i3blocks.conf @@ -0,0 +1,107 @@ +# dotfiles -- i3blocks +# author: johannst + + +# NOTE: +# Env Variables exported to scripts specified in 'command=' +# BLOCK_NAME=name # indicator block name '[name]' +# BLOCK_INSTANCE=inst # value of 'instance=inst' +# BLOCK_INTERVAL=10 # value of 'interval=10' +# BLOCK_BUTTON=1 # set to '1' if script gets triggered by click event +# BLOCK_X=795 # x coordinate of click event +# BLOCK_Y=9 # y coordinate of click event +# +# Coloring indicator blocks +# color=#FF0000 # sets text color +# background=#222222 # sets block background +# border=#9FBC00 # sets color of visible block border +# +# Trigger block action by signal +# signal=1 # trigger command by sending SIGRTMIN+1 +# signal=8 # trigger command by sending SIGRTMIN+8 + + +# +# Global settings +# + +command=/usr/lib/i3blocks/$BLOCK_NAME +markup=none +separator_block_width=15 +#separator=false +border_top=0 +border_left=0 +border_right=0 +border_bottom=2 + +# +# Network +# + +[eth] +command=$HOME/.scripts/eth.sh +instance=enp0s25 +label=: +interval=10 +# light green +border=#9FBC00 + +[wifi] +command=$HOME/.scripts/wifi.sh --ap_quality --ap_name +instance=wlp3s0 +label=: +interval=10 +# bright grey +border=#928374 + +# +# Load +# + +[load_average] +label=: +interval=10 +# red +border=#cc241d + +# +# Battery +# + +[battery] +command=$HOME/.scripts/battery.sh +label=: +instance=BAT0 +interval=5 +# yellow - orange +border=#d79921 + +# +# Volume +# + +[volume] +label=: +instance=Master +interval=5 +# light purple +border=#b16286 + +# +# Date Time +# + +[date] +command=echo ":$(date '+%Y-%m-%d')" +interval=60 +separator=false +separator_block_width=5 +# blue +border=#458588 + +[time] +command=echo ":$(date '+%H:%M:%S')" +interval=5 +# olive +border=#98971a + diff --git a/i3wm.conf b/i3wm.conf index b6ea62f..b70dac6 100644 --- a/i3wm.conf +++ b/i3wm.conf @@ -1,8 +1,6 @@ # dotfiles -- i3config # author: johannst -# i3 config file (v4) - # helpful cmdline tools: # * xev # * xmodmap @@ -12,15 +10,18 @@ set $mod Mod1 # super key #set $mod Mod4 -font pango:Terminus 10 +#font pango:Terminus 12 +font pango:xos4 Terminus 12 # mouse+$mod to move/rezie window in floating mode floating_modifier $mod # launch terminal -bindsym $mod+Return exec st +bindsym $mod+Return exec i3-sensible-terminal # launch dmenu_run bindsym $mod+d exec dmenu_run +# launch dmenu_run +bindsym $mod+p exec passmenu # kill focused Window bindsym $mod+Shift+c kill # reload the configuration file @@ -142,7 +143,23 @@ bindsym XF86AudioMute exec "amixer set Master toggle" #}}} #{{{ lock/suspend -set $lock_cmd i3lock --inactivity-timeout 30s -d --ignore-empty-password -c 455a64 +#set $lock_cmd i3lock --inactivity-timeout 30s -d --ignore-empty-password -c 455a64 -i ~/.i3/lock.png +set $lock_cmd i3lock \ + --ignore-empty-password \ + -B=100 \ + --indicator \ + --indpos="100:800" \ + --radius 30 \ + --insidecolor=00000000 \ + --insidevercolor=00000000 \ + --insidewrongcolor=00000000 \ + --ringcolor=ffffff80 \ + --ringvercolor=fffffff0 \ + --ringwrongcolor=ff0000ff \ + --veriftext="" \ + --wrongtext="" \ + --keyhlcolor=00ff0080 \ + --bshlcolor=ff000080 # lock screen bindsym $mod+Control+l exec $lock_cmd @@ -164,17 +181,28 @@ mode "$power_mode" { # Start i3bar bar { - status_command i3status --config ~/.i3/i3status.conf + font pango: xos4 Terminus, Font Awesome 5 Free, Ionicons 10 + position top + height 26 + status_command i3blocks -c ~/.i3/i3blocks.conf + #status_command i3status --config ~/.i3/i3status.conf + + #separator_symbol "■" + #tray_output LVDS-1 + #tray_padding 0 } #}}} # PLAYGROUND +gaps outer 0 +gaps inner 5 + # pin applications to specific workspace # helpfull to get name: 'xprop | grep WM_CLASS' (then click window) -assign [class="Firefox"] 9 +#assign [class="Firefox"] 9 -bindsym $mod+p exec "notify-send \\"Hello, i3; $USER\\"" +#bindsym $mod+p exec "notify-send \\"Hello, i3; $USER\\"" #% vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1 diff --git a/install b/install index d3e5207..159b352 100755 --- a/install +++ b/install @@ -16,6 +16,7 @@ gToolsConfig=( "Xresources:xterm:xtermConfigInstaller" "i3config:i3:i3ConfigInstaller" "i3status:i3status:i3statusConfigInstaller" +"i3blocks:i3blocks:i3blocksConfigInstaller" ) gMagicNumber=e2718281 @@ -179,6 +180,21 @@ function i3statusConfigInstaller() { return 0 } +#}}} +#{{{ i3blocksConfigInstaller + +function i3blocksConfigInstaller() { + local i3_home=~/.i3 + local i3_blocks_conf=$i3_home/i3blocks.conf + mkdir $i3_home 2> /dev/null + if [ -f $i3_blocks_conf ]; then + return 1 + fi + cp i3blocks.conf $i3_blocks_conf + + return 0 +} + #}}} #{{{ Installer Main Loop diff --git a/install.config b/install.config index 5e82273..42b8c9c 100644 --- a/install.config +++ b/install.config @@ -13,3 +13,4 @@ n - vimrc n - Xresources n - i3config n - i3status +n - i3blocks diff --git a/scripts/battery.sh b/scripts/battery.sh new file mode 100755 index 0000000..05ac440 --- /dev/null +++ b/scripts/battery.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# dotfiles -- scripts/battery.sh +# author: johannst + +bat="${BLOCK_INSTANCE:-BAT0}" +[[ ! -f "/sys/class/power_supply/$bat/type" ]] && exit 0 + +show_bat_use_design_capacity=0 +show_bat_status=0 +show_bat_color_output=0 +for arg in "$@"; do + case $arg in + -dc | --design_capacity) show_bat_use_design_capacity=1 + ;; + -s | --status) show_bat_status=1 + ;; + -c | --color) show_bat_color_output=1 + ;; + *) # ignore unknown + ;; + esac +done + +# Unknown, Charging, Discharging, Full +BAT_STATUS=$(cat /sys/class/power_supply/$bat/status) +BAT_NOW=$(cat /sys/class/power_supply/$bat/charge_now) +[[ $show_bat_use_design_capacity == 1 ]] \ + && BAT_FULL=$(cat /sys/class/power_supply/$bat/charge_full_design) \ + || BAT_FULL=$(cat /sys/class/power_supply/$bat/charge_full) + +BAT_POWER=$(echo $BAT_NOW $BAT_FULL | awk '{ print int($1 * 100 / $2); }') + +OUT="$BAT_POWER%" +[[ $show_bat_status == 1 ]] && \ + case $BAT_STATUS in + Charging) OUT="$OUT (Charging)" + ;; + *) # only show charging state for now + ;; + esac + +echo "$OUT" + +[[ $show_bat_color_output == 1 ]] && \ + # print twice, else colors not working?! + echo "$OUT" + if [[ $BAT_POWER -ge 80 ]]; then + # green + echo "#00FF00" + elif [[ $BAT_POWER -ge 60 ]]; then + # yellow + echo "#FFF600" + elif [[ $BAT_POWER -ge 40 ]]; then + # dark orange + echo "#FFAE00" + else + # red + echo "#FF0000" + fi + diff --git a/scripts/eth.sh b/scripts/eth.sh new file mode 100755 index 0000000..2fb8b30 --- /dev/null +++ b/scripts/eth.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# dotfiles -- scripts/eth.sh +# author: johannst + +if="${BLOCK_INSTANCE:-enp0s25}" +[[ ! -d /sys/class/net/${if} ]] && exit 0 + +# operstate: down, up +[[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]] && exit 0 + +# first ipv4 addr +IP_ADDR=$(ip address show $if | grep 'inet ' | sed 's/\s\+inet \([0-9.]\+\)\/.*/\1/') + +echo "$IP_ADDR" + diff --git a/scripts/wifi.sh b/scripts/wifi.sh new file mode 100755 index 0000000..6f8417a --- /dev/null +++ b/scripts/wifi.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# dotfiles -- scripts/wifi.sh +# author: johannst + +if="${BLOCK_INSTANCE:-wlp3s0}" +[[ ! -d /sys/class/net/${if} ]] && exit 0 + +show_ap_mac=0 +show_ap_quality=0 +show_ap_name=0 +for arg in "$@"; do + case $arg in + -aq | --ap_quality) show_ap_quality=1 + ;; + -am | --ap_mac) show_ap_mac=1 + ;; + -an | --ap_name) show_ap_name=1 + ;; + *) # ignore unknown + ;; + esac +done + +AP_NAME=$(iwgetid -r $if) +AP_MAC=$(iwgetid -a $if | sed 's/.*\(\([0-9A-F]\{2\}:\)\{5\}[0-9A-F]\{2\}\).*/\1/') +AP_QUALITY=$(grep $if /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')% + +# first ipv4 addr +IP_ADDR=$(ip address show $if | grep 'inet ' | sed 's/\s\+inet \([0-9.]\+\)\/.*/\1/') + +OUT="$IP_ADDR" +if [[ $show_ap_name == 1 && $show_ap_quality == 1 ]]; then + OUT="$OUT ($AP_NAME $AP_QUALITY)" +elif [[ $show_ap_name == 1 ]]; then + OUT="$OUT ($AP_NAME)" +elif [[ $show_ap_quality == 1 ]]; then + OUT="$OUT ($AP_QUALITY)" +fi +[[ $show_ap_mac == 1 ]] && OUT="$OUT $AP_MAC" + +echo "$OUT" + -- cgit v1.2.3