From 7493c4c868ff183df959e9b7aa8c172c94044bac Mon Sep 17 00:00:00 2001 From: Ambrevar Date: Mon, 29 Oct 2012 17:22:41 +0100 Subject: [PATCH] Awesome: fixed 'ostype' variable. Shell: SHELL_CURRENT uses the same ps command for both BSD and GNU. --- .bashrc | 2 +- .config/awesome/rc.lua | 11 ++++++----- .shell.d/lscolors | 1 + .zshrc | 7 +------ 4 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 .shell.d/lscolors diff --git a/.bashrc b/.bashrc index df865ea5..6afcfded 100644 --- a/.bashrc +++ b/.bashrc @@ -12,7 +12,7 @@ ## Sourcing ##============================================================================== -SHELL_CURRENT="$(ps | awk -v shellpid=$$ '$0 ~ shellpid {print $4}')" +SHELL_CURRENT="$(ps -o command="" $$)" SHELL_DIR="$HOME/.shell.d" ## Should be sourced first. diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 65907cc1..4657ceee 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -3,9 +3,9 @@ -- Date 2012-10-28 -------------------------------------------------------------------------------- --- Get OS +-- Get OS. Take care to read one line only, skipping end of line. local f = io.popen("uname") -local ostype = f:read("*a") +local ostype = f:read("*l") f:close() -- Standard awesome library @@ -42,7 +42,8 @@ end -- Handle runtime errors after startup do local in_error = false - awesome.add_signal("debug::error", function (err) + awesome.add_signal("debug::error", + function (err) -- Make sure we don't go into an endless error loop if in_error then return end in_error = true @@ -51,7 +52,7 @@ do title = "Oops, an error happened!", text = err }) in_error = false - end) + end) end -------------------------------------------------------------------------------- @@ -135,11 +136,11 @@ if ostype == "Linux" then -- If 'amixer' is not installed, status will never display. local volpf = io.popen("amixer | grep PCM 2>/dev/null") local volpl = volpf:read("*a") + volpf:close() if volpl ~= "" then volpwidget = widget({ type = "textbox" }) vicious.register(volpwidget, vicious.widgets.volume, "PCM $1%", 1, "PCM") end - volpf:close() -- Battery local batf = io.popen("ls '/sys/class/power_supply' 2>/dev/null") diff --git a/.shell.d/lscolors b/.shell.d/lscolors new file mode 100644 index 00000000..2d709723 --- /dev/null +++ b/.shell.d/lscolors @@ -0,0 +1 @@ +mh=01;37:pi=01;33:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.tlz=00;31:*.txz=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.lz=00;31:*.xz=00;31:*.bz2=00;31:*.bz=00;31:*.tbz=00;31:*.tbz2=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.war=00;31:*.ear=00;31:*.sar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:*.iso=04;31:*.jpg=04;33:*.jpeg=04;33:*.gif=04;33:*.bmp=04;33:*.pbm=04;33:*.pgm=04;33:*.ppm=04;33:*.tga=04;33:*.xbm=04;33:*.xpm=04;33:*.tif=04;33:*.tiff=04;33:*.png=04;33:*.svg=04;33:*.svgz=04;33:*.mng=04;33:*.pcx=04;33:*.JPG=04;33:*.JPEG=04;33:*.GIF=04;33:*.BMP=04;33:*.PBM=04;33:*.PGM=04;33:*.PPM=04;33:*.TGA=04;33:*.XBM=04;33:*.XPM=04;33:*.TIF=04;33:*.TIFF=04;33:*.PNG=04;33:*.SVG=04;33:*.SVGZ=04;33:*.MNG=04;33:*.PCX=04;33:*.pdf=00;33:*.ps=00;33:*.dvi=00;33:*.0=00;33:*.1=00;33:*.2=00;33:*.3=00;33:*.4=00;33:*.5=00;33:*.6=00;33:*.7=00;33:*.8=00;33:*.9=00;33:*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:*.m2v=00;35:*.mkv=00;35:*.webm=00;35:*.ogm=00;35:*.mp4=00;35:*.m4v=00;35:*.mp4v=00;35:*.vob=00;35:*.qt=00;35:*.nuv=00;35:*.wmv=00;35:*.asf=00;35:*.rm=00;35:*.rmvb=00;35:*.flc=00;35:*.avi=00;35:*.fli=00;35:*.flv=00;35:*.gl=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.cgm=00;35:*.emf=00;35:*.aac=04;35:*.au=04;35:*.flac=04;35:*.mid=04;35:*.midi=04;35:*.mka=04;35:*.mp3=04;35:*.mpc=04;35:*.ogg=04;35:*.ra=04;35:*.wav=04;35:*.txt=04;37:*.log=04;37:*.tex=04;37:*.srt=04;37:*.sub=04;37:*.html=04;37:*.htm=04;37:*.css=04;37:*.js=04;37:*.mk=04;36:*.in=04;36:*.lua=00;36:*.py=00;36:*.pl=00;36:*.el=00;36:*.c=00;36:*.h=00;36:*.cpp=00;36:*.hpp=00;36:*.cc=00;36:*.hh=00;36:*.sh=00;36:*.bash=00;36:*.zsh=00;36:*.csh=00;36:*.ksh=00;36: diff --git a/.zshrc b/.zshrc index 78e2ac4d..0a787288 100644 --- a/.zshrc +++ b/.zshrc @@ -7,12 +7,7 @@ ## Sourcing ##============================================================================== -## TODO: is it possible to unify BSD and GNU here? -if [ "$OSTYPE" = "linux-gnu" ]; then - SHELL_CURRENT="$(ps -o command hp $$ )" -else - SHELL_CURRENT="$(ps -o command="" $$)" -fi +SHELL_CURRENT="$(ps -o command="" $$)" SHELL_DIR="$HOME/.shell.d" ## Should be sourced first.