diff --git a/rc.lua b/rc.lua index ebf6a0d..997d408 100644 --- a/rc.lua +++ b/rc.lua @@ -216,6 +216,28 @@ gmail_mail.timer:connect_signal("timeout", gmail_mail.timer:start() gmail_mail:buttons(mailicon:buttons()) +-- nVidia Optimus +local optimus_icon = wibox.widget.imagebox() +optimus_icon:set_image(beautiful.widget_optimus_off) +optimus_icon.timer = timer{timeout=3} +optimus_icon.timer:connect_signal("timeout", + function () + local f = io.open("/proc/acpi/bbswitch", "r") + local l = nil + if f ~= nil then + l = f:read() + if string.sub (l, 14) == "ON" then + optimus_icon:set_image(beautiful.widget_optimus_on) + else + optimus_icon:set_image(beautiful.widget_optimus_off) + end + f:close() + else + optimus_icon:set_image(beautiful.widget_optimus_off) + end + end) +optimus_icon.timer:start() + -- Wi-Fi / Ethernet widgets local wifi_widget_down = wibox.widget.textbox() local wifi_widget_up = wibox.widget.textbox() @@ -281,6 +303,8 @@ for s = 1, screen.count() do right_layout:add(mem) right_layout:add(diskicon) right_layout:add(disk) + right_layout:add(optimus_icon) + right_layout:add(spacer) right_layout:add(baticon) right_layout:add(batpct) right_layout:add(icon_wifi) diff --git a/themes/default/theme.lua b/themes/default/theme.lua index cd7c4ae..64fc1cd 100644 --- a/themes/default/theme.lua +++ b/themes/default/theme.lua @@ -125,6 +125,8 @@ theme.widget_pac = awful.util.getdir("config") .. "/themes/default/widgets/pac.p theme.widget_pacnew = awful.util.getdir("config") .. "/themes/default/widgets/pacnew.png" theme.widget_mail = awful.util.getdir("config") .. "/themes/default/widgets/mail.png" theme.widget_mailnew = awful.util.getdir("config") .. "/themes/default/widgets/mailnew.png" +theme.widget_optimus_off = awful.util.getdir("config") .. "/themes/default/widgets/optimus_off.png" +theme.widget_optimus_on = awful.util.getdir("config") .. "/themes/default/widgets/optimus_on.png" theme.widget_temp = awful.util.getdir("config") .. "/themes/default/widgets/temp.png" theme.widget_tempwarn = awful.util.getdir("config") .. "/themes/default/widgets/tempwarm.png" theme.widget_temphot = awful.util.getdir("config") .. "/themes/default/widgets/temphot.png" diff --git a/themes/default/widgets/optimus_off.png b/themes/default/widgets/optimus_off.png new file mode 100644 index 0000000..b5142db Binary files /dev/null and b/themes/default/widgets/optimus_off.png differ diff --git a/themes/default/widgets/optimus_on.png b/themes/default/widgets/optimus_on.png new file mode 100644 index 0000000..ff59731 Binary files /dev/null and b/themes/default/widgets/optimus_on.png differ