Awesome: battery now warns according to time limit, not to percentage limit.
Awesome: network up/down speed now works for ethN as well as for wlanN. Emacs: set TeX default compiler. Shell: added a lot of common bash completion features. Not tested. Shell: cpuusage function.master
parent
a8cbec0b21
commit
d378c9346b
|
@ -105,28 +105,43 @@ cpuwidget = widget({ type = "textbox" })
|
|||
vicious.register(cpuwidget, vicious.widgets.cpu, '<span color="#CC8F52">CPU $1%</span>')
|
||||
|
||||
-- Net
|
||||
-- TODO: get speed for all interfaces.
|
||||
netwidget = widget({ type = "textbox" })
|
||||
vicious.register(netwidget, vicious.widgets.net, '<span color="#CC9393">↓${eth0 down_kb}</span> <span color="#7F9F7F">↑${eth0 up_kb}</span>', 3)
|
||||
networks = { "eth0", "wlan0" }
|
||||
vicious.register(netwidget, vicious.widgets.net,
|
||||
function (widget, args)
|
||||
for _,device in pairs(networks) do
|
||||
if tonumber(args["{".. device .." carrier}"]) > 0 then
|
||||
return '<span color="#CC9393">↓' .. args["{" .. device .. " down_kb}"] .. '</span> <span color="#7F9F7F">↑' .. args["{" .. device .. " up_kb}"] .. '</span>'
|
||||
end
|
||||
end
|
||||
end, 3)
|
||||
|
||||
-- Battery
|
||||
batwidget = widget({ type = "textbox" })
|
||||
local batf = io.popen("ls '/sys/class/power_supply' 2>/dev/null")
|
||||
local batl = batf:read("*a")
|
||||
local batlimit = 10
|
||||
if batl ~= "" then
|
||||
--{{ Simple version (perf friendly)
|
||||
-- vicious.register(batwidget, vicious.widgets.bat, '<span color="#73A9CD">$2%$1$3</span> | ', 60, "BAT0")
|
||||
-- This functions changes the status color when a specific level is reached.
|
||||
--{{ Complex version (time warning)
|
||||
-- This functions changes the status color when batlimit is reached.
|
||||
vicious.register(batwidget, vicious.widgets.bat,
|
||||
function (widget, args)
|
||||
if args[2] <= 10 then return '<span color="#FF0000">' .. args[2] .. '%' .. args[1] .. args[3] .. '</span>'
|
||||
else return '<span color="#73A9CD">' .. args[2] .. '%' .. args[1] .. args[3] .. '</span>'
|
||||
-- We check if time is displayed (otherwise it's 'N/A'), and if minutes are less than limit.
|
||||
if string.len(args[3]) == 5
|
||||
and tonumber(string.sub(args[3],1,2)) == 0
|
||||
and tonumber(string.sub(args[3],4,5)) <= batlimit
|
||||
then
|
||||
return '<span color="#FF0000">' .. args[2] .. '%' .. args[1] .. args[3] .. '</span>'
|
||||
else
|
||||
return '<span color="#73A9CD">' .. args[2] .. '%' .. args[1] .. args[3] .. '</span>'
|
||||
end
|
||||
end,
|
||||
60, "BAT0")
|
||||
end
|
||||
batf:close()
|
||||
|
||||
|
||||
-- Volume
|
||||
volmwidget = widget({ type = "textbox" })
|
||||
vicious.register(volmwidget, vicious.widgets.volume, "Master $1% $2 ", 1, "Master")
|
||||
|
|
7
.emacs
7
.emacs
|
@ -527,6 +527,13 @@ the line."
|
|||
;; AucTeX
|
||||
;;==============================================================================
|
||||
|
||||
(setq tex-run-command "pdftex")
|
||||
(setq latex-run-command "pdflatex")
|
||||
|
||||
;;==============================================================================
|
||||
;; AucTeX
|
||||
;;==============================================================================
|
||||
|
||||
;; ;; Activate AucTeX
|
||||
;; (load "auctex.el" nil t t)
|
||||
;; (load "preview-latex.el" nil t t)
|
||||
|
|
|
@ -128,6 +128,60 @@ netspeed ()
|
|||
echo "TX $TX_RESULT KiB/s"
|
||||
}
|
||||
|
||||
## CPU usage
|
||||
##
|
||||
## A typical CPU array is (on Linux Kernel 3.0)
|
||||
## cpu 158150 0 52354 18562746 1472 0 10198 0 0 0
|
||||
##
|
||||
## The meanings of the columns are as follows, from left to right:
|
||||
##
|
||||
## user: normal processes executing in user mode
|
||||
## nice: niced processes executing in user mode
|
||||
## system: processes executing in kernel mode
|
||||
## idle: twiddling thumbs
|
||||
## iowait: waiting for I/O to complete
|
||||
## irq: servicing interrupts
|
||||
## softirq: servicing softirqs
|
||||
## ... (see 'man 5 proc' for further details)
|
||||
##
|
||||
## Only the first 4 values are interesting here.
|
||||
cpuusage(){
|
||||
local cpuarray
|
||||
local f1
|
||||
local f2
|
||||
local f3
|
||||
local f4
|
||||
|
||||
cpuarray="$(grep 'cpu ' /proc/stat)"
|
||||
f1=$(echo $cpuarray | cut -f3 -d' ')
|
||||
f2=$(echo $cpuarray | cut -f4 -d' ')
|
||||
f3=$(echo $cpuarray | cut -f5 -d' ')
|
||||
f4=$(echo $cpuarray | cut -f6 -d' ')
|
||||
|
||||
local totalA=$(($f1+$f2+$f3+$f4))
|
||||
local idleA=$f4
|
||||
|
||||
sleep 0.4
|
||||
|
||||
cpuarray="$(grep 'cpu ' /proc/stat)"
|
||||
f1=$(echo $cpuarray | cut -f3 -d' ')
|
||||
f2=$(echo $cpuarray | cut -f4 -d' ')
|
||||
f3=$(echo $cpuarray | cut -f5 -d' ')
|
||||
f4=$(echo $cpuarray | cut -f6 -d' ')
|
||||
|
||||
local totalB=$(($f1+$f2+$f3+$f4))
|
||||
local idleB=$f4
|
||||
|
||||
local totaldiff=$((${totalB:-0}-${totalA:-0}))
|
||||
|
||||
if [ $totaldiff -eq 0 ]; then
|
||||
echo 0
|
||||
else
|
||||
echo "$((100 - 100 * ($idleB-$idleA) / $totaldiff ))"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
## Vim-only: search the vim reference manual for a keyword.
|
||||
## Usage: :h <keyword>
|
||||
if [ -e "/usr/bin/vim" ]; then
|
||||
|
|
|
@ -24,9 +24,9 @@ export FIGNORE=".o:~"
|
|||
## To search and fill the complete name of a file (with <Esc>)
|
||||
set filec
|
||||
|
||||
##======================================================================
|
||||
##==============================================================================
|
||||
## History management
|
||||
##======================================================================
|
||||
##==============================================================================
|
||||
|
||||
# Don't put duplicate lines in the history. See bash(1) for more options.
|
||||
export HISTCONTROL=ignoredups
|
||||
|
@ -37,9 +37,10 @@ export HISTFILESIZE=1000
|
|||
export HISTIGNORE="&:bg:fg:ll:h:ls:la:la:lk:clear:exit:history"
|
||||
export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S_%a "
|
||||
|
||||
##======================================================================
|
||||
##==============================================================================
|
||||
## Various options
|
||||
##======================================================================
|
||||
##==============================================================================
|
||||
|
||||
set -o notify # Jobs notify shell about their states immediately.
|
||||
#set ignoreeof # To avoid accidentally quitting the shell with <Ctrl-D>.
|
||||
#shopt -u mailwarn # Disable the shell ability to warn about incoming mail.
|
||||
|
@ -58,6 +59,34 @@ shopt -s no_empty_cmd_completion # No completion on an empty line.
|
|||
shopt -s nocaseglob # Pathname expansion will be treated as case-insensitive.
|
||||
shopt -s progcomp # To enable the programmable completion.
|
||||
|
||||
##==============================================================================
|
||||
## Various options
|
||||
##==============================================================================
|
||||
|
||||
complete -A setopt set
|
||||
complete -A hostname ssh rsh rcp telnet rlogin r ftp ping disk
|
||||
complete -A export export printenv
|
||||
complete -A variable export local readonly unset
|
||||
complete -A enabled builtin
|
||||
complete -A alias alias unalias
|
||||
complete -A function function
|
||||
complete -A user su mail finger my_ps my_detail_ps
|
||||
complete -A helptopic help # currently same as builtins
|
||||
complete -A shopt shopt
|
||||
complete -A stopped -P '%' bg
|
||||
complete -A job -P '%' fg jobs disown
|
||||
complete -A directory rmdir
|
||||
#complete -A directory -o default cd
|
||||
complete -A command which
|
||||
complete -A signal kill killall
|
||||
|
||||
# File name completion according to program functionnality
|
||||
complete -A file -X '!*.@(zip|ZIP|jar|JAR)' unzip zipinfo
|
||||
complete -A file -X '!*.@(z|Z)' uncompress
|
||||
complete -A file -X '!*.@(gz|GZ)' gunzip
|
||||
complete -A file -X '!*.@(bz2|BZ2)' bunzip2 untar
|
||||
complete -A file -X '!*.@(tar|TAR)' untar
|
||||
|
||||
##==============================================================================
|
||||
## PS1 -- Full width bar with informations.
|
||||
##==============================================================================
|
||||
|
|
Loading…
Reference in New Issue