From b302b7078770b2f3fd12fe12827dd44148436c31 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 17 Jun 2014 22:22:47 +0200 Subject: [PATCH] theme: adapt to "hidpi" screens We use a scale factor. We are expected to have something sensible set for DPI. --- rc/theme.lua | 22 +++++++++++++++++++--- rc/widgets.lua | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/rc/theme.lua b/rc/theme.lua index 9ebab42..9b029c3 100644 --- a/rc/theme.lua +++ b/rc/theme.lua @@ -3,11 +3,27 @@ local na = awful.util.color_strip_alpha local icons = awful.util.getdir("config") .. "/icons" +local function scale() + local xdpyinfo = io.popen("xdpyinfo") + if xdpyinfo then + for line in xdpyinfo:lines() do + output = line:match("^%s*resolution:%s+(%d+)x%d+ dots per inch$") + if output then + xdpyinfo:close() + return tonumber(output)/96 + end + end + xdpyinfo:close() + end + return 1 +end + theme = {} +theme.scale = scale() theme.icons = icons theme.wallpaper_cmd = { "/bin/true" } -theme.font = "Terminus 8" -theme.tasklist_font = "DejaVu Sans 8" +theme.font = "Terminus " .. 8 * theme.scale +theme.tasklist_font = "DejaVu Sans " .. 8 * theme.scale theme.bg_normal = "#22222299" theme.bg_focus = "#d8d8d8bb" @@ -44,7 +60,7 @@ end -- Naughty naughty.config.presets.normal.bg = theme.bg_widget for _,preset in pairs({"normal", "low", "critical"}) do - naughty.config.presets[preset].font = "DejaVu Sans 10" + naughty.config.presets[preset].font = "DejaVu Sans " .. 10 * theme.scale end return theme diff --git a/rc/widgets.lua b/rc/widgets.lua index 27d9157..f430f0d 100644 --- a/rc/widgets.lua +++ b/rc/widgets.lua @@ -130,7 +130,7 @@ local netdownicon = widget({ type = "imagebox" }) netdownicon.image = image(beautiful.icons .. "/widgets/down.png") local netgraph = awful.widget.graph() -netgraph:set_width(80):set_height(16) +netgraph:set_width(80):set_height(16 * theme.scale) netgraph:set_stack(true):set_scale(true) netgraph:set_border_color(beautiful.fg_widget_border) netgraph:set_stack_colors({ "#EF8171", "#cfefb3" }) @@ -263,7 +263,7 @@ for s = 1, screen.count() do fg = beautiful.fg_normal, bg = beautiful.bg_widget, position = "top", - height = 16, + height = 16 * theme.scale, }) -- Add widgets to the wibox local on = function(n, what)