From b59e66226cde127252743fa795b21b11b9c2c37b Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sun, 12 Jul 2015 13:55:59 +0200 Subject: [PATCH] Notify system startup errors --- .config/awesome/rc.lua | 21 ++++++++++++++++++--- .profile | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 3301889f..175ed68b 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -31,6 +31,11 @@ if ostype == "Linux" then vicious = require("vicious") end +-- Custom variables. +local termcmd = os.getenv("TERMCMD") or "urxvt" +local term = termcmd .. " -e " +local home = os.getenv("HOME") + -------------------------------------------------------------------------------- -- Error handling -------------------------------------------------------------------------------- @@ -58,6 +63,19 @@ do end) end +-- Notify system startup errors. +do + for _, file in pairs({home .. "/errors-dmesg.log", home .. "/errors-systemd.log"}) do + local f = io.open (file,'r') + if f ~= nil then + f:close () + naughty.notify({ preset = naughty.config.presets.critical, + title = "System startup error!", + text = "See " .. file }) + end + end +end + -------------------------------------------------------------------------------- -- Themes define colours, icons, and wallpapers -------------------------------------------------------------------------------- @@ -231,9 +249,6 @@ move_mouse_away() -- Note that some laptop will not work when pressing Super+Fn. -- Therefore we only use Fn and Mod1+Fn. -------------------------------------------------------------------------------- -termcmd = os.getenv("TERMCMD") or "urxvt" -term = termcmd .. " -e " -home = os.getenv("HOME") globalkeys = awful.util.table.join( -- Terminal diff --git a/.profile b/.profile index 13a8ac7e..735827a2 100644 --- a/.profile +++ b/.profile @@ -123,6 +123,20 @@ if [ -d "$HOME/.go" ]; then appendpath "$GOPATH/bin" fi +## Startup error log. +## dmesg +log_dmesg="$(dmesg | grep -i error)" +[ -n "$log_dmesg" ] && echo "$log_dmesg" > "$HOME/errors-dmesg.log" || rm -f "$HOME/errors-dmesg.log" +## systemd +if command -v systemctl >/dev/null 2>&1; then + count="$(systemctl -l --failed | awk '{print $1;exit}')" + if [ $count -ne 0 ]; then + systemctl -l --failed > "$HOME/errors-systemd.log" + else + rm -f "$HOME/errors-systemd.log" + fi +fi + ## Hook. Should be sourced last [ -f ~/.profile_hook ] && . ~/.profile_hook ################################################################################