From bcb39f3a7016f5f15696390210721dc7608b9617 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 27 Sep 2023 20:04:34 -0400 Subject: awesome: redo topbar. reworking systems org --- home/jon/home.nix | 22 ++--- programs/dotfiles/awesome/calendar.lua | 115 ------------------------- programs/dotfiles/awesome/dmenu.lua | 12 +++ programs/dotfiles/awesome/rc.lua | 14 +-- programs/dotfiles/awesome/theme.lua | 10 +-- programs/dotfiles/awesome/volume.lua | 60 ------------- programs/dotfiles/awesome/widgets/calendar.lua | 115 +++++++++++++++++++++++++ programs/dotfiles/awesome/widgets/volume.lua | 60 +++++++++++++ programs/virt-manager.nix | 16 ++++ systems/default.nix | 69 +++++---------- systems/jonbox/default.nix | 38 +++++++- users/jon.nix | 1 + 12 files changed, 283 insertions(+), 249 deletions(-) delete mode 100644 programs/dotfiles/awesome/calendar.lua create mode 100644 programs/dotfiles/awesome/dmenu.lua delete mode 100644 programs/dotfiles/awesome/volume.lua create mode 100644 programs/dotfiles/awesome/widgets/calendar.lua create mode 100644 programs/dotfiles/awesome/widgets/volume.lua create mode 100644 programs/virt-manager.nix diff --git a/home/jon/home.nix b/home/jon/home.nix index 6fb6d02..740f1e6 100644 --- a/home/jon/home.nix +++ b/home/jon/home.nix @@ -4,9 +4,12 @@ let username = "jon"; in { + programs.home-manager.enable = true; + home.username = username; home.homeDirectory = "/home/${username}"; + #Userspace programs imports = [ ../../programs/picom.nix @@ -16,6 +19,8 @@ in ../../programs/neovim.nix ../../programs/firefox.nix ../../programs/newsboat.nix + + ../../programs/virt-manager.nix ]; home.packages = with pkgs; [ @@ -31,6 +36,12 @@ in ffmpeg ]; + programs.ncmpcpp.enable = true; + programs.zathura.enable = true; + programs.bashmount.enable = true; + programs.mpv.enable = true; + + #Awesome home.activation.installAwesomeWMConfig = '' if [ ! -d "$HOME/.config/awesome" ]; then ln -s "/etc/nixos/programs/dotfiles/awesome" "$HOME/.config/awesome" @@ -38,21 +49,12 @@ in fi ''; - programs.home-manager.enable = true; - + #Git programs.git = { enable = true; userName = "Jon Santmyer"; userEmail = "jon@jonsantmyer.com"; }; - programs.ncmpcpp.enable = true; - programs.zathura.enable = true; - programs.bashmount.enable = true; - - programs.mpv = { - enable = true; - }; - home.stateVersion = "23.05"; } diff --git a/programs/dotfiles/awesome/calendar.lua b/programs/dotfiles/awesome/calendar.lua deleted file mode 100644 index 6e791b3..0000000 --- a/programs/dotfiles/awesome/calendar.lua +++ /dev/null @@ -1,115 +0,0 @@ -local awful = require("awful") -local beautiful = require("beautiful") -local wibox = require("wibox") -local gears = require("gears") - -local calendar_widget = {} - -local function worker(user_args) - local args = user_args or {} - - local style = {} - - style.month = { - padding = 4, - bg_color = beautiful.bg_normal, - border_width = 0 - } - - style.normal = { - markup = function(t) return t end, - shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end, - } - - style.focused = { - bg_color = beautiful.bg_focus, - fg_color = beautiful.fg_focus, - markup = function(t) return '' .. t .. '' end, - shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end, - } - - style.header = { - bg_color = beautiful.bg_focus, - fg_color = beautiful.fg_focus, - markup = function(t) return ''..t..'' end, - } - - style.weekday = { - bg_color = beautiful.bg_focus, - fg_color = beautiful.fg_focus, - markup = function(t) return ''..t..'' end, - } - - local function decorate(widget, flag, date) - if flag == 'monthheader' then flag = 'header' end - if flag == 'focus' then - local today = os.date('*t') - if not today.month == date.month and today.year == date.year then - flag = 'normal' - end - end - local properties = style[flag] or {} - if properties.markup and widget.get_text and widget.set_markup then - widget:set_markup(properties.markup(widget:get_text())) - end - local thisdate = { year = date.year, month = (date.month or 1), day = (date.day or 1) } - local weekday = tonumber(os.date('%w', os.time(d))) - local default_bg = (weekday == 0 or weekday == 6) - and beautiful.bg_focused - or beautiful.bg_normal - return wibox.widget { - { - { - widget, - halign = 'center', - widget = wibox.container.place - }, - margins = (properties.padding or 2) + (properties.border_width or 0), - widget = wibox.container.margin - }, - shape = properties.shape, - shape_border_color = properties.border_color or '#00000000', - shape_border_width = properties.border_width or 0, - fg = properties.fg_color or beautiful.fg_normal, - bg = properties.bg_color or beautiful.bg_normal, - widget = wibox.container.background - } - end - - local cal = wibox.widget { - date = os.date('*t'), - font = beautiful.get_font(), - fn_embed = decorate, - long_weekdays = true, - start_sunday = true, - widget = wibox.widget.calendar.month - } - - local popup = awful.popup { - ontop = true, - visible = false, - shape = gears.shape.rounded_rect, - offset = { y = 5 }, - border_width = 2, - border_color = beautiful.fg_minimize, - widget = cal - } - - function calendar_widget.toggle() - if popup.visible then - cal:set_date(nil) - cal:set_date(os.date('*t')) - popup:set_widget(nil) - popup:set_widget(cal) - popup.visible = not popup.visible - else - awful.placement.top_right(popup, { margins = { top = 30, right = 10 }, parent = awful.screen.focused() }) - popup.visible = true - end - end - return calendar_widget -end - -return setmetatable(calendar_widget, { __call = function(_, ...) - return worker(...) -end}) diff --git a/programs/dotfiles/awesome/dmenu.lua b/programs/dotfiles/awesome/dmenu.lua new file mode 100644 index 0000000..17301d3 --- /dev/null +++ b/programs/dotfiles/awesome/dmenu.lua @@ -0,0 +1,12 @@ +local awful = require("awful") +local keygrabber = require("awful.keygrabber") +local beautiful = require("beautiful") +local wibox = require("wibox") +local gears = require("gears") + +local dmenu_widget = {} + +local function worker(user_args) + +end + diff --git a/programs/dotfiles/awesome/rc.lua b/programs/dotfiles/awesome/rc.lua index 904164a..3bf090f 100644 --- a/programs/dotfiles/awesome/rc.lua +++ b/programs/dotfiles/awesome/rc.lua @@ -137,10 +137,10 @@ toptextclock = wibox.widget.textclock() -- shape = gears.shape.rounded_rect --} -local calendar_widget = require("calendar") +local calendar_widget = require("widgets.calendar") local topcalendar = calendar_widget() -local volume_widget = require("volume") +local volume_widget = require("widgets.volume") local volumebar = volume_widget() toptextclock:connect_signal("button::press", @@ -316,7 +316,7 @@ awful.screen.connect_for_each_screen(function(s) } -- Create the wibox - s.mywibox = awful.wibar({ position = "top", screen = s, bg = "#00000000"}) + s.mywibox = awful.wibar({ position = "top", screen = s, bg = "#00000000", border_width = 8,}) s.systray = wibox.widget.systray() s.systray.visible = true @@ -327,11 +327,14 @@ awful.screen.connect_for_each_screen(function(s) expand = "none", { -- Left widgets layout = wibox.layout.fixed.horizontal, - wibox.container.margin(s.mytaglist, 5, 0, 0), + s.mytaglist, s.mypromptbox, }, s.mytasklist, -- Middle widget { -- Right widgets + volumebar, + toptextclock, + wibox.container.margin(s.mylayoutbox, 4, 4, 4, 4), { { layout = wibox.layout.fixed.horizontal, @@ -344,9 +347,6 @@ awful.screen.connect_for_each_screen(function(s) top = 4, bottom = 4 }, - volumebar, - toptextclock, - wibox.container.margin(s.mylayoutbox, 4, 4, 4, 4), }, widget = wibox.container.background, shape = gears.shape.rounded_rect, diff --git a/programs/dotfiles/awesome/theme.lua b/programs/dotfiles/awesome/theme.lua index c2da65a..49fe840 100644 --- a/programs/dotfiles/awesome/theme.lua +++ b/programs/dotfiles/awesome/theme.lua @@ -29,8 +29,8 @@ theme.tag_list_occupied = "#767d98" theme.tag_list_focused = "#cdd6f4" theme.tag_list_urgent = "#f38ba8" -theme.useless_gap = dpi(8) -theme.border_width = dpi(3) +theme.useless_gap = dpi(4) +theme.border_width = dpi(4) theme.border_normal = theme.bg_normal theme.border_focus = theme.bg_focus theme.border_marked = theme.fg_focus @@ -132,12 +132,6 @@ theme.awesome_icon = theme_assets.awesome_icon( -- from /usr/share/icons and /usr/share/icons/hicolor will be used. theme.icon_theme = nil -theme.taglist_text_font = "FiraCode Nerd Font" - -theme.taglist_text_empty = { "", "", "", "", "", "", "", "", "", "" } -theme.taglist_text_occupied = { "", "", "", "", "", "", "", "", "", "" } -theme.taglist_text_focused = { "", "", "", "", "", "", "", "", "", "" } - return theme -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/programs/dotfiles/awesome/volume.lua b/programs/dotfiles/awesome/volume.lua deleted file mode 100644 index 21c200b..0000000 --- a/programs/dotfiles/awesome/volume.lua +++ /dev/null @@ -1,60 +0,0 @@ -local awful = require("awful") -local spawn = require("awful.spawn") -local watch = require("awful.widget.watch") -local beautiful = require("beautiful") -local wibox = require("wibox") -local gears = require("gears") -local naughty = require("naughty") - -local volume_widget = {} - -local get_volume_cmd = "bash -c 'wpctl get-volume @DEFAULT_AUDIO_SINK@'" - -local function worker(user_args) - local volume_bar = wibox.widget { - bar_shape = gears.shape.rounded_rect, - bar_height = 4, - bar_color = beautiful.fg_focus, - handle_color = beautiful.fg_focus, - handle_shape = gears.shape.circle, - handle_border_width = 0, - value = 0, - forced_width = 50, - widget = wibox.widget.slider, - } - - volume_widget = wibox.widget { - { - layout = wibox.layout.fixed.horizontal, - { - text = "󰕾 ", - widget = wibox.widget.textbox - }, - volume_bar, - spacing = 4 - }, - widget = wibox.container.margin, - left = 8, - } - - local function percentage(value) - return math.floor(value) - end - - watch(get_volume_cmd, 1, - function(widget, stdout) - volume = stdout:match('0.%d+') - widget.value = tonumber(volume) * 100 - end, volume_bar) - - volume_bar:connect_signal("property::value", - function(self) - spawn.easy_async("bash -c 'wpctl set-volume @DEFAULT_AUDIO_SINK@ " .. self.value .. "%'", function() end) - end) - - return volume_widget -end - -return setmetatable(volume_widget, { __call = function(_, ...) - return worker(...) -end}) diff --git a/programs/dotfiles/awesome/widgets/calendar.lua b/programs/dotfiles/awesome/widgets/calendar.lua new file mode 100644 index 0000000..6e791b3 --- /dev/null +++ b/programs/dotfiles/awesome/widgets/calendar.lua @@ -0,0 +1,115 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local wibox = require("wibox") +local gears = require("gears") + +local calendar_widget = {} + +local function worker(user_args) + local args = user_args or {} + + local style = {} + + style.month = { + padding = 4, + bg_color = beautiful.bg_normal, + border_width = 0 + } + + style.normal = { + markup = function(t) return t end, + shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end, + } + + style.focused = { + bg_color = beautiful.bg_focus, + fg_color = beautiful.fg_focus, + markup = function(t) return '' .. t .. '' end, + shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end, + } + + style.header = { + bg_color = beautiful.bg_focus, + fg_color = beautiful.fg_focus, + markup = function(t) return ''..t..'' end, + } + + style.weekday = { + bg_color = beautiful.bg_focus, + fg_color = beautiful.fg_focus, + markup = function(t) return ''..t..'' end, + } + + local function decorate(widget, flag, date) + if flag == 'monthheader' then flag = 'header' end + if flag == 'focus' then + local today = os.date('*t') + if not today.month == date.month and today.year == date.year then + flag = 'normal' + end + end + local properties = style[flag] or {} + if properties.markup and widget.get_text and widget.set_markup then + widget:set_markup(properties.markup(widget:get_text())) + end + local thisdate = { year = date.year, month = (date.month or 1), day = (date.day or 1) } + local weekday = tonumber(os.date('%w', os.time(d))) + local default_bg = (weekday == 0 or weekday == 6) + and beautiful.bg_focused + or beautiful.bg_normal + return wibox.widget { + { + { + widget, + halign = 'center', + widget = wibox.container.place + }, + margins = (properties.padding or 2) + (properties.border_width or 0), + widget = wibox.container.margin + }, + shape = properties.shape, + shape_border_color = properties.border_color or '#00000000', + shape_border_width = properties.border_width or 0, + fg = properties.fg_color or beautiful.fg_normal, + bg = properties.bg_color or beautiful.bg_normal, + widget = wibox.container.background + } + end + + local cal = wibox.widget { + date = os.date('*t'), + font = beautiful.get_font(), + fn_embed = decorate, + long_weekdays = true, + start_sunday = true, + widget = wibox.widget.calendar.month + } + + local popup = awful.popup { + ontop = true, + visible = false, + shape = gears.shape.rounded_rect, + offset = { y = 5 }, + border_width = 2, + border_color = beautiful.fg_minimize, + widget = cal + } + + function calendar_widget.toggle() + if popup.visible then + cal:set_date(nil) + cal:set_date(os.date('*t')) + popup:set_widget(nil) + popup:set_widget(cal) + popup.visible = not popup.visible + else + awful.placement.top_right(popup, { margins = { top = 30, right = 10 }, parent = awful.screen.focused() }) + popup.visible = true + end + end + return calendar_widget +end + +return setmetatable(calendar_widget, { __call = function(_, ...) + return worker(...) +end}) diff --git a/programs/dotfiles/awesome/widgets/volume.lua b/programs/dotfiles/awesome/widgets/volume.lua new file mode 100644 index 0000000..21c200b --- /dev/null +++ b/programs/dotfiles/awesome/widgets/volume.lua @@ -0,0 +1,60 @@ +local awful = require("awful") +local spawn = require("awful.spawn") +local watch = require("awful.widget.watch") +local beautiful = require("beautiful") +local wibox = require("wibox") +local gears = require("gears") +local naughty = require("naughty") + +local volume_widget = {} + +local get_volume_cmd = "bash -c 'wpctl get-volume @DEFAULT_AUDIO_SINK@'" + +local function worker(user_args) + local volume_bar = wibox.widget { + bar_shape = gears.shape.rounded_rect, + bar_height = 4, + bar_color = beautiful.fg_focus, + handle_color = beautiful.fg_focus, + handle_shape = gears.shape.circle, + handle_border_width = 0, + value = 0, + forced_width = 50, + widget = wibox.widget.slider, + } + + volume_widget = wibox.widget { + { + layout = wibox.layout.fixed.horizontal, + { + text = "󰕾 ", + widget = wibox.widget.textbox + }, + volume_bar, + spacing = 4 + }, + widget = wibox.container.margin, + left = 8, + } + + local function percentage(value) + return math.floor(value) + end + + watch(get_volume_cmd, 1, + function(widget, stdout) + volume = stdout:match('0.%d+') + widget.value = tonumber(volume) * 100 + end, volume_bar) + + volume_bar:connect_signal("property::value", + function(self) + spawn.easy_async("bash -c 'wpctl set-volume @DEFAULT_AUDIO_SINK@ " .. self.value .. "%'", function() end) + end) + + return volume_widget +end + +return setmetatable(volume_widget, { __call = function(_, ...) + return worker(...) +end}) diff --git a/programs/virt-manager.nix b/programs/virt-manager.nix new file mode 100644 index 0000000..b2f3de5 --- /dev/null +++ b/programs/virt-manager.nix @@ -0,0 +1,16 @@ +{ pkgs, username, ... }: +{ + dconf.settings = { + "org/virt-manager/virt-manager/connections" = { + autoconnect = ["qemu:///system"]; + uris = ["qemu:///system"]; + }; + }; + + xdg.configFile."libvirt/qemu.conf".text = '' +nvram = [ + "/run/libvirt/nix-ovmf/AAVMF_CODE.fd:/run/libvirt/nix-ovmf/AAVMF_VARS.fd", + "/run/libvirt/nix-ovmf/OVMF_CODE.fd:/run/libvirt/nix-ovmf/OVMF_VARS.fd" +] + ''; +} diff --git a/systems/default.nix b/systems/default.nix index 1cd1037..94bb592 100644 --- a/systems/default.nix +++ b/systems/default.nix @@ -12,11 +12,13 @@ ../programs/openvpn.nix ]; + #Default boot parameters. boot = { tmp.cleanOnBoot = true; initrd.verbose = false; }; + #Nix package manager configs. nix = { registry = lib.mapAttrs (_: value: {flake = value;}) inputs; @@ -30,17 +32,19 @@ gc = { automatic = true; dates = "weekly"; - options = "--delete-older-than 7d" + options = "--delete-older-than 7d"; }; }; + #Networking networking.hostName = hostname; # Define your hostname. networking.useDHCP = lib.mkDefault true; networking.networkmanager.enable = true; - # Set your time zone. + #Timezone time.timeZone = "America/New_York"; + #Locale & Fonts i18n.defaultLocale = "en_US.UTF-8"; i18n.extraLocaleSettings = { LC_ADDRESS = "en_US.UTF-8"; @@ -53,27 +57,17 @@ LC_TELEPHONE = "en_US.UTF-8"; LC_TIME = "en_US.UTF-8"; }; - - # Configure X11 - services.xserver = { - enable = true; - layout = "us"; - xkbVariant = ""; - - displayManager = { - sddm.enable = true; - defaultSession = "none+awesome"; - }; - - windowManager.awesome = { - enable = true; - luaModules = with pkgs.luaPackages; [ - luarocks - luadbi-mysql - ]; - }; - }; - + fonts.packages = with pkgs; [ + fira-code + fira-code-symbols + font-awesome + liberation_ttf + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + (nerdfonts.override { fonts = [ "FiraCode" ]; } ) + ]; + services.pipewire = { enable = true; alsa.enable = true; @@ -81,12 +75,12 @@ pulse.enable = true; }; + #Security security.rtkit.enable = true; + security.polkit.enable = true; - # List packages installed in system profile. To search, run: - # $ nix search wget + #Default packages for QOL environment.systemPackages = with pkgs; [ - arandr binutils clang-tools gcc @@ -96,26 +90,14 @@ unzip wget ]; - - fonts.packages = with pkgs; [ - fira-code - fira-code-symbols - font-awesome - liberation_ttf - noto-fonts - noto-fonts-cjk - noto-fonts-emoji - (nerdfonts.override { fonts = [ "FiraCode" ]; } ) - ]; - programs.zsh.enable = true; users.defaultUserShell = pkgs.zsh; - programs.neovim = { enable = true; defaultEditor = true; }; + #MPD services.mpd = { enable = true; musicDirectory = "/var/mus"; @@ -131,19 +113,14 @@ audio_output { network.listenAddress = "any"; }; - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; + #GPG programs.gnupg.agent = { enable = true; enableSSHSupport = true; }; - # List services that you want to enable: - - # Enable the OpenSSH daemon. + #SSH services.openssh.enable = true; - environment.shellInit = '' gpg-connect-agent /bye export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) diff --git a/systems/jonbox/default.nix b/systems/jonbox/default.nix index 16cf6a2..c894497 100644 --- a/systems/jonbox/default.nix +++ b/systems/jonbox/default.nix @@ -8,6 +8,7 @@ ../bluetooth.nix ]; + #Unfree-packages. nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "nvidia-x11" @@ -15,6 +16,7 @@ "nvidia-persistenced" ]; + #Bootloader boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; @@ -23,14 +25,38 @@ boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; + #SSD-optimization + services.fstrim.enable = true; + + #OpenGL hardware.opengl = { enable = true; driSupport = true; driSupport32Bit = true; }; + + #X11 Server + services.xserver = { + enable = true; + layout = "us"; + xkbVariant = ""; + videoDrivers = [ "nvidia" ]; - services.xserver.videoDrivers = [ "nvidia" ]; + displayManager = { + sddm.enable = true; + defaultSession = "none+awesome"; + }; + windowManager.awesome = { + enable = true; + luaModules = with pkgs.luaPackages; [ + luarocks + luadbi-mysql + ]; + }; + }; + + #NVidia hardware.nvidia = { modesetting.enable = true; powerManagement.enable = false; @@ -40,8 +66,14 @@ package = config.boot.kernelPackages.nvidiaPackages.stable; }; - services.fstrim.enable = true; - nix.settings.auto-optimize-store = true; + #Virtualization + virtualisation.libvirtd.enable = true; + programs.dconf.enable = true; + environment.systemPackages = with pkgs; [ + virt-manager + libguestfs + guestfs-tools + ]; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; diff --git a/users/jon.nix b/users/jon.nix index da8c84e..92c4bd1 100644 --- a/users/jon.nix +++ b/users/jon.nix @@ -7,6 +7,7 @@ "networkmanager" "wheel" "video" + "libvirtd" ]; packages = with pkgs; []; }; -- cgit v1.2.1