Browse Source

Copied i3blocks scripts from orig dir

Some were modified from original but can't be bothered to check which.
'backlight' is custom. Changed both PC/laptop i3blocks config to
reference new i3blocks-scripts location.

system: Fixed keyboard repeat rate for PC/laptop.
Git: Added amending commit and forcing push aliases.
i3: Changed '$mod+F[1-3]' mappings to just 'F[1-3]'.
red-hat-laptop
Kevin Mok 7 years ago
parent
commit
c87546e75c
  1. 1
      .gitignore
  2. 7
      aliases/zsh_aliases
  3. 3
      configs/NZXT/i3blocks/i3blocks.conf
  4. 13
      configs/X1-Carbon/i3/config
  5. 44
      configs/X1-Carbon/i3blocks/i3blocks.conf
  6. 9
      configs/i3blocks-scripts/backlight
  7. 76
      configs/i3blocks-scripts/battery
  8. 55
      configs/i3blocks-scripts/cpu_usage
  9. 34
      configs/i3blocks-scripts/load_average
  10. 49
      configs/i3blocks-scripts/memory
  11. 1
      configs/i3blocks-scripts/name
  12. 15
      configs/i3blocks-scripts/spotify.py
  13. 69
      configs/i3blocks-scripts/temperature
  14. 70
      configs/i3blocks-scripts/volume
  15. 46
      configs/i3blocks-scripts/wifi
  16. 2
      dotfiles/Xresources
  17. 8
      dotfiles/vimrc
  18. 7
      dotfiles/zshrc

1
.gitignore

@ -5,3 +5,4 @@ temp.sh
konsole.shortcuts
commit-msg.txt
core
ideas.md

7
aliases/zsh_aliases

@ -71,7 +71,7 @@ alias vr="ni ~/.config/ranger/rc.conf"
# i3 {{{ #
alias v3="ni ~/.config/i3/config"
alias v3b="ni ~/.config/i3blocks/i3blocks.conf"
alias i3b="f /usr/share/i3blocks"
alias i3b="f ~/i3blocks"
alias pipes="pipes.sh -t 2"
alias bgs="nemo ~/Pictures/Backgrounds"
@ -91,6 +91,7 @@ alias rg="ranger"
function ok() { okular $1 ; }
function chr() { google-chrome $1 ; }
function ni() { nvim $1 ; }
alias nisw="f ~/.local/share/nvim/swap"
# function mrk() { pandoc -o ${1%.*}.html $1 && chr ${1%.*}.html ; }
function mrk() { pandoc -o ${1%.*}.html $1 ; }
@ -202,7 +203,7 @@ if [[ "$(hostname)" = "X1-Carbon" ]]; then
# }}} key swaps #
alias gbl="xbacklight -get"
function sbl() { xbacklight -set $(echo "scale=2;$1*10" | bc) ; }
function bl() { xbacklight -set $(echo "scale=2;$1*10" | bc) ; }
alias thn="thunar ."
@ -242,10 +243,12 @@ alias gst="git stash"
alias gstp="git stash pop"
alias gc="git commit"
alias gcam="git commit --amend"
# todo: fix
function gcm(){ echo git commit -m \""$1"\" ; }
alias gps="git push"
alias gpsfrc="git push --force"
alias gdwip="git push -d origin wip && git branch -d wip"
alias gclear="git stash clear"
# }}} push #

3
configs/NZXT/i3blocks/i3blocks.conf

@ -26,7 +26,8 @@
# The top properties below are applied to every block, but can be overridden.
# Each block command defaults to the script name to avoid boilerplate.
align=center
command=/usr/share/i3blocks/$BLOCK_NAME
# command=/usr/share/i3blocks/$BLOCK_NAME
command=~/linux-config/configs/i3blocks-scripts/$BLOCK_NAME
separator=true
separator_block_width=25
markup=pango

13
configs/X1-Carbon/i3/config

@ -1,14 +1,16 @@
# applications {{{ #
# startup {{{ #
exec redshift -O 4000
# exec_always /home/kevin/.local/bin/wal -i "/home/kevin/Pictures/Backgrounds/"
exec_always /home/kevin/.local/bin/wal -i "/home/kevin/Pictures/Backgrounds/japan-street.jpg"
exec_always /home/kevin/.local/bin/wal -i "/home/kevin/Pictures/Backgrounds/"
# exec_always /home/kevin/.local/bin/wal -i "/home/kevin/Pictures/Backgrounds/japan-street.jpg"
exec imwheel
# enable horizontal scrolling
exec --no-startup-id synclient HorizTwoFingerScroll=1
# disable touchscreen
exec xinput disable 12
exec $def_term
reload
# }}} startup #
set $def_term "rxvt-unicode"
@ -100,18 +102,19 @@ bindsym $mod+a focus parent
# workspace {{{ #
# ws names {{{ #
set $ws1 "1 "
bindsym $mod+F1 workspace $ws1; exec $def_term
bindsym F1 workspace $ws1; exec $def_term
set $ws2 "2 "
bindsym $mod+F2 workspace $ws2; exec $def_term
bindsym F2 workspace $ws2; exec $def_term
set $ws3 "3 🌐"
bindsym $mod+F3 workspace $ws3; exec $run_chrome
bindsym F3 workspace $ws3; exec $run_chrome
set $ws4 "4 🖹"
set $ws5 "5 "
set $ws6 "6 🗪"
bindsym Mod4+d workspace $ws6; exec discord
bindsym Mod4+l workspace $ws6; exec slack
set $ws7 "7 ↥"
set $ws8 "8 𝅘𝅥𝅮"

44
configs/X1-Carbon/i3blocks/i3blocks.conf

@ -1,4 +1,4 @@
#j properties {{{ #
# properties {{{ #
# i3blocks config file
#
# Please see man i3blocks for a complete reference!
@ -26,41 +26,65 @@
# The top properties below are applied to every block, but can be overridden.
# Each block command defaults to the script name to avoid boilerplate.
align=center
command=/usr/share/i3blocks/$BLOCK_NAME
command=~/linux-config/configs/i3blocks-scripts/$BLOCK_NAME
separator=true
separator_block_width=25
markup=pango
# }}} Global properties #
[time]
command=date '+%H:%M.%a-%m-%d'
interval=60
color=#999999
# blocks {{{ #
# spotify {{{ #
[spotify]
command=python /usr/share/i3blocks/spotify.py
label=
# label=
color=#388E8E
interval=10
# }}} spotify #
[load_average]
label=🗠
interval=5
color=#990000
# backlight {{{ #
[backlight]
command=. /usr/share/i3blocks/backlight
label=🔆
color=#EEAD0E
interval=10
# }}} backlight #
# battery {{{ #
[battery]
label=⚡
interval=60
# }}} battery #
# wifi {{{ #
[wifi]
label=🖧
instance=wlp3s0
interval=10
# }}} wifi #
# time {{{ #
[time]
command=date '+%H:%M.%a-%m-%d'
interval=60
color=#999999
# }}} time #
# load {{{ #
[load_average]
label=🗠
interval=5
color=#990000
# }}} load #
# name {{{ #
[name]
color=#cc5490
interval=6000
# }}} name #
# blocks }}} #
# unused blocks {{{ #
# [memory]

9
configs/i3blocks-scripts/backlight

@ -0,0 +1,9 @@
#!/bin/sh
# https://askubuntu.com/a/179949/794515
round()
{
echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))
};
cur_bl=$(xbacklight -get)
echo "$(round "$cur_bl" 0)%"

76
configs/i3blocks-scripts/battery

@ -0,0 +1,76 @@
#!/usr/bin/perl
#
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
#
# 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 utf8;
my $acpi;
my $status;
my $percent;
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 = <ACPI>;
close(ACPI);
# fail on unexpected output
if ($acpi !~ /: (\w+), (\d+)%/) {
die "$acpi\n";
}
$status = $1;
$percent = $2;
$full_text = "$percent%";
if ($status eq 'Discharging') {
$full_text .= ' DIS';
} elsif ($status eq 'Charging') {
$full_text .= ' CHR';
}
$short_text = $full_text;
if ($acpi =~ /(\d\d:\d\d):/) {
$full_text .= " ($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 "#FFAE00\n";
} elsif ($percent < 60) {
print "#FFF600\n";
} elsif ($percent < 85) {
print "#A8FF00\n";
}
if ($percent < 5) {
exit(33);
}
} else {
print "#2c9332\n";
}
exit(0);

55
configs/i3blocks-scripts/cpu_usage

@ -0,0 +1,55 @@
#!/usr/bin/perl
#
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com>
#
# 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 <warning>] [-c <critical>]\n";
print "-w <percent>: warning threshold to become yellow\n";
print "-c <percent>: 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;
while (<MPSTAT>) {
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 "%.2f%%\n", $cpu_usage;
printf "%.2f%%\n", $cpu_usage;
# Print color, if needed
if ($cpu_usage >= $t_crit) {
print "#FF0000\n";
exit 33;
} elsif ($cpu_usage >= $t_warn) {
print "#FFFC00\n";
}
exit 0;

34
configs/i3blocks-scripts/load_average

@ -0,0 +1,34 @@
#!/bin/sh
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# 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/>.
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;
}
}
'

49
configs/i3blocks-scripts/memory

@ -0,0 +1,49 @@
#!/bin/sh
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# 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/>.
TYPE="${BLOCK_INSTANCE:-mem}"
awk -v type=$TYPE '
/^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 {
# full text
if (type == "swap")
printf("%.1fG\n", (swap_total-swap_free)/1024/1024)
else
printf("%.1fG\n", mem_free/1024/1024)
# TODO: short text
# TODO: color (if less than X%)
}
' /proc/meminfo

1
configs/i3blocks-scripts/name

@ -0,0 +1 @@
echo "Kevin 🚀"

15
configs/i3blocks-scripts/spotify.py

@ -0,0 +1,15 @@
#!/usr/bin/python
import dbus
try:
bus = dbus.SessionBus()
spotify = bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2")
spotify_iface = dbus.Interface(spotify, 'org.freedesktop.DBus.Properties')
props = spotify_iface.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
print(str(props['xesam:artist'][0]) + " - " + str(props['xesam:title']))
exit
except dbus.exceptions.DBusException:
exit

69
configs/i3blocks-scripts/temperature

@ -0,0 +1,69 @@
#!/usr/bin/perl
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com>
# Copyright 2014 Benjamin Chretien <chretien at lirmm dot fr>
# 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/>.
use strict;
use warnings;
use utf8;
use Getopt::Long;
binmode(STDOUT, ":utf8");
# default values
my $t_warn = 70;
my $t_crit = 90;
my $chip = "";
my $temperature = -9999;
sub help {
print "Usage: temperature [-w <warning>] [-c <critical>] [--chip <chip>]\n";
print "-w <percent>: warning threshold to become yellow\n";
print "-c <percent>: critical threshold to become red\n";
print "--chip <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 (<SENSORS>) {
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 "$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;

70
configs/i3blocks-scripts/volume

@ -0,0 +1,70 @@
#!/bin/bash
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
# 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/>.
#------------------------------------------------------------------------
# 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:-5%}"
#------------------------------------------------------------------------
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" ? "MUTE" : "'
# If dB was selected, print that instead
perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1')
perl_filter+='"; exit}'
perl -ne "$perl_filter"
}
#------------------------------------------------------------------------
case $BLOCK_BUTTON in
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
volume | format

46
configs/i3blocks-scripts/wifi

@ -0,0 +1,46 @@
#!/bin/bash
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
# 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/>.
#------------------------------------------------------------------------
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

2
dotfiles/Xresources

@ -4,7 +4,7 @@ URxvt.font: xft:hack:size=12
URxvt*inheritPixmap: true
URxvt*transparent: true
! URxvt*shading: 0 to 99 darkens, 101 to 200 lightens
URxvt*shading: 30
URxvt*shading: 40
/* }}} transparency */
URxvt.scrollBar: false

8
dotfiles/vimrc

@ -117,7 +117,7 @@ colorscheme wal
" Mappings {{{ "
" function keys {{{ "
map <F3> :wa<CR>
" map <F3> :wa<CR>
map <F4> :wqa<CR>
map <F5> :qa!<CR>
map <F6> :make -C ~/Documents/resume cv<CR>
@ -171,8 +171,6 @@ nnoremap <leader>rv :source $MYVIMRC<CR>
nnoremap <leader>R q:i%s///g<ESC>2F/i
" set syntax to shell (for dotfiles)
nnoremap <leader>s :set syn=sh<CR>
" replace bars/underscores in URL
nnoremap <leader>url :.s/\([-_]\)/\\\1/g<CR>
" format current line
nnoremap <leader>w Vgq
" format this and next line
@ -181,6 +179,7 @@ nnoremap <leader>ww Vjgq
nnoremap <leader>z za
" copy next thing to system clipboard
nnoremap <leader>y "+
nnoremap <leader>Y "+Y
" }}} leader mappings "
@ -193,6 +192,7 @@ autocmd Filetype c inoremap <localleader>s struct pixel
" tex {{{ "
autocmd Filetype tex inoremap <localleader>D \Delta
autocmd Filetype tex inoremap <localleader>e \exists
autocmd Filetype tex inoremap <localleader>ep \epsilon
autocmd Filetype tex inoremap <localleader>fa \forall
autocmd Filetype tex inoremap <localleader>g \geq
autocmd Filetype tex inoremap <localleader>i \in
@ -204,6 +204,8 @@ autocmd Filetype tex inoremap <localleader>R \Rightarrow
autocmd Filetype tex inoremap <localleader>st such that
autocmd Filetype tex inoremap <localleader>t \times
autocmd Filetype tex inoremap <localleader>T $T$
" replace bars/underscores in URL
autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
autocmd Filetype tex inoremap <localleader>v \vee
autocmd Filetype tex inoremap <localleader>w \wedge
autocmd Filetype tex inoremap <localleader>x $x$-axis

7
dotfiles/zshrc

@ -95,8 +95,6 @@ source ~/linux-config/aliases/zsh_aliases
# alias ohmyzsh="mate ~/.oh-my-zsh"
if [ "$(whoami)" = "kevin" ]; then
gsettings set org.gnome.desktop.peripherals.keyboard delay 25
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 200
export PATH="${PATH}:${HOME}/.local/bin/"
(cat ~/.cache/wal/sequences &)
fi
@ -106,6 +104,11 @@ then
xmodmap -e "clear Lock"
xmodmap -e "keycode 22 = Caps_Lock"
xmodmap -e "keycode 66 = BackSpace"
# keyboard repeat rate
gsettings set org.gnome.desktop.peripherals.keyboard delay 25
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 200
else
xrandr --dpi 150
xset r rate 200 60
fi
Loading…
Cancel
Save