Added i3blocks, and a bunch of scripts for modules
This commit is contained in:
parent
98463ce91e
commit
f837a32209
106
bin/battery
Executable file
106
bin/battery
Executable file
|
@ -0,0 +1,106 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2016 James Murphy
|
||||
# Licensed under the GPL version 2 only
|
||||
#
|
||||
# A battery indicator blocklet script for i3blocks
|
||||
|
||||
from subprocess import check_output
|
||||
import os
|
||||
import re
|
||||
|
||||
config = dict(os.environ)
|
||||
status = check_output(['acpi'], universal_newlines=True)
|
||||
|
||||
if not status:
|
||||
# stands for no battery found
|
||||
color = config.get("color_10", "red")
|
||||
fulltext = "<span color='{}'><span font='FontAwesome'>\uf00d \uf240</span></span>".format(color)
|
||||
percentleft = 100
|
||||
else:
|
||||
# if there is more than one battery in one laptop, the percentage left is
|
||||
# available for each battery separately, although state and remaining
|
||||
# time for overall block is shown in the status of the first battery
|
||||
batteries = status.split("\n")
|
||||
state_batteries=[]
|
||||
commasplitstatus_batteries=[]
|
||||
percentleft_batteries=[]
|
||||
time = ""
|
||||
for battery in batteries:
|
||||
if battery!='':
|
||||
state_batteries.append(battery.split(": ")[1].split(", ")[0])
|
||||
commasplitstatus = battery.split(", ")
|
||||
if not time:
|
||||
time = commasplitstatus[-1].strip()
|
||||
# check if it matches a time
|
||||
time = re.match(r"(\d+):(\d+)", time)
|
||||
if time:
|
||||
time = ":".join(time.groups())
|
||||
timeleft = " ({})".format(time)
|
||||
else:
|
||||
timeleft = ""
|
||||
|
||||
p = int(commasplitstatus[1].rstrip("%\n"))
|
||||
if p>0:
|
||||
percentleft_batteries.append(p)
|
||||
commasplitstatus_batteries.append(commasplitstatus)
|
||||
state = state_batteries[0]
|
||||
commasplitstatus = commasplitstatus_batteries[0]
|
||||
if percentleft_batteries:
|
||||
percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries))
|
||||
else:
|
||||
percentleft = 0
|
||||
|
||||
# stands for charging
|
||||
color = config.get("color_charging", "yellow")
|
||||
FA_LIGHTNING = "<span color='{}'><span font='FontAwesome'>\uf0e7</span></span>".format(color)
|
||||
|
||||
# stands for plugged in
|
||||
FA_PLUG = "<span font='FontAwesome'>\uf1e6</span>"
|
||||
|
||||
# stands for using battery
|
||||
FA_BATTERY = "<span font='FontAwesome'>\uf240</span>"
|
||||
|
||||
# stands for unknown status of battery
|
||||
FA_QUESTION = "<span font='FontAwesome'>\uf128</span>"
|
||||
|
||||
|
||||
if state == "Discharging":
|
||||
fulltext = FA_BATTERY + " "
|
||||
elif state == "Full":
|
||||
fulltext = FA_PLUG + " "
|
||||
timeleft = ""
|
||||
elif state == "Unknown":
|
||||
fulltext = FA_QUESTION + " " + FA_BATTERY + " "
|
||||
timeleft = ""
|
||||
else:
|
||||
fulltext = FA_LIGHTNING + " " + FA_PLUG + " "
|
||||
|
||||
def color(percent):
|
||||
if percent < 10:
|
||||
# exit code 33 will turn background red
|
||||
return config.get("color_10", "#FFFFFF")
|
||||
if percent < 20:
|
||||
return config.get("color_20", "#FF3300")
|
||||
if percent < 30:
|
||||
return config.get("color_30", "#FF6600")
|
||||
if percent < 40:
|
||||
return config.get("color_40", "#FF9900")
|
||||
if percent < 50:
|
||||
return config.get("color_50", "#FFCC00")
|
||||
if percent < 60:
|
||||
return config.get("color_60", "#FFFF00")
|
||||
if percent < 70:
|
||||
return config.get("color_70", "#FFFF33")
|
||||
if percent < 80:
|
||||
return config.get("color_80", "#FFFF66")
|
||||
return config.get("color_full", "#FFFFFF")
|
||||
|
||||
form = '<span color="{}">{}%</span>'
|
||||
fulltext += form.format(color(percentleft), percentleft)
|
||||
fulltext += timeleft
|
||||
|
||||
print(fulltext)
|
||||
print(fulltext)
|
||||
if percentleft < 10:
|
||||
exit(33)
|
66
bin/cpu_usage
Executable file
66
bin/cpu_usage
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env 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 = $ENV{T_WARN} // 50;
|
||||
my $t_crit = $ENV{T_CRIT} // 80;
|
||||
my $cpu_usage = -1;
|
||||
my $decimals = $ENV{DECIMALS} // 2;
|
||||
my $label = $ENV{LABEL} // "";
|
||||
my $color_normal = $ENV{COLOR_NORMAL} // "#EBDBB2";
|
||||
my $color_warn = $ENV{COLOR_WARN} // "#FFFC00";
|
||||
my $color_crit = $ENV{COLOR_CRIT} // "#FF0000";
|
||||
|
||||
sub help {
|
||||
print "Usage: cpu_usage [-w <warning>] [-c <critical>] [-d <decimals>]\n";
|
||||
print "-w <percent>: warning threshold to become yellow\n";
|
||||
print "-c <percent>: critical threshold to become red\n";
|
||||
print "-d <decimals>: Use <decimals> decimals for percentage (default is $decimals) \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
GetOptions("help|h" => \&help,
|
||||
"w=i" => \$t_warn,
|
||||
"c=i" => \$t_crit,
|
||||
"d=i" => \$decimals,
|
||||
);
|
||||
|
||||
# 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\x00]?$/) {
|
||||
$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
|
||||
print "${label}";
|
||||
printf "%.${decimals}f%%\n", $cpu_usage;
|
||||
print "${label}";
|
||||
printf "%.${decimals}f%%\n", $cpu_usage;
|
||||
|
||||
# Print color, if needed
|
||||
if ($cpu_usage >= $t_crit) {
|
||||
print "${color_crit}\n";
|
||||
} elsif ($cpu_usage >= $t_warn) {
|
||||
print "${color_warn}\n";
|
||||
} else {
|
||||
print "${color_normal}\n";
|
||||
}
|
||||
|
||||
exit 0;
|
73
bin/memory
Executable file
73
bin/memory
Executable file
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env 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}"
|
||||
PERCENT="${PERCENT:-true}"
|
||||
|
||||
awk -v type=$TYPE -v percent=$PERCENT '
|
||||
/^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") {
|
||||
free=swap_free/1024/1024
|
||||
used=(swap_total-swap_free)/1024/1024
|
||||
total=swap_total/1024/1024
|
||||
} else {
|
||||
free=mem_free/1024/1024
|
||||
used=(mem_total-mem_free)/1024/1024
|
||||
total=mem_total/1024/1024
|
||||
}
|
||||
|
||||
pct=0
|
||||
if (total > 0) {
|
||||
pct=used/total*100
|
||||
}
|
||||
|
||||
# full text
|
||||
if (percent == "true" ) {
|
||||
printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct)
|
||||
} else {
|
||||
printf("%.1fG/%.1fG\n", used, total)
|
||||
}
|
||||
# short text
|
||||
printf("%.f%%\n", pct)
|
||||
|
||||
# color
|
||||
if (pct > 90) {
|
||||
print("#FF0000")
|
||||
} else if (pct > 80) {
|
||||
print("#FFAE00")
|
||||
} else if (pct > 70) {
|
||||
print("#FFF600")
|
||||
}
|
||||
}
|
||||
' /proc/meminfo
|
31
i3blocks
Normal file
31
i3blocks
Normal file
|
@ -0,0 +1,31 @@
|
|||
[wifi]
|
||||
command=~/.dotfiles/bin/wifi -np -fe '{status}' '=' 'up' ' {ssid} ({quality}%)' -fe '{status}' '!=' 'up' ' down'
|
||||
instance=wlan0
|
||||
interval=5
|
||||
|
||||
[battery]
|
||||
command=~/.dotfiles/bin/battery
|
||||
markup=pango
|
||||
interval=30
|
||||
|
||||
[cpu_usage]
|
||||
command=~/.dotfiles/bin/cpu_usage
|
||||
interval=10
|
||||
LABEL=
|
||||
#min_width=CPU: 100.00%
|
||||
#T_WARN=50
|
||||
#T_CRIT=80
|
||||
DECIMALS=1
|
||||
#COLOR_NORMAL=#EBDBB2
|
||||
#COLOR_WARN=#FFFC00
|
||||
#COLOR_CRIT=#FF0000
|
||||
|
||||
[memory]
|
||||
command=~/.dotfiles/bin/memory
|
||||
label=
|
||||
interval=30
|
||||
|
||||
[time]
|
||||
command=date "+%Y-%m-%d %R:%S"
|
||||
label=
|
||||
interval=5
|
2
i3config
2
i3config
|
@ -203,7 +203,7 @@ bindsym $mod+r mode "resize"
|
|||
# finds out, if available)
|
||||
|
||||
bar {
|
||||
status_command i3status
|
||||
status_command i3blocks
|
||||
bindsym button1 nop
|
||||
bindsym button4 nop
|
||||
bindsym button5 nop
|
||||
|
|
3
install
3
install
|
@ -17,6 +17,9 @@ ln -sf ~/.dotfiles/dunstrc ~/.config/dunst/dunstrc
|
|||
mkdir -p ~/.config/alacritty
|
||||
ln -sf ~/.dotfiles/alacritty ~/.config/alacritty/alacritty.toml
|
||||
|
||||
mkdir -p ~/.config/i3blocks
|
||||
ln -sf ~/.dotfiles/i3blocks ~/.config/i3blocks/config
|
||||
|
||||
ln -sf ~/.dotfiles/bashrc ~/.bashrc
|
||||
ln -sf ~/.dotfiles/bash_profile ~/.bash_profile
|
||||
ln -sf ~/.dotfiles/xinitrc ~/.xinitrc
|
||||
|
|
|
@ -11,3 +11,7 @@ xclip
|
|||
cowsay
|
||||
fortune-mod
|
||||
mpc
|
||||
i3blocks
|
||||
acpi
|
||||
python3
|
||||
sysstat
|
||||
|
|
54
tags
54
tags
|
@ -8,10 +8,23 @@
|
|||
!_TAG_FIELD_DESCRIPTION name /tag name/
|
||||
!_TAG_FIELD_DESCRIPTION pattern /pattern/
|
||||
!_TAG_FIELD_DESCRIPTION typeref /Type and name of a variable or typedef/
|
||||
!_TAG_FIELD_DESCRIPTION!Python nameref /the original name for the tag/
|
||||
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
||||
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
||||
!_TAG_KIND_DESCRIPTION!Iniconf k,key /keys/
|
||||
!_TAG_KIND_DESCRIPTION!Iniconf s,section /sections/
|
||||
!_TAG_KIND_DESCRIPTION!Perl c,constant /constants/
|
||||
!_TAG_KIND_DESCRIPTION!Perl f,format /formats/
|
||||
!_TAG_KIND_DESCRIPTION!Perl l,label /labels/
|
||||
!_TAG_KIND_DESCRIPTION!Perl p,package /packages/
|
||||
!_TAG_KIND_DESCRIPTION!Perl s,subroutine /subroutines/
|
||||
!_TAG_KIND_DESCRIPTION!Python I,namespace /name referring a module defined in other file/
|
||||
!_TAG_KIND_DESCRIPTION!Python Y,unknown /name referring a class\/variable\/function\/module defined in other module/
|
||||
!_TAG_KIND_DESCRIPTION!Python c,class /classes/
|
||||
!_TAG_KIND_DESCRIPTION!Python f,function /functions/
|
||||
!_TAG_KIND_DESCRIPTION!Python i,module /modules/
|
||||
!_TAG_KIND_DESCRIPTION!Python m,member /class members/
|
||||
!_TAG_KIND_DESCRIPTION!Python v,variable /variables/
|
||||
!_TAG_KIND_DESCRIPTION!Sh a,alias /aliases/
|
||||
!_TAG_KIND_DESCRIPTION!Sh f,function /functions/
|
||||
!_TAG_KIND_DESCRIPTION!Sh h,heredoc /label for here document/
|
||||
|
@ -28,6 +41,8 @@
|
|||
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
|
||||
!_TAG_OUTPUT_VERSION 0.0 /current.age/
|
||||
!_TAG_PARSER_VERSION!Iniconf 0.0 /current.age/
|
||||
!_TAG_PARSER_VERSION!Perl 0.0 /current.age/
|
||||
!_TAG_PARSER_VERSION!Python 0.0 /current.age/
|
||||
!_TAG_PARSER_VERSION!Sh 0.0 /current.age/
|
||||
!_TAG_PARSER_VERSION!Vim 0.0 /current.age/
|
||||
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
|
||||
|
@ -36,12 +51,35 @@
|
|||
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
|
||||
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
|
||||
!_TAG_PROGRAM_VERSION 6.1.0 /v6.1.0/
|
||||
!_TAG_ROLE_DESCRIPTION!Python!module imported /imported modules/
|
||||
!_TAG_ROLE_DESCRIPTION!Python!module indirectlyImported /module imported in alternative name/
|
||||
!_TAG_ROLE_DESCRIPTION!Python!module namespace /namespace from where classes\/variables\/functions are imported/
|
||||
!_TAG_ROLE_DESCRIPTION!Python!unknown imported /imported from the other module/
|
||||
!_TAG_ROLE_DESCRIPTION!Python!unknown indirectlyImported /classes\/variables\/functions\/modules imported in alternative name/
|
||||
!_TAG_ROLE_DESCRIPTION!Sh!heredoc endmarker /end marker/
|
||||
!_TAG_ROLE_DESCRIPTION!Sh!script loaded /loaded/
|
||||
<Leader>md vimrc /^nnoremap <buffer> <Leader>md :Termdebug<CR>$/;" m
|
||||
<Leader>mm vimrc /^nnoremap <buffer> <Leader>mm <cmd>make<CR>$/;" m
|
||||
FA_BATTERY bin/battery /^ FA_BATTERY = "<span font='FontAwesome'>\\uf240<\/span>"$/;" v
|
||||
FA_LIGHTNING bin/battery /^ FA_LIGHTNING = "<span color='{}'><span font='FontAwesome'>\\uf0e7<\/span><\/span>".format(co/;" v
|
||||
FA_PLUG bin/battery /^ FA_PLUG = "<span font='FontAwesome'>\\uf1e6<\/span>"$/;" v
|
||||
FA_QUESTION bin/battery /^ FA_QUESTION = "<span font='FontAwesome'>\\uf128<\/span>"$/;" v
|
||||
W vimrc /^command! W execute 'w !sudo tee % > \/dev\/null' <bar> edit!$/;" c
|
||||
batteries bin/battery /^ batteries = status.split("\\n")$/;" v
|
||||
color bin/battery /^ color = config.get("color_10", "red")$/;" v
|
||||
color bin/battery /^ color = config.get("color_charging", "yellow")$/;" v
|
||||
color bin/battery /^ def color(percent):$/;" f
|
||||
commasplitstatus bin/battery /^ commasplitstatus = battery.split(", ")$/;" v
|
||||
commasplitstatus bin/battery /^ commasplitstatus = commasplitstatus_batteries[0]$/;" v
|
||||
commasplitstatus_batteries bin/battery /^ commasplitstatus_batteries=[]$/;" v
|
||||
config bin/battery /^config = dict(os.environ)$/;" v
|
||||
data_dir vimrc /^let data_dir = has('nvim') ? stdpath('data') . '\/site' : '~\/.vim'$/;" v
|
||||
form bin/battery /^ form = '<span color="{}">{}%<\/span>'$/;" v
|
||||
fulltext bin/battery /^ fulltext = FA_BATTERY + " "$/;" v
|
||||
fulltext bin/battery /^ fulltext = FA_LIGHTNING + " " + FA_PLUG + " "$/;" v
|
||||
fulltext bin/battery /^ fulltext = FA_PLUG + " "$/;" v
|
||||
fulltext bin/battery /^ fulltext = FA_QUESTION + " " + FA_BATTERY + " "$/;" v
|
||||
fulltext bin/battery /^ fulltext = "<span color='{}'><span font='FontAwesome'>\\uf00d \\uf240<\/span><\/span>".forma/;" v
|
||||
g:ycm_always_populate_location_list vimrc /^let g:ycm_always_populate_location_list = 1$/;" v
|
||||
get_album_art bin/volbright /^function get_album_art {$/;" f
|
||||
get_brightness bin/volbright /^function get_brightness {$/;" f
|
||||
|
@ -49,6 +87,22 @@ get_brightness_icon bin/volbright /^function get_brightness_icon {$/;" f
|
|||
get_mute bin/volbright /^function get_mute {$/;" f
|
||||
get_volume bin/volbright /^function get_volume {$/;" f
|
||||
get_volume_icon bin/volbright /^function get_volume_icon {$/;" f
|
||||
help bin/cpu_usage /^sub help {$/;" s
|
||||
p bin/battery /^ p = int(commasplitstatus[1].rstrip("%\\n"))$/;" v
|
||||
percentleft bin/battery /^ percentleft = 0$/;" v
|
||||
percentleft bin/battery /^ percentleft = int(sum(percentleft_batteries)\/len(percentleft_batteries))$/;" v
|
||||
percentleft bin/battery /^ percentleft = 100$/;" v
|
||||
percentleft_batteries bin/battery /^ percentleft_batteries=[]$/;" v
|
||||
show_brightness_notif bin/volbright /^function show_brightness_notif {$/;" f
|
||||
show_music_notif bin/volbright /^function show_music_notif {$/;" f
|
||||
show_volume_notif bin/volbright /^function show_volume_notif {$/;" f
|
||||
state bin/battery /^ state = state_batteries[0]$/;" v
|
||||
state_batteries bin/battery /^ state_batteries=[]$/;" v
|
||||
status bin/battery /^status = check_output(['acpi'], universal_newlines=True)$/;" v
|
||||
time bin/battery /^ time = ":".join(time.groups())$/;" v
|
||||
time bin/battery /^ time = commasplitstatus[-1].strip()$/;" v
|
||||
time bin/battery /^ time = re.match(r"(\\d+):(\\d+)", time)$/;" v
|
||||
time bin/battery /^ time = ""$/;" v
|
||||
timeleft bin/battery /^ timeleft = " ({})".format(time)$/;" v
|
||||
timeleft bin/battery /^ timeleft = ""$/;" v
|
||||
timeleft bin/battery /^ timeleft = ""$/;" v
|
||||
|
|
Loading…
Reference in a new issue