aboutsummaryrefslogtreecommitdiffstats
path: root/home/conky
diff options
context:
space:
mode:
authorPetri Hienonen <petri.hienonen@gmail.com>2024-05-23 13:56:00 +0300
committerPetri Hienonen <petri.hienonen@gmail.com>2025-11-30 12:29:57 +0200
commit08297376a85a1719518507e54fca9de954d2376a (patch)
tree3b9c58304b40248533bbb2bb5b7bad2da9da1ff0 /home/conky
parent75c2af4aedd2ac5c2cfc74b346625fa4b265541d (diff)
downloadnixos-08297376a85a1719518507e54fca9de954d2376a.tar.zst
Agenix configuration
Diffstat (limited to 'home/conky')
-rw-r--r--home/conky/default.nix76
-rw-r--r--home/conky/main.lua45
2 files changed, 121 insertions, 0 deletions
diff --git a/home/conky/default.nix b/home/conky/default.nix
new file mode 100644
index 0000000..1fc628e
--- /dev/null
+++ b/home/conky/default.nix
@@ -0,0 +1,76 @@
+{
+ config,
+ pkgs-unstable,
+ lib,
+ ...
+}:
+let
+ luaMain = builtins.readFile ./main.lua;
+in
+{
+ services.conky = {
+ enable = true;
+ package =
+ (pkgs-unstable.conky.override {
+ curlSupport = true;
+ journalSupport = true;
+ luaCairoSupport = true;
+ luaSupport = true;
+ pulseSupport = true;
+ waylandSupport = true;
+ x11Support = true;
+ }).overrideAttrs
+ (old: {
+ buildInputs = old.buildInputs ++ [
+ pkgs-unstable.cairo
+ pkgs-unstable.wayland
+ pkgs-unstable.libGL
+ pkgs-unstable.expat
+ pkgs-unstable.xorg.libXfixes
+ ];
+ });
+
+ # https://conky.cc/config_settings
+ extraConfig = ''
+ conky.config = {
+ -- wayland
+ out_to_wayland = false,
+ out_to_x = true,
+ own_window_class = 'conky',
+ own_window_type ='override',
+ own_window = true,
+ own_window_transparent = true,
+ own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',
+ double_buffer = true,
+
+ alignment = "top_right",
+ gap_x = 60,
+ gap_y = 60,
+ minimum_width = 400,
+ minimum_height = 200,
+ maximum_width = 400,
+
+ -- Colors and fonts
+ draw_shades = false,
+ draw_outline = false,
+ draw_borders = false,
+ default_color = "white",
+ default_shade_color = "black",
+ default_outline_color = "black",
+ color1 = "lightblue",
+
+ -- Text
+ use_xft = yes,
+ font = "Liberation Mono:size=10",
+ uppercase = false,
+
+ -- Lua configuration
+ lua_load = '${config.home.homeDirectory}/.config/conky/main.lua',
+ lua_draw_hook_post = "conky_main"
+ };
+
+ conky.text = [[ ]]
+ '';
+ };
+ xdg.configFile."conky/main.lua".text = luaMain;
+}
diff --git a/home/conky/main.lua b/home/conky/main.lua
new file mode 100644
index 0000000..04eac69
--- /dev/null
+++ b/home/conky/main.lua
@@ -0,0 +1,45 @@
+require("cairo")
+require("cairo_xlib")
+
+function conky_main()
+ if conky_window == nil then
+ print("No window")
+ return
+ end
+
+ local cairo_surface = cairo_xlib_surface_create(
+ conky_window.display,
+ conky_window.drawable,
+ conky_window.visual,
+ conky_window.width,
+ conky_window.height
+ )
+ local c = cairo_create(cairo_surface)
+
+ cairo_select_font_face(c, "Liberation Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size(c, 12)
+ cairo_set_source_rgba(c, 1, 1, 1, 1)
+ cairo_move_to(c, 100, 100)
+ cairo_show_text(c, "hello world")
+ cairo_stroke(c)
+
+ -- Settings.
+ local line_width = 5
+ local top_left_x = 20
+ local top_left_y = 20
+ local rec_width = 100
+ local rec_height = 50
+ local red = 1
+ local green = 0
+ local blue = 0
+ local alpha = 1
+
+ -- Draw it.
+ cairo_set_line_width(c, line_width)
+ cairo_rectangle(c, top_left_x, top_left_y, rec_width, rec_height)
+ cairo_set_source_rgba(c, red, green, blue, alpha)
+
+ cairo_destroy(c)
+ cairo_surface_destroy(cairo_surface)
+ print("Draw")
+end