From a2e1130b2ab79180c2fdb7257903fc5aa0e1f1d5 Mon Sep 17 00:00:00 2001 From: Joseph Groocock Date: Thu, 31 Mar 2016 03:06:44 +0100 Subject: [PATCH] Added i3 config --- .config/i3/alt-tab.sh | 19 +++ .config/i3/config | 154 ++++++++++++++++++++++++ .config/i3/cycleaudio.py | 31 +++++ .config/i3/disable-standby-fs.py | 33 +++++ .config/i3/i3 | 1 + .config/i3/lock.png | Bin 0 -> 7966 bytes .config/i3/lock.sh | 41 +++++++ .config/i3blocks/blocks/bandwidth | 90 ++++++++++++++ .config/i3blocks/blocks/battery | 97 +++++++++++++++ .config/i3blocks/blocks/clock | 5 + .config/i3blocks/blocks/cpu_usage | 53 ++++++++ .config/i3blocks/blocks/disk | 41 +++++++ .config/i3blocks/blocks/iface | 62 ++++++++++ .config/i3blocks/blocks/keyindicator | 70 +++++++++++ .config/i3blocks/blocks/load_average | 34 ++++++ .config/i3blocks/blocks/mediaplayer | 76 ++++++++++++ .config/i3blocks/blocks/memory | 61 ++++++++++ .config/i3blocks/blocks/openvpn | 149 +++++++++++++++++++++++ .config/i3blocks/blocks/temperature | 69 +++++++++++ .config/i3blocks/blocks/toggleoutput.sh | 27 +++++ .config/i3blocks/blocks/volume | 94 +++++++++++++++ .config/i3blocks/blocks/wifi | 46 +++++++ .config/i3blocks/config | 93 ++++++++++++++ 23 files changed, 1346 insertions(+) create mode 100755 .config/i3/alt-tab.sh create mode 100644 .config/i3/config create mode 100755 .config/i3/cycleaudio.py create mode 100644 .config/i3/disable-standby-fs.py create mode 120000 .config/i3/i3 create mode 100644 .config/i3/lock.png create mode 100755 .config/i3/lock.sh create mode 100755 .config/i3blocks/blocks/bandwidth create mode 100755 .config/i3blocks/blocks/battery create mode 100755 .config/i3blocks/blocks/clock create mode 100755 .config/i3blocks/blocks/cpu_usage create mode 100755 .config/i3blocks/blocks/disk create mode 100755 .config/i3blocks/blocks/iface create mode 100755 .config/i3blocks/blocks/keyindicator create mode 100755 .config/i3blocks/blocks/load_average create mode 100755 .config/i3blocks/blocks/mediaplayer create mode 100755 .config/i3blocks/blocks/memory create mode 100755 .config/i3blocks/blocks/openvpn create mode 100755 .config/i3blocks/blocks/temperature create mode 100755 .config/i3blocks/blocks/toggleoutput.sh create mode 100755 .config/i3blocks/blocks/volume create mode 100755 .config/i3blocks/blocks/wifi create mode 100644 .config/i3blocks/config diff --git a/.config/i3/alt-tab.sh b/.config/i3/alt-tab.sh new file mode 100755 index 0000000..5f17ed6 --- /dev/null +++ b/.config/i3/alt-tab.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# ================================================================================== # +# Focus the next window on the current workspace in i3, e.g. for binding to Alt+Tab # +# Depends: jq, awk, i3wm (obviously) # +# Author: Nervengift # +# License: Don't think this deserves a license, Public Domain # +# Known bugs: doesn't work with non-window container focused # +# ================================================================================== # + +ws=$(i3-msg -t get_workspaces|jq "map(select(.focused))[]|.name") +echo $ws +windows=$(i3-msg -t get_tree|jq ".nodes|map(.nodes[])|map(.nodes[])|map(select(.type==\"workspace\" and .name==$ws))[0].nodes|map(recurse(.nodes[]))|map(.window)|.[]|values") +echo $windows +current=$(i3-msg -t get_tree|jq "recurse(.nodes[])|select(.focused)|.window") +echo $current +if [ "x$current" != "xnull" ]; then + next=$(echo $windows | awk "BEGIN {RS=\" \";FS=\" \"};NR == 1 {w=\$1};{if (f == 1){w=\$1;f=0}else if (\$1 == \"$current\") f=1};END {print w}") + i3-msg [id=$next] focus > /dev/null +fi diff --git a/.config/i3/config b/.config/i3/config new file mode 100644 index 0000000..d93635b --- /dev/null +++ b/.config/i3/config @@ -0,0 +1,154 @@ +# i3 config file (v4) +# +# Please see http://i3wm.org/docs/userguide.html for a complete reference! + +set $mod Mod4 +floating_modifier $mod + +font pango:Noto Sans 11 + +# kill focused window +bindsym $mod+apostrophe kill +bindsym Mod1+F4 kill + +# move focused window +bindsym $mod+Left move left +bindsym $mod+Down move down +bindsym $mod+Up move up +bindsym $mod+Right move right + +# split in horizontal orientation +bindsym $mod+h split h +bindsym $mod+t split v + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+o layout stacking +bindsym $mod+comma layout tabbed +bindsym $mod+period layout toggle split + +# toggle tiling / floating +bindsym $mod+u floating toggle + +# focus the parent container +bindsym $mod+a focus parent +bindsym $mod+d focus child + +# Screen configs # +set $left "DP-1.1" +set $centre "DP-1.2.1" +set $right "DP-1.2.2" +set $top "HDMI-0" + +# Workspace -> Screen +workspace 1 output $left +workspace 2 output $centre +workspace 3 output $right +workspace 4 output $top + +# switch to workspace +bindsym $mod+1 workspace 1 +bindsym $mod+2 workspace 2 +bindsym $mod+3 workspace 3 +bindsym $mod+4 workspace 4 +bindsym $mod+5 workspace 5 +bindsym $mod+6 workspace 6 +bindsym $mod+7 workspace 7 +bindsym $mod+8 workspace 8 +bindsym $mod+9 workspace 9 +bindsym $mod+0 workspace 10 + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace 1 +bindsym $mod+Shift+2 move container to workspace 2 +bindsym $mod+Shift+3 move container to workspace 3 +bindsym $mod+Shift+4 move container to workspace 4 +bindsym $mod+Shift+5 move container to workspace 5 +bindsym $mod+Shift+6 move container to workspace 6 +bindsym $mod+Shift+7 move container to workspace 7 +bindsym $mod+Shift+8 move container to workspace 8 +bindsym $mod+Shift+9 move container to workspace 9 +bindsym $mod+Shift+0 move container to workspace 10 + +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+Escape exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" + +set $bg-color #2f343f +set $inactive-bg-color #2f343f +set $text-color #f3f4f5 +set $inactive-text-color #676E7D +set $urgent-bg-color #E53935 + +# window colors +# border background text indicator +client.focused $bg-color $bg-color $text-color #00ff00 +client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00 +client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00 +client.urgent $urgent-bg-color $urgent-bg-color $text-color #00ff00 + +bar { + status_command i3blocks -c ~/.config/i3blocks/config + + workspace_buttons yes + strip_workspace_numbers yes + tray_output primary + tray_padding 0 + height 24 + + output $centre + position top + + colors { + separator #757575 + background #2f343f + # border background text + focused_workspace $bg-color $bg-color $text-color + inactive_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color + urgent_workspace $urgent-bg-color $urgent-bg-color $text-color + } +} + +# remove window border, add spacing +for_window [class="^.*"] border pixel 0 +gaps inner 10 +gaps outer 2 +#smart_gaps on + +# Do not follow the mouse +focus_follows_mouse no + +# keybindings +bindsym $mod+Shift+j reload +bindsym $mod+Shift+p restart +bindsym Mod1+Tab exec ~/.config/i3/alt-tab.sh +bindsym $mod+Return exec i3-sensible-terminal +bindsym $mod+l exec ~/.config/i3/lock.sh +bindsym $mod+space exec rofi -show run -fg "#D3DAE3" -bg "#383C4A" -hlbg "#5294E2" +bindsym Print exec sh imgur-screenshot -s +bindsym $mod+Print exec sh imgur-screenshot +bindsym $mod+Shift+Return exec --no-startup-id ~/.config/i3/cycleaudio.py && pkill -RTMIN+10 i3blocks + +# Media player controls +bindsym XF86AudioPlay exec --no-startup-id mpc toggle +bindsym XF86AudioPause exec --no-startup-id mpc pause +bindsym XF86AudioStop exec --no-startup-id mpc stop +bindsym XF86AudioNext exec --no-startup-id mpc next +bindsym XF86AudioPrev exec --no-startup-id mpc previous +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && pkill -RTMIN+10 i3blocks +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && pkill -RTMIN+10 i3blocks +bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && pkill -RTMIN+10 i3blocks + +# app launch shortcuts +exec_alawys --no-startup-id ~/.fehbg +exec_always --no-startup-id ~/.config/i3/disable-standby-fs.py +exec xautolock -time 10 -locker /usr/bin/lock.sh +bindsym $mod+c exec --no-startup-id google-chrome-stable + +exec dex -a +exec redshift +exec compton -b --config ~/.config/compton.conf + +exec i3-msg 'workspace 2; exec i3-sensible-terminal' +exec --no-startup-id i3-msg 'workspace 3; exec google-chrome-stable' diff --git a/.config/i3/cycleaudio.py b/.config/i3/cycleaudio.py new file mode 100755 index 0000000..a29238a --- /dev/null +++ b/.config/i3/cycleaudio.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import subprocess as sp +import re + +# This script cycles pulseaudio sinks and changes the defaults. +# Audio playback is also moved to the new default sink. The script +# is intended to bind to some keyboard shortcut to cycle through +# outputs on the fly. +# +# Requirements: pacmd, python3 + +dev_out, _ = sp.Popen('pacmd list-sinks', shell=True, stdout=sp.PIPE).communicate() +inp_out, _ = sp.Popen('pacmd list-sink-inputs', shell=True, stdout=sp.PIPE).communicate() + +devices = re.findall(r"(\*?) index: (\d+)", str(dev_out)) +inputs = re.findall(r"index: (\d+)", str(inp_out)) + +# find the next default device, i.e., the one after the current default +found = False +next_device = devices[0][1] +for d in devices: + if found: + next_device = d[1] + break + found = (d[0] == "*") + +# set default device and move inputs +sp.call(["pacmd", "set-default-sink", next_device]) +for i in inputs: + sp.call(["pacmd", "move-sink-input", i, next_device]) diff --git a/.config/i3/disable-standby-fs.py b/.config/i3/disable-standby-fs.py new file mode 100644 index 0000000..b8ca13f --- /dev/null +++ b/.config/i3/disable-standby-fs.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +from argparse import ArgumentParser +from subprocess import call +import i3ipc + +i3 = i3ipc.Connection() + +parser = ArgumentParser(prog='disable-standby-fs', + description=''' + Disable standby (dpms) and screensaver when a window becomes fullscreen + or exits fullscreen-mode. Requires `xorg-xset`. + ''') + +args = parser.parse_args() + +def on_fullscreen_mode(i3, e): + if e.container.props.fullscreen_mode: + call(['xset', 's', 'off']) + call(['xset', '-dpms']) + else: + call(['xset', 's', 'on']) + call(['xset', '+dpms']) + +def on_window_close(i3, e): + if e.container.props.fullscreen_mode: + call(['xset', 's', 'on']) + call(['xset', '+dpms']) + +i3.on('window::fullscreen_mode', on_fullscreen_mode) +i3.on('window::close', on_window_close) + +i3.main() diff --git a/.config/i3/i3 b/.config/i3/i3 new file mode 120000 index 0000000..41a6cd9 --- /dev/null +++ b/.config/i3/i3 @@ -0,0 +1 @@ +i3 \ No newline at end of file diff --git a/.config/i3/lock.png b/.config/i3/lock.png new file mode 100644 index 0000000000000000000000000000000000000000..67a15f6b07a1b307616c84a6cc631d3ec4a48139 GIT binary patch literal 7966 zcmaKRcT`i&);?(Hy@alW-b?7Ahu)ij6hT4=MGS<{K|n()mAlmHwCkgrj^e6Z6yUpchZslWT zXdn;wM2f=x*oX!oQ8#EjJVliN6b$Z;@Buj@T--dAIQQDSI6-bsN}Ttl4aE&n>Ihdi zogg&gUXYPFJjfjmapF`_1}O%}-#9=bd|;pe8Nd3u2Uc!W86`uZqw-Z1@F2uRd_+5GQnOq?^SzSa#}jSt z>G}AdESk7_`gnS~dZIw;>L7kY7~IX{PhH?|fT5whu7|e|%ma?l)llNRaUtsF<|Hoz z(UMe?)6i5`myrX5H6`WLp>lFkvYN7TvND=bY4AT-4Ntf)65-+V57y~_v0DEp_Ky~j zsGE^B5NJ0)gp(H96AAh|W_h>&!bM9)LRJPWt9Ij0=D&0K7uM;&aQQb@{r|*@-H;Lc zGqeBCO#jn#BcDI7|IzJDL65q-1QqJiN;Ko=4Q~;E1IuOA8v>2471D<-sxE&{f z{7viX;X(N1RkaQ{CAJuJ8>_v;9%O-h$s_pPZdzH$Z!cZCDFx6Y)8w$20U-x<%C#V;@F-Q(w+Q+uE8n=wONOWrM z$?_MF-^l@F);u`jCK^gEq78tc--eutWOkL6y+1do6A}Kzo5Ib3-!^^wdy=rGU?XRQ zQW#lMbkTH43Qo?aiuh9FEyrmf@T%i*{PqqA2-^M_gm?b1GBXr zt$bu4HhlYP`(AopaV;O;HC7w)smjveFj&t{9k?7t#U!F!`@Y3mNRsrBNr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u2rZ!MDTG=jsoalDZE2Uc7u zp2OeQ-rN~#jB^IJ>Bx{dApGWgJZ*H#k~MC^Zm0+Qr*G=kkZRGOB=w1$l1o1 zJS|#k8Ru3c9*4)#SxWaZYivOysHI2e2whv3Onx>>yBl;Q39-cr$x~zO)-8W$2X9Hc znJi;!>$Gd52zsoWKofRC4`C;cL?8hjUbBQoLe&V%-!3kPa}wRdWC3kkj&+?%tavx) zWDh&7UxOh`-y +# Copyright (C) 2014 kaueraal +# Copyright (C) 2015 Thiago Perrotta + +# 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 . + +# Use the provided interface, otherwise the device used for the default route. +if [[ -n $BLOCK_INSTANCE ]]; then + INTERFACE=$BLOCK_INSTANCE +else + INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +# Issue #36 compliant. +if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || ! [ "`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="/dev/shm/$(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 " " +rx_kib=$(( $rx_rate >> 10 )) +if [[ "$rx_rate" -gt 1048576 ]]; then + printf '%sk' "`echo "scale=1; $rx_kib / 1024" | bc`" +else + echo -n "${rx_kib}k" +fi + +echo -n " " + +# outgoing +echo -n " " +tx_kib=$(( $tx_rate >> 10 )) +if [[ "$tx_rate" -gt 1048576 ]]; then + printf '%sm' "`echo "scale=1; $tx_kib / 1024" | bc`" +else + echo -n "${tx_kib}k" +fi diff --git a/.config/i3blocks/blocks/battery b/.config/i3blocks/blocks/battery new file mode 100755 index 0000000..b608375 --- /dev/null +++ b/.config/i3blocks/blocks/battery @@ -0,0 +1,97 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# +# Licensed under the terms of the GNU GPL v3, or any later version. +# +# This script is meant to use with i3blocks. It parses the output of the "acpi" +# command (often provided by a package of the same name) to read the status of +# the battery, and eventually its remaining time (to full charge or discharge). +# +# The color will gradually change for a percentage below 85%, and the urgency +# (exit code 33) is set if there is less that 5% remaining. + +use strict; +use warnings; +use Switch; + +my $acpi; +my $status; +my $percent; +my $hours = -1; +my $mins; +my $full_text; +my $short_text; +my $bat_number = $ENV{BLOCK_INSTANCE} || 0; + +# read the first line of the "acpi" command output +open (ACPI, "acpi -b | grep 'Battery $bat_number' |") or die; +$acpi = ; +close(ACPI); + +# fail on unexpected output +if ($acpi !~ /: (\w+), (\d+)%/) { + die "$acpi\n"; +} +$status = $1; +$percent = $2; + +if ($acpi =~ /, (\d+):(\d+)/) { + $hours = $1; + $mins = $2; +} + +if ($status eq 'Discharging') { + if ($percent <= 10) { + $full_text = ""; + } elsif ($percent <= 40) { + $full_text = ""; + } elsif ($percent <= 75) { + $full_text = ""; + } else { + $full_text = ""; + } + +} elsif ($status eq 'Charging') { + $full_text = ''; +} else { + $full_text = ''; +} + +$full_text .= " $percent%"; +$short_text = $full_text; + +switch($ENV{BLOCK_BUTTON} || 0) { + case "1" { + if ($hours lt 0) { + $full_text .= " Charged"; + } else { + $full_text .= " ($hours:$mins"; + if ($status eq 'Discharging') { + $full_text .= ")"; + } else { + $full_text .= " until full)"; + } + } + } + case "4" { system("light -U -l 1") } + case "5" { system("light -A -l 1") } +} + + +# print text +print "$full_text\n"; +print "$short_text\n"; + +# consider color and urgent flag only on discharge +if ($status eq 'Discharging') { + + if ($percent < 20) { + print "#FF0000\n"; + } elsif ($percent < 40) { + print "#FFCB00\n"; + } +} + +exit(0); diff --git a/.config/i3blocks/blocks/clock b/.config/i3blocks/blocks/clock new file mode 100755 index 0000000..e9b3192 --- /dev/null +++ b/.config/i3blocks/blocks/clock @@ -0,0 +1,5 @@ +case $BLOCK_BUTTON in + 1) printf " "$(date '+%d/%m/%y') ; exit ;; +esac + +printf " "$(date '+%H:%M') diff --git a/.config/i3blocks/blocks/cpu_usage b/.config/i3blocks/blocks/cpu_usage new file mode 100755 index 0000000..c0d659a --- /dev/null +++ b/.config/i3blocks/blocks/cpu_usage @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# +# Licensed under the terms of the GNU GPL v3, or any later version. + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +# default values +my $t_warn = 50; +my $t_crit = 80; +my $cpu_usage = -1; + +sub help { + print "Usage: cpu_usage [-w ] [-c ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit); + +# Get CPU usage +$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is +open (MPSTAT, 'mpstat 1 1 |') or die 'Cannot run mpstat'; +while () { + if (/^.*\s+(\d+\.\d+)\s+$/) { + $cpu_usage = 100 - $1; # 100% - %idle + last; + } +} +close(MPSTAT); + +#$cpu_usage eq -1 and die 'Can\'t find CPU information'; + +# Print short_text, full_text +printf "%.0f%%\n"x2, $cpu_usage; + +# Print color, if needed +if ($cpu_usage >= $t_crit) { + print "#FF0000\n"; +} elsif ($cpu_usage >= $t_warn) { + print "#FFCB00\n"; +} + +exit 0; diff --git a/.config/i3blocks/blocks/disk b/.config/i3blocks/blocks/disk new file mode 100755 index 0000000..5511eac --- /dev/null +++ b/.config/i3blocks/blocks/disk @@ -0,0 +1,41 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# 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 . + +DIR="${BLOCK_INSTANCE:-$HOME}" +ALERT_LOW="${1:-10}" # color will turn red under this value (default: 10%) + +df -h -P -l "$DIR" | awk -v alert_low=$ALERT_LOW ' +/\/.*/ { + # full text + print $4 + + # short text + print $4 + + use=$5 + + # no need to continue parsing + exit 0 +} + +END { + gsub(/%$/,"",use) + if (100 - use < alert_low) { + # color + print "#FF0000" + } +} +' diff --git a/.config/i3blocks/blocks/iface b/.config/i3blocks/blocks/iface new file mode 100755 index 0000000..959983a --- /dev/null +++ b/.config/i3blocks/blocks/iface @@ -0,0 +1,62 @@ +#!/bin/bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# 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 . + +#------------------------------------------------------------------------ + +# Use the provided interface, otherwise the device used for the default route. +if [[ -n $BLOCK_INSTANCE ]]; then + IF=$BLOCK_INSTANCE +else + IF=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +#------------------------------------------------------------------------ + +# 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 + +#------------------------------------------------------------------------ + +if [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then + echo down # full text + echo down # short text + echo \#FF0000 # color + exit +fi + +case $1 in + -4) + AF=inet ;; + -6) + AF=inet6 ;; + *) + AF=inet6? ;; +esac + +# if no interface is found, use the first device with a global scope +LOCIP=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit") +EXTIP=$(curl -s http://whatismijnip.nl |cut -d " " -f 5) + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 1) echo "$EXTIP";; +# 2) echo -n "$LOCIP" | xclip -q -se c ;; +# 3) echo -n "$EXTIP" | xclip -q -se c ;; + *) echo "$LOCIP";; +esac diff --git a/.config/i3blocks/blocks/keyindicator b/.config/i3blocks/blocks/keyindicator new file mode 100755 index 0000000..9c21505 --- /dev/null +++ b/.config/i3blocks/blocks/keyindicator @@ -0,0 +1,70 @@ +#!/usr/bin/perl +# +# Copyright 2014 Marcelo Cerri +# +# 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 . + +use strict; +use warnings; +use utf8; +use Getopt::Long; +use File::Basename; + +# Default values +my $indicator = $ENV{BLOCK_INSTANCE} || "CAPS"; +my $color_on = "#00FF00"; +my $color_off = "#222222"; + +sub help { + my $program = basename($0); + printf "Usage: %s [-c ] [-C ]\n", $program; + printf " -c : hex color to use when indicator is on\n"; + printf " -C : hex color to use when indicator is off\n"; + printf "\n"; + printf "Note: environment variable \$BLOCK_INSTANCE should be one of:\n"; + printf " CAPS, NUM (default is CAPS).\n"; + exit 0; +} + +Getopt::Long::config qw(no_ignore_case); +GetOptions("help|h" => \&help, + "c=s" => \$color_on, + "C=s" => \$color_off) or exit 1; + +# Key mapping +my %indicators = ( + CAPS => 0x00000001, + NUM => 0x00000002, +); + +# Retrieve key flags +my $mask = 0; +open(XSET, "xset -q |") or die; +while () { + if (/LED mask:\s*([0-9]+)/) { + $mask = $1; + last; + } +} +close(XSET); + +# Output +printf "%s\n", $indicator; +printf "%s\n", $indicator; +if (($indicators{$indicator} || 0) & $mask) { + printf "%s\n", $color_on; +} else { + printf "%s\n", $color_off; +} +exit 0 diff --git a/.config/i3blocks/blocks/load_average b/.config/i3blocks/blocks/load_average new file mode 100755 index 0000000..37a5c71 --- /dev/null +++ b/.config/i3blocks/blocks/load_average @@ -0,0 +1,34 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# 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 . + +load="$(cut -d ' ' -f1 /proc/loadavg)" +cpus="$(nproc)" + +# full text +echo "$load" + +# short text +echo "$load" + +# color if load is too high +awk -v cpus=$cpus -v cpuload=$load ' + BEGIN { + if (cpus <= cpuload) { + print "#FF0000"; + exit 33; + } + } +' diff --git a/.config/i3blocks/blocks/mediaplayer b/.config/i3blocks/blocks/mediaplayer new file mode 100755 index 0000000..b3d3ecb --- /dev/null +++ b/.config/i3blocks/blocks/mediaplayer @@ -0,0 +1,76 @@ +#!/usr/bin/perl +# Copyright (C) 2014 Tony Crisci + +# 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 . + +# Requires playerctl binary to be in your path (except cmus) +# See: https://github.com/acrisci/playerctl + +# Set instance=NAME in the i3blocks configuration to specify a music player +# (playerctl will attempt to connect to org.mpris.MediaPlayer2.[NAME] on your +# DBus session). + +use Env qw(BLOCK_INSTANCE); + +my @metadata = (); +my $player_arg = ""; + +if ($BLOCK_INSTANCE) { + $player_arg = "--player='$BLOCK_INSTANCE'"; +} + +if ($ENV{'BLOCK_BUTTON'} == 1) { + system("playerctl $player_arg previous"); +} elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("playerctl $player_arg play-pause"); +} elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("playerctl $player_arg next"); +} + +if ($player_arg eq '' or $player_arg =~ /cmus$/) { + # try cmus first + my @cmus = split /^/, qx(cmus-remote -Q); + if ($? == 0) { + foreach my $line (@cmus) { + my @data = split /\s/, $line; + if (shift @data eq 'tag') { + my $key = shift @data; + my $value = join ' ', @data; + + @metadata[0] = $value if $key eq 'artist'; + @metadata[1] = $value if $key eq 'title'; + } + } + + if (@metadata) { + # metadata found so we are done + print(join ' - ', @metadata); + exit 0; + } + } + + # if cmus was given, we are done + exit 0 unless $player_arg eq ''; +} + +my $artist = qx(playerctl $player_arg metadata artist); +# exit status will be nonzero when playerctl cannot find your player +exit(0) if $?; +push(@metadata, $artist) if $artist; + +my $title = qx(playerctl $player_arg metadata title); +exit(0) if $?; +push(@metadata, $title) if $title; + +print(join(" - ", @metadata)) if @metadata; diff --git a/.config/i3blocks/blocks/memory b/.config/i3blocks/blocks/memory new file mode 100755 index 0000000..a8c7ad0 --- /dev/null +++ b/.config/i3blocks/blocks/memory @@ -0,0 +1,61 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# 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 . + +TYPE="${BLOCK_INSTANCE:-mem}" + +awk -v type=$TYPE ' +BEGIN { + swap_total=1 + mem_total=1 +} +/^MemTotal:/ { + mem_total=$2 +} +/^MemFree:/ { + mem_free=$2 +} +/^Buffers:/ { + mem_free+=$2 +} +/^Cached:/ { + mem_free+=$2 +} +/^SwapTotal:/ { + swap_total=$2 +} +/^SwapFree:/ { + swap_free=$2 +} +END { + if (type == "swap") { + swap_perc = (swap_total - swap_free) / swap_total * 100 + printf("%.0f%\n", swap_perc) + printf("%.0f%\n", swap_perc) + perc = swap_perc + } + else{ + mem_perc = (mem_total - mem_free) / mem_total * 100 + printf("%.0f%\n", mem_perc) + printf("%.0f%\n", mem_perc) + perc = mem_perc + } + + if (perc > 80) + print "#FFCB00" + else if (perc > 60) + print "#FFCB00" +} +' /proc/meminfo diff --git a/.config/i3blocks/blocks/openvpn b/.config/i3blocks/blocks/openvpn new file mode 100755 index 0000000..02aaba4 --- /dev/null +++ b/.config/i3blocks/blocks/openvpn @@ -0,0 +1,149 @@ +#!/usr/bin/perl +# Made by Pierre Mavro/Deimosfr +# Licensed under the terms of the GNU GPL v3, or any later version. +# Version: 0.2 + +# Usage: +# 1. The configuration name of OpenVPN should be familiar for you (home,work...) +# 2. The device name in your configuration file should be fully named (tun0,tap1...not only tun or tap) +# 3. When you launch one or multiple OpenVPN connexion, be sure the PID file is written in the correct folder (ex: --writepid /run/openvpn/home.pid) + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +my $openvpn_enabled='/dev/shm/openvpn_i3blocks_enabled'; +my $openvpn_disabled='/dev/shm/openvpn_i3blocks_disabled'; + +# Print output +sub print_output { + my $ref_pid_files = shift; + my @pid_files = @$ref_pid_files; + my $change=0; + + # Total pid files + my $total_pid = @pid_files; + if ($total_pid == 0) { + print "VPN: down\n"x2; + # Delete OpenVPN i3blocks temp files + if (-f $openvpn_enabled) { + unlink $openvpn_enabled or die "Can't delete $openvpn_enabled\n"; + # Colorize if VPN has just went down + print '#FF0000\n'; + } + unless (-f $openvpn_disabled) { + open(my $shm, '>', $openvpn_disabled) or die "Can't write $openvpn_disabled\n"; + } + exit(0); + } + + # Check if interface device is present + my $vpn_found=0; + my $pid; + my $cmd_line; + my @config_name; + my @config_path; + my $interface; + my $current_config_path; + my $current_config_name; + foreach (@pid_files) { + # Get current PID + $pid=0; + open(PID, '<', $_); + while() { + chomp $_; + $pid = $_; + } + close(PID); + # Check if PID has been found + if ($pid ==0) { + print "Can't get PID $_: $!\n"; + } + + # Check if PID is still alive + $cmd_line='/proc/'.$pid.'/cmdline'; + if (-f $cmd_line) { + # Get config name + open(CMD_LINE, '<', $cmd_line); + while() { + chomp $_; + if ($_ =~ /--config\s*(.*\.conf)/) { + # Get interface from config file + $current_config_path = $1; + # Remove unwanted escape chars + $current_config_path =~ s/\x{00}//g; + $interface = 'null'; + # Get configuration name + if ($current_config_path =~ /(\w+).conf/) { + $current_config_name=$1; + } else { + $current_config_name='unknow'; + } + # Get OpenVPN interface device name + open(CONFIG, '<', $current_config_path) or die "Can't read config file '$current_config_path': $!\n"; + while() { + chomp $_; + if ($_ =~ /dev\s+(\w+)/) { + $interface=$1; + last; + } + } + close(CONFIG); + # check if interface exist + unless ($interface eq 'null') { + if (-d "/sys/class/net/$interface") { + push @config_name, $current_config_name; + $vpn_found=1; + # Write enabled file + unless (-f $openvpn_enabled) { + open(my $shm, '>', $openvpn_enabled) or die "Can't write $openvpn_enabled\n"; + $change=1; + } + } + } + } + } + close(CMD_LINE); + } + } + + # Check if PID found + my $names; + my $short_status; + if ($vpn_found == 1) { + $names = join('/', @config_name); + $short_status='up'; + } else { + $short_status='down'; + $names = $short_status; + } + + print "VPN: $names\n"; + print "VPN: $short_status\n"; + + # Print color if there were changes + print "#00FF00\n" if ($change == 1); + + exit(0); +} + +sub check_opts { + # Vars + my @pid_file=glob '/run/openvpn/*.pid'; + + # Set options + GetOptions( "help|h" => \&help, + "p=s" => \@pid_file); + + print_output(\@pid_file); +} + +sub help { + print "Usage: openvpn [-d pid folder files]\n"; + print "-d : pid folder files (default /run/openvpn/*.pid)\n"; + print "Note: devices in configuration file should be named with their number (ex: tun0, tap1)\n"; + exit(1); +} + +&check_opts; diff --git a/.config/i3blocks/blocks/temperature b/.config/i3blocks/blocks/temperature new file mode 100755 index 0000000..ab8d815 --- /dev/null +++ b/.config/i3blocks/blocks/temperature @@ -0,0 +1,69 @@ +#!/usr/bin/perl +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# Copyright 2014 Benjamin Chretien + +# 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 . + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +binmode(STDOUT, ":utf8"); + +# default values +my $t_warn = 70; +my $t_crit = 90; +my $chip = "coretemp-isa-0000"; +my $temperature = -9999; + +sub help { + print "Usage: temperature [-w ] [-c ] [--chip ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "--chip : sensor chip\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "chip=s" => \$chip); + +# Get chip temperature +open (SENSORS, "sensors -u $chip |") or die; +while () { + if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) { + $temperature = $1; + last; + } +} +close(SENSORS); + +$temperature eq -9999 and die 'Cannot find temperature'; + +# Print short_text, full_text +print int($temperature)."°c\n" x2; + +# Print color, if needed +if ($temperature >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($temperature >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/.config/i3blocks/blocks/toggleoutput.sh b/.config/i3blocks/blocks/toggleoutput.sh new file mode 100755 index 0000000..a1cd706 --- /dev/null +++ b/.config/i3blocks/blocks/toggleoutput.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +CARDS=$(pacmd list-cards | grep -e index: -e alsa.card_name | xargs -n5 | awk '{print $2}') + +if [[ ${#CARDS} != 3 ]]; # there is a space +then + echo "This script works only with 2 outputs, and you have ..." + pacmd list-cards | grep -e index: -e alsa.card_name | xargs -n5 + exit +fi + +i=1 +for card_index in $CARDS ; +do + eval CARD$i=$card_index + let i+=1 + +done + +LAST_SINK_LINE=$(pacmd list-sink-inputs | grep -e index: -e sink: | xargs -n5 | tail -n1) +last_sink_app_index=$( echo $LAST_SINK_LINE | awk '{print $2}' ) +last_sink_out_index=$( echo $LAST_SINK_LINE | awk '{print $4}' ) +[[ ${last_sink_out_index} == ${CARD1} ]] && new_sink_out=$CARD2 || new_sink_out=$CARD1 + +#echo "$last_sink_app_index > $last_sink_out_index > ${new_sink_out}" + +pacmd move-sink-input ${last_sink_app_index} ${new_sink_out} diff --git a/.config/i3blocks/blocks/volume b/.config/i3blocks/blocks/volume new file mode 100755 index 0000000..7c337a3 --- /dev/null +++ b/.config/i3blocks/blocks/volume @@ -0,0 +1,94 @@ +#!/bin/bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# 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 . + +#------------------------------------------------------------------------ + +# The second parameter overrides the mixer selection +# For PulseAudio users, use "pulse" +# For Jack/Jack2 users, use "jackplug" +# For ALSA users, you may use "default" for your primary card +# or you may use hw:# where # is the number of the card desired +MIXER="default" +[ -n "$(lsmod | grep pulse)" ] && MIXER="pulse" +[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" +MIXER="${2:-$MIXER}" + +# The instance option sets the control to report and configure +# This defaults to the first control of your selected mixer +# For a list of the available, use `amixer -D $Your_Mixer scontrols` +SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | + sed -n "s/Simple mixer control '\([A-Za-z ]*\)',0/\1/p" | + head -n1 + )}" + +# The first parameter sets the step to change the volume by (and units to display) +# This may be in in % or dB (eg. 5% or 3dB) +STEP="${1:-2%}" + + +#------------------------------------------------------------------------ + +capability() { # Return "Capture" if the device is a capture device + amixer -D $MIXER get $SCONTROL | + sed -n "s/ Capabilities:.*cvolume.*/Capture/p" +} + +volume() { + amixer -D $MIXER get $SCONTROL $(capability) +} + +format() { + perl_filter='if (/.*\[(\d+)%\] (\[(-?\d+.\d+)dB\] )?\[(on|off)\]/)' + perl_filter+='{CORE::say $4 eq "off" ? "-1" : "' + perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1') + perl_filter+='"; exit}' + perl -ne "$perl_filter" +} + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 1) pavucontrol ;; + 3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease +esac + +#------------------------------------------------------------------------ + +VOL=$(volume | format) + +ACTIVE=$(pacmd list-sinks | grep '* index' | awk -F": " '{print $2}') + +if pactl list short sinks | grep -q \^$ACTIVE".*Yeti" +then + printf "" +elif [ "$VOL" -eq -1 ] +then + printf "X" + exit 0 +elif [ "$VOL" -eq 0 ] +then + printf "" +elif [ "$VOL" -gt 59 ] +then + printf "" +else + printf "" +fi + +printf " "$VOL diff --git a/.config/i3blocks/blocks/wifi b/.config/i3blocks/blocks/wifi new file mode 100755 index 0000000..ffaccab --- /dev/null +++ b/.config/i3blocks/blocks/wifi @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright (C) 2014 Alexander Keller + +# 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 . + +#------------------------------------------------------------------------ + +INTERFACE="${BLOCK_INSTANCE:-wlan0}" + +#------------------------------------------------------------------------ + +# 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/${INTERFACE}/wireless ]] || + [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && exit + +#------------------------------------------------------------------------ + +QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + +#------------------------------------------------------------------------ + +echo $QUALITY% # full text +echo $QUALITY% # short text + +# color +if [[ $QUALITY -ge 80 ]]; then + echo "#00FF00" +elif [[ $QUALITY -lt 80 ]]; then + echo "#FFF600" +elif [[ $QUALITY -lt 60 ]]; then + echo "#FFAE00" +elif [[ $QUALITY -lt 40 ]]; then + echo "#FF0000" +fi diff --git a/.config/i3blocks/config b/.config/i3blocks/config new file mode 100644 index 0000000..dfdfe69 --- /dev/null +++ b/.config/i3blocks/config @@ -0,0 +1,93 @@ +# i3blocks config file +# +# Please see man i3blocks for a complete reference! +# The man page is also hosted at http://vivien.github.io/i3blocks +# +# List of valid properties: +# +# align +# color +# command +# full_text +# instance +# interval +# label +# min_width +# name +# separator +# separator_block_width +# short_text +# signal +# urgent + +# Global properties +# +# The top properties below are applied to every block, but can be overridden. +# Each block command defaults to the script name to avoid boilerplate. +command=~/.config/i3blocks/blocks/$BLOCK_NAME +markup=none + +#full_text= +align=center +color=#FFFFFF +separator=false +separator_block_width=10 + +[window title] +command=xtitle -s #| sed 's/^$/ /g'" +color=#A6D1FA +align=center +min_width=700 +interval=persist + +[separator] + +# Command gets the text. This +# needs to do command on click +#[playpause] +#label=$ +#command=mpc toggle +#interval=once + +[volume] +instance=Master +interval=10 +signal=10 + +[separator] + +[iface] +label= +#instance=wlan0 +#color=#00FF00 +interval=30 + +[separator] + +[cpu_usage] +label= +interval=5 + +[separator] + +[memory] +label= +interval=30 + +[separator] + +[temperature] +label= +interval=5 + +[separator] + +#[battery] +#label= +#interval=5 + +#[separator] + +[clock] +interval=5 +