diff --git a/flake.lock b/flake.lock index e44ce2d..698a63a 100644 --- a/flake.lock +++ b/flake.lock @@ -256,7 +256,234 @@ "type": "github" } }, + "hyprcursor": { + "inputs": { + "hyprlang": [ + "hyprland", + "hyprlang" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1720108799, + "narHash": "sha256-AxRkTJlbB8r7aG6gvc7IaLhc2T9TO4/8uqanKRxukBQ=", + "owner": "hyprwm", + "repo": "hyprcursor", + "rev": "a5c0d57325c5f0814c39110a70ca19c070ae9486", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprcursor", + "type": "github" + } + }, + "hyprland": { + "inputs": { + "hyprcursor": "hyprcursor", + "hyprlang": "hyprlang", + "hyprutils": "hyprutils", + "hyprwayland-scanner": "hyprwayland-scanner", + "nixpkgs": "nixpkgs", + "systems": "systems", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1720731503, + "narHash": "sha256-Qlm0IRnOrI64RW/SEvW9rA1ytVvPS1CsVvRataNvStI=", + "ref": "refs/heads/main", + "rev": "e728e56cbc6af0a9be1276b2cf8e019a894016e7", + "revCount": 4917, + "submodules": true, + "type": "git", + "url": "https://github.com/hyprwm/Hyprland" + }, + "original": { + "submodules": true, + "type": "git", + "url": "https://github.com/hyprwm/Hyprland" + } + }, + "hyprland-hyprspace": { + "inputs": { + "hyprland": [ + "hyprland" + ] + }, + "locked": { + "lastModified": 1720553729, + "narHash": "sha256-9aM4MCBJn4UstcsSdukOFTxg79keUMTw9Kmqr7Wsfmw=", + "owner": "KZDKM", + "repo": "Hyprspace", + "rev": "e8662093ae5b6e13a3cf1145d21d4804a3e84aeb", + "type": "github" + }, + "original": { + "owner": "KZDKM", + "repo": "Hyprspace", + "type": "github" + } + }, + "hyprland-plugins": { + "inputs": { + "hyprland": [ + "hyprland" + ], + "nixpkgs": [ + "hyprland-plugins", + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland-plugins", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1719784423, + "narHash": "sha256-D7O5+nh2Wn9tQPJArWHrDSZeEfBCtj5zTGd86701LPE=", + "owner": "hyprwm", + "repo": "hyprland-plugins", + "rev": "98cb18c6fcfe8196ef4150d09fbae305b7bb2954", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-plugins", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "hyprland", + "xdph", + "nixpkgs" + ], + "systems": [ + "hyprland", + "xdph", + "systems" + ] + }, + "locked": { + "lastModified": 1718746314, + "narHash": "sha256-HUklK5u86w2Yh9dOkk4FdsL8eehcOZ95jPhLixGDRQY=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "1b61f0093afff20ab44d88ad707aed8bf2215290", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "hyprlang": { + "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1720381373, + "narHash": "sha256-lyC/EZdHULsaAKVryK11lgHY9u6pXr7qR4irnxNWC7k=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "5df0174fd09de4ac5475233d65ffc703e89b82eb", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, + "hyprutils": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1720545076, + "narHash": "sha256-Pxacc2uoxI00koXp5+CyNqHOTQlqNlK0rlRHDBHX4+g=", + "owner": "hyprwm", + "repo": "hyprutils", + "rev": "6174a2a25f4e216c0f1d0c4278adc23c476b1d09", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprutils", + "type": "github" + } + }, + "hyprwayland-scanner": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1720215857, + "narHash": "sha256-JPdL+Qul+jEueAn8CARfcWP83eJgwkhMejQYfDvrgvU=", + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "rev": "d5fa094ca27e0039be5e94c0a80ae433145af8bb", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1720542800, + "narHash": "sha256-ZgnNHuKV6h2+fQ5LuqnUaqZey1Lqqt5dTUAiAnqH0QQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "feb2849fdeb70028c70d73b848214b00d324a497", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1719690277, "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=", @@ -272,7 +499,7 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_3": { "locked": { "lastModified": 1714912032, "narHash": "sha256-clkcOIkg8G4xuJh+1onLG4HPMpbtzdLv4rHxFzgsH9c=", @@ -293,7 +520,10 @@ "aagl": "aagl", "catppuccin": "catppuccin", "home-manager": "home-manager", - "nixpkgs": "nixpkgs", + "hyprland": "hyprland", + "hyprland-hyprspace": "hyprland-hyprspace", + "hyprland-plugins": "hyprland-plugins", + "nixpkgs": "nixpkgs_2", "stylix": "stylix" } }, @@ -309,7 +539,7 @@ "flake-compat": "flake-compat_2", "gnome-shell": "gnome-shell", "home-manager": "home-manager_2", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1719525570, @@ -324,6 +554,51 @@ "repo": "stylix", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": "hyprland-protocols", + "hyprlang": [ + "hyprland", + "hyprlang" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1720194466, + "narHash": "sha256-Rizg9efi6ue95zOp0MeIV2ZedNo+5U9G2l6yirgBUnA=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "b9b97e5ba23fe7bd5fa4df54696102e8aa863cf6", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 6f11ee6..916e5c7 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,18 @@ url = "github:ezKEa/aagl-gtk-on-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; + + hyprland-plugins = { + url = "github:hyprwm/hyprland-plugins"; + inputs.hyprland.follows = "hyprland"; + }; + + hyprland-hyprspace = { + url = "github:KZDKM/Hyprspace"; + inputs.hyprland.follows = "hyprland"; + }; }; outputs = { self, nixpkgs, ... }@inputs: diff --git a/hosts/default/configuration.nix b/hosts/default/configuration.nix index 2d4a69a..b53aa13 100644 --- a/hosts/default/configuration.nix +++ b/hosts/default/configuration.nix @@ -82,7 +82,7 @@ users.users.shoi = { isNormalUser = true; description = "Sho Ishida"; - extraGroups = [ "networkmanager" "wheel" "input" ]; + extraGroups = [ "networkmanager" "wheel" "input" "audio" ]; shell = pkgs.zsh; }; @@ -105,6 +105,8 @@ environment.systemPackages = with pkgs; [ # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. lm_sensors + brightnessctl + inotify-tools ]; # Some programs need SUID wrappers, can be configured further or are diff --git a/hosts/default/home.nix b/hosts/default/home.nix index 1d32df7..09af357 100644 --- a/hosts/default/home.nix +++ b/hosts/default/home.nix @@ -22,16 +22,22 @@ # For funsies spotify vesktop + ncmpcpp + mpd + mpdris2 # Other utility mullvad-vpn transmission_4-gtk imagemagick + neofetch ]; # Enable sound control services.easyeffects.enable = true; + services.playerctld.enable = true; + # Home Manager is pretty good at managing dotfiles. The primary way to manage # plain files is through 'home.file'. home.file = { diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 870303e..d9fc914 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -28,6 +28,7 @@ # Utils corefonts noto-fonts + flameshot ]; programs.firefox.enable = true; diff --git a/modules/home-manager/ricing/awesomewm/default.nix b/modules/home-manager/ricing/awesomewm/default.nix new file mode 100644 index 0000000..1fba72c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + home.file.".config/awesome" = { + recursive = true; + source = ./dotfiles; + }; +} \ No newline at end of file diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/helpers.lua b/modules/home-manager/ricing/awesomewm/dotfiles/helpers.lua new file mode 100644 index 0000000..7b500ee --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/helpers.lua @@ -0,0 +1,230 @@ +local helpers = {} +local awful = require("awful") +local beautiful = require("beautiful") +local gears = require("gears") +local dpi = beautiful.xresources.apply_dpi +local cairo = require("lgi").cairo +local gmatrix = require("gears.matrix") +local json = require("mods.json") + +helpers.rrect = function(radius) + radius = radius or dpi(4) + return function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, radius) + end +end + +helpers.addHover = function(element, bg, hbg) + element:connect_signal('mouse::enter', function(self) + self.bg = hbg + end) + element:connect_signal('mouse::leave', function(self) + self.bg = bg + end) +end + +helpers.placeWidget = function(widget) + if beautiful.barDir == 'left' then + awful.placement.bottom_left(widget, { honor_workarea = true, margins = beautiful.useless_gap * 2 }) + elseif beautiful.barDir == 'right' then + awful.placement.bottom_right(widget, { honor_workarea = true, margins = beautiful.useless_gap * 2 }) + elseif beautiful.barDir == 'bottom' then + awful.placement.bottom(widget, { honor_workarea = true, margins = beautiful.useless_gap * 2 }) + elseif beautiful.barDir == 'top' then + awful.placement.top(widget, { honor_workarea = true, margins = beautiful.useless_gap * 2 }) + end +end + +helpers.prect = function(tl, tr, br, bl, radius) + radius = radius or dpi(4) + return function(cr, width, height) + gears.shape.partially_rounded_rect(cr, width, height, tl, tr, br, bl, radius) + end +end + +helpers.clickKey = function(c, key) + awful.spawn.with_shell("xdotool type --window " .. tostring(c.window) .. " '" .. key .. "'") +end + +helpers.colorizeText = function(txt, fg) + if fg == "" then + fg = "#ffffff" + end + + return "" .. txt .. "" +end + +helpers.cropSurface = function(ratio, surf) + local old_w, old_h = gears.surface.get_size(surf) + local old_ratio = old_w / old_h + if old_ratio == ratio then return surf end + + local new_h = old_h + local new_w = old_w + local offset_h, offset_w = 0, 0 + -- quick mafs + if (old_ratio < ratio) then + new_h = math.ceil(old_w * (1 / ratio)) + offset_h = math.ceil((old_h - new_h) / 2) + else + new_w = math.ceil(old_h * ratio) + offset_w = math.ceil((old_w - new_w) / 2) + end + + local out_surf = cairo.ImageSurface(cairo.Format.ARGB32, new_w, new_h) + local cr = cairo.Context(out_surf) + cr:set_source_surface(surf, -offset_w, -offset_h) + cr.operator = cairo.Operator.SOURCE + cr:paint() + + return out_surf +end + +helpers.inTable = function(t, v) + for _, value in ipairs(t) do + if value == v then + return true + end + end + + return false +end + + +helpers.generateId = function() + local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' + return string.gsub(template, '[xy]', function(c) + local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb) + return string.format('%x', v) + end) +end + +helpers.find_last = function(haystack, needle) + -- Set the third arg to false to allow pattern matching + local found = haystack:reverse():find(needle:reverse(), nil, true) + if found then + return haystack:len() - needle:len() - found + 2 + else + return found + end +end + + + +helpers.addTables = function(a, b) + local result = {} + for _, v in pairs(a) do + table.insert(result, v) + end + for _, v in pairs(b) do + table.insert(result, v) + end + return result +end + +helpers.hasKey = function(set, key) + return set[key] ~= nil +end + +helpers.trim = function(string) + return string:gsub("^%s*(.-)%s*$", "%1") +end +helpers.indexOf = function(array, value) + for i, v in ipairs(array) do + if v == value then + return i + end + end + return nil +end + +helpers.split = function(inputstr, sep) + if sep == nil then + sep = "%s" + end + local t = {} + for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do + table.insert(t, str) + end + return t +end + +helpers.readFile = function(file) + local f = assert(io.open(file, "rb")) + local content = f:read("*all") + f:close() + return content +end + +helpers.file_exists = function(name) + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + else + return false + end +end + +local function get_widget_geometry(_hierarchy, widget) + local width, height = _hierarchy:get_size() + if _hierarchy:get_widget() == widget then + -- Get the extents of this widget in the device space + local x, y, w, h = gmatrix.transform_rectangle(_hierarchy:get_matrix_to_device(), 0, 0, width, height) + return { x = x, y = y, width = w, height = h, hierarchy = _hierarchy } + end + + for _, child in ipairs(_hierarchy:get_children()) do + local ret = get_widget_geometry(child, widget) + if ret then + return ret + end + end +end + +function helpers.get_widget_geometry(wibox, widget) + return get_widget_geometry(wibox._drawable._widget_hierarchy, widget) +end + +function helpers.randomColor() + local accents = { + beautiful.magenta, + beautiful.yellow, + beautiful.green, + beautiful.red, + beautiful.blue, + } + + local i = math.random(1, #accents) + return accents[i] +end + +helpers.readJson = function(DATA) + if helpers.file_exists(DATA) then + local f = assert(io.open(DATA, "rb")) + local lines = f:read("*all") + f:close() + local data = json.decode(lines) + return data + else + return {} + end +end + +helpers.writeJson = function(PATH, DATA) + local w = assert(io.open(PATH, "w")) + w:write(json.encode(DATA, nil, { pretty = true, indent = " ", align_keys = false, array_newline = true })) + w:close() +end + +-- this stands for :get_children_by_id +helpers.gc = function(widget, id) + return widget:get_children_by_id(id)[1] +end + +helpers.beginsWith = function(str, pattern) + return str:find('^' .. pattern) ~= nil +end + + +return helpers \ No newline at end of file diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/lib/brightness.lua b/modules/home-manager/ricing/awesomewm/dotfiles/lib/brightness.lua new file mode 100644 index 0000000..19159c1 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/lib/brightness.lua @@ -0,0 +1,21 @@ +local awful = require "awful" + +local brightness = {} + +brightness.increase = function() + local script = [[ + brightnessctl set 3%+ + ]] + + awful.spawn.with_shell(script) +end + +brightness.decrease = function() + local script = [[ + brightnessctl set 3%- + ]] + + awful.spawn.with_shell(script) +end + +return brightness diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/lib/volume.lua b/modules/home-manager/ricing/awesomewm/dotfiles/lib/volume.lua new file mode 100644 index 0000000..15374ba --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/lib/volume.lua @@ -0,0 +1,29 @@ +local awful = require "awful" + +local volume = {} + +volume.increase = function() + local script = [[ + pamixer -i 3 + ]] + + awful.spawn.with_shell(script) +end + +volume.decrease = function() + local script = [[ + pamixer -d 3 + ]] + + awful.spawn.with_shell(script) +end + +volume.mute = function() + local script = [[ + pamixer -t + ]] + + awful.spawn.with_shell(script) +end + +return volume diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/liblua_pam.so b/modules/home-manager/ricing/awesomewm/dotfiles/liblua_pam.so new file mode 100644 index 0000000..fb05778 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/liblua_pam.so differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/apps.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/apps.lua new file mode 100644 index 0000000..44ca779 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/apps.lua @@ -0,0 +1,8 @@ +local apps = { + terminal = "wezterm", + launcher = "rofi -show drun", + browser = "firefox", + fileManager = "thunar", +} + +return apps diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/autorun.sh b/modules/home-manager/ricing/awesomewm/dotfiles/main/autorun.sh new file mode 100644 index 0000000..9f1bce9 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/autorun.sh @@ -0,0 +1,6 @@ +#!/bin/bash +mpDris2 & +xrdb -merge ~/.Xresources +picom --config $HOME/.config/picom/picom.conf +xss-lock lock +mkdir -p ~/.cache/awesome/json/ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/bindings/bindings.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/bindings/bindings.lua new file mode 100644 index 0000000..be0fe18 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/bindings/bindings.lua @@ -0,0 +1,230 @@ +local awful = require "awful" +local gears = require "gears" +local naughty = require "naughty" +local beautiful = require "beautiful" + +local apps = require "main.apps" + +modkey = "Mod4" + +-- General awesome keybindings +awful.keyboard.append_global_keybindings({ + awful.key({ modkey, "Control" }, "r", awesome.restart, + { description = "reload awesome", group = "awesome" }), + awful.key({ modkey, "Shift" }, "q", awesome.quit, + { description = "quit awesome", group = "awesome" }), + awful.key({ modkey, }, "Return", function() awful.spawn(apps.terminal) end, + { description = "open a terminal", group = "launcher" }), +}) + +-- Tag bindings +awful.keyboard.append_global_keybindings({ + awful.key({ modkey, }, "Left", awful.tag.viewprev, + { description = "view previous", group = "tag" }), + awful.key({ modkey, }, "Right", awful.tag.viewnext, + { description = "view next", group = "tag" }), + awful.key({ modkey, }, "Escape", awful.tag.history.restore, + { description = "go back", group = "tag" }), +}) + +awful.keyboard.append_global_keybindings({ + awful.key { + modifiers = { modkey }, + keygroup = "numrow", + description = "only view tag", + group = "tag", + on_press = function(index) + local screen = awful.screen.focused() + local tag = screen.tags[index] + if tag then + tag:view_only() + end + end, + }, + awful.key { + modifiers = { modkey, "Control" }, + keygroup = "numrow", + description = "toggle tag", + group = "tag", + on_press = function(index) + local screen = awful.screen.focused() + local tag = screen.tags[index] + if tag then + awful.tag.viewtoggle(tag) + end + end, + }, + awful.key { + modifiers = { modkey, "Shift" }, + keygroup = "numrow", + description = "move focused client to tag", + group = "tag", + on_press = function(index) + if client.focus then + local tag = client.focus.screen.tags[index] + if tag then + client.focus:move_to_tag(tag) + end + end + end, + }, + awful.key { + modifiers = { modkey, "Control", "Shift" }, + keygroup = "numrow", + description = "toggle focused client on tag", + group = "tag", + on_press = function(index) + if client.focus then + local tag = client.focus.screen.tags[index] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + }, + awful.key { + modifiers = { modkey }, + keygroup = "numpad", + description = "select layout directly", + group = "layout", + on_press = function(index) + local t = awful.screen.focused().selected_tag + if t then + t.layout = t.layouts[index] or t.layout + end + end, + } +}) + +-- Focus bindings +awful.keyboard.append_global_keybindings({ + awful.key({ modkey, }, "j", + function() + awful.client.focus.byidx(1) + end, + { description = "focus next by index", group = "client" } + ), + awful.key({ modkey, }, "k", + function() + awful.client.focus.byidx(-1) + end, + { description = "focus previous by index", group = "client" } + ), + awful.key({ modkey, }, "Tab", + function() + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, + { description = "go back", group = "client" }), + awful.key({ modkey, "Control" }, "j", function() awful.screen.focus_relative(1) end, + { description = "focus the next screen", group = "screen" }), + awful.key({ modkey, "Control" }, "k", function() awful.screen.focus_relative(-1) end, + { description = "focus the previous screen", group = "screen" }), + awful.key({ modkey, "Control" }, "n", + function() + local c = awful.client.restore() + -- Focus restored client + if c then + c:activate { raise = true, context = "key.unminimize" } + end + end, + { description = "restore minimized", group = "client" }), +}) + +-- Layout bindings +awful.keyboard.append_global_keybindings({ + awful.key({ modkey, "Shift" }, "j", function() awful.client.swap.byidx(1) end, + { description = "swap with next client by index", group = "client" }), + awful.key({ modkey, "Shift" }, "k", function() awful.client.swap.byidx(-1) end, + { description = "swap with previous client by index", group = "client" }), + awful.key({ modkey, }, "u", awful.client.urgent.jumpto, + { description = "jump to urgent client", group = "client" }), + awful.key({ modkey, }, "l", function() awful.tag.incmwfact(0.05) end, + { description = "increase master width factor", group = "layout" }), + awful.key({ modkey, }, "h", function() awful.tag.incmwfact(-0.05) end, + { description = "decrease master width factor", group = "layout" }), + awful.key({ modkey, "Shift" }, "h", function() awful.tag.incnmaster(1, nil, true) end, + { description = "increase the number of master clients", group = "layout" }), + awful.key({ modkey, "Shift" }, "l", function() awful.tag.incnmaster(-1, nil, true) end, + { description = "decrease the number of master clients", group = "layout" }), + awful.key({ modkey, "Control" }, "h", function() awful.tag.incncol(1, nil, true) end, + { description = "increase the number of columns", group = "layout" }), + awful.key({ modkey, "Control" }, "l", function() awful.tag.incncol(-1, nil, true) end, + { description = "decrease the number of columns", group = "layout" }), + awful.key({ modkey, }, "space", function() awful.layout.inc(1) end, + { description = "select next", group = "layout" }), + awful.key({ modkey, "Shift" }, "space", function() awful.layout.inc(-1) end, + { description = "select previous", group = "layout" }), +}) + +-- Client bindings +client.connect_signal("request::default_keybindings", function() + awful.keyboard.append_client_keybindings({ + awful.key({ modkey, }, "f", + function(c) + c.fullscreen = not c.fullscreen + c:raise() + end, + { description = "toggle fullscreen", group = "client" }), + awful.key({ modkey, "Shift" }, "c", function(c) c:kill() end, + { description = "close", group = "client" }), + awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle, + { description = "toggle floating", group = "client" }), + awful.key({ modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end, + { description = "move to master", group = "client" }), + awful.key({ modkey, }, "o", function(c) c:move_to_screen() end, + { description = "move to screen", group = "client" }), + awful.key({ modkey, }, "t", function(c) c.ontop = not c.ontop end, + { description = "toggle keep on top", group = "client" }), + awful.key({ modkey, }, "n", + function(c) + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true + end, + { description = "minimize", group = "client" }), + awful.key({ modkey, }, "m", + function(c) + c.maximized = not c.maximized + c:raise() + end, + { description = "(un)maximize", group = "client" }), + awful.key({ modkey, "Control" }, "m", + function(c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end, + { description = "(un)maximize vertically", group = "client" }), + awful.key({ modkey, "Shift" }, "m", + function(c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end, + { description = "(un)maximize horizontally", group = "client" }), + }) +end) + +-- Mouse bindings +local menu = require("ui.rightclick") +awful.mouse.append_global_mousebindings({ + awful.button({}, 3, function() + menu.desktop:toggle() + return + end), +}) + +client.connect_signal("request::default_mousebindings", function() + awful.mouse.append_client_mousebindings({ + awful.button({}, 1, function(c) + c:activate { context = "mouse_click" } + end), + awful.button({ modkey }, 1, function(c) + c:activate { context = "mouse_click", action = "mouse_move" } + end), + awful.button({ modkey }, 3, function(c) + c:activate { context = "mouse_click", action = "mouse_resize" } + end), + }) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/bindings/custom_bindings.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/bindings/custom_bindings.lua new file mode 100644 index 0000000..835cfab --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/bindings/custom_bindings.lua @@ -0,0 +1,45 @@ +local awful = require "awful" + +local volume = require "lib.volume" +local brightness = require "lib.brightness" + +-- Volume +awful.keyboard.append_global_keybindings({ + awful.key({}, "XF86AudioRaiseVolume", function() + volume.increase() + awesome.emit_signal("open::osd") + end), + awful.key({}, "XF86AudioLowerVolume", function() + volume.decrease() + awesome.emit_signal("open::osd") + end), + awful.key({}, "XF86AudioMute", function() + volume.mute() + awesome.emit_signal("open::osd") + end) +}) + +-- Brightness +awful.keyboard.append_global_keybindings({ + awful.key({}, "XF86MonBrightnessUp", function() + brightness.increase() + awesome.emit_signal("open::osdb") + end), + + awful.key({}, "XF86MonBrightnessDown", function() + brightness.decrease() + awesome.emit_signal("open::osdb") + end), + awful.key({ modkey, }, "a", + function(c) + awesome.emit_signal("toggle::launcher") + end), + awful.key({ modkey, }, "x", + function(c) + awesome.emit_signal("toggle::exit") + end), + awful.key({ modkey, }, "q", + function(c) + awesome.emit_signal("toggle::scrotter") + end), +}) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/error_handling.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/error_handling.lua new file mode 100644 index 0000000..8e2f91c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/error_handling.lua @@ -0,0 +1,9 @@ +local naughty = require "naughty" + +naughty.connect_signal("request::display_error", function(message, startup) + naughty.notification { + urgency = "critical", + title = "Oops, an error happened"..(startup and " during startup!" or "!"), + message = message + } +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/init.lua new file mode 100644 index 0000000..f1e86c9 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/init.lua @@ -0,0 +1,10 @@ +-- init config +require "main.wallpaper" +require "main.layout" +require "main.rules" +require "main.bindings.bindings" +require "main.bindings.custom_bindings" +require "main.tags" +require "main.swallow" +require "main.error_handling" +require "main.scratch" diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/layout.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/layout.lua new file mode 100644 index 0000000..fd9c661 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/layout.lua @@ -0,0 +1,16 @@ +local awful = require "awful" +local gears = require "gears" +local beautiful = require "beautiful" + +awful.layout.layouts = { + awful.layout.suit.tile, + awful.layout.suit.floating, +} + +client.connect_signal("mouse::enter", function(c) + c:activate { context = "mouse_enter", raise = false } +end) + +client.connect_signal("manage", function(c) + if awesome.startup then awful.client.setslave(c) end +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/rules.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/rules.lua new file mode 100644 index 0000000..0e7dd9f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/rules.lua @@ -0,0 +1,35 @@ +local awful = require "awful" +local gears = require "gears" +local ruled = require "ruled" + +ruled.client.connect_signal("request::rules", function() + ruled.client.append_rule { + id = "global", + rule = {}, + properties = { + focus = awful.client.focus.filter, + raise = true, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap + awful.placement.no_offscreen, + }, + } + + ruled.client.append_rule { + id = "titlebars", + rule_any = { + type = { "normal", "dialog" }, + }, + properties = { + titlebars_enabled = true + } + } + ruled.client.append_rule { + id = "desktop", + rule_any = { + class = { + "Nemo-desktop" + } + }, + properties = { sticky = true, tag = " " } + } +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/scratch.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/scratch.lua new file mode 100644 index 0000000..fbd98da --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/scratch.lua @@ -0,0 +1,162 @@ +local awful = require("awful") +local gears = require("gears") +local beautiful = require("beautiful") +local ruled = require("ruled") + + +local Scratchpad = { mt = {} } -- scratch init + +-- make a new instance of scratchpad +function Scratchpad:new(args) + local ret = gears.object {} + gears.table.crush(ret, Scratchpad) + gears.table.crush(ret, args) + return ret +end + +local findClient = function(rule) + local function matcher(c) + return awful.rules.match(c, rule) + end + local clients = client.get() + local findex = gears.table.hasitem(clients, client.focus) or 1 + local start = gears.math.cycle(#clients, findex + 1) + + local matches = {} + for c in awful.client.iterate(matcher, start) do + matches[#matches + 1] = c + end + + return matches +end + +function Scratchpad:find() + return findClient(self.rule) +end + +function Scratchpad:become(c) + if not c or not c.valid then return end + c.floating = true + c.sticky = false + c.fullscreen = false + c.maximised = false + c:geometry({ + x = (1920 - self.width) / 2, + y = (1080 - self.height) / 2, + width = self.width, + height = self.height + }) +end + +function on(c) + local current_tag = c.screen.selected_tag + ctags = { current_tag } + for k, tag in pairs(c:tags()) do + if tag ~= current_tag then + table.insert(ctags, tag) + end + end + c:tags(ctags) + c:raise() + client.focus = c +end + +function Scratchpad:on() + self.client = self:find()[1] + if not self.client then + local pid = awful.spawn.with_shell(self.command) + ruled.client.append_rule({ + id = "scratch", + rule = self.rule, + properties = { + tag = awful.screen.focused().selected_tag, + switch_to_tags = false, + hidden = true, + minimized = true, + }, + callback = function(c) + gears.timer({ + timeout = 0.1, + autostart = true, + single_shot = true, + callback = function() + self.client = c + self:become(c) + c.hidden = false + c.minimized = false + + c:activate({}) + self:emit_signal("inital_apply", c) + if c.name ~= "Discord Updater" then + ruled.client.remove_rule("scratch") + end + c:connect_signal("request::unmanage", function() + ruled.client.remove_rule("scratch") + end) + end + }) + end + }) + else + self.client:raise() + client.focus = self.client + on(self.client) + self:become(self.client) + end +end + +function turn_off(c) + current_tag = c.screen.selected_tag + local ctags = {} + for k, tag in pairs(c:tags()) do + if tag ~= current_tag then + table.insert(ctags, tag) + end + end + c:tags(ctags) + c.sticky = false +end + +function Scratchpad:off() + self.client = self:find()[1] + turn_off(self.client) +end + +function Scratchpad:toggle() + local is_turn_off = client.focus and awful.rules.match(client.focus, self.rule) + if is_turn_off then + self:off() + else + self:on() + end +end + +function Scratchpad.mt:__call(...) + return Scratchpad:new(...) +end + +local createScratch = function(command, width, height, k) + local scratch = Scratchpad:new { + --command = 'kitty' .. ' --class "' .. command .. 'pad" -e sh -c "' .. command .. '; $SHELL"', + command = 'wezterm start --class ' .. command .. 'pad -e sh -c "' .. command .. '; $SHELL"', + rule = { class = command .. 'pad' }, + height = height, + width = width, + } + awful.keyboard.append_global_keybindings { + awful.key { + modifiers = { "Mod4" }, + key = k, + description = 'show help', + group = 'awesome', + on_press = function() scratch:toggle() end, + }, + } + awesome.connect_signal("toggle::" .. command .. "pad", function() + scratch:toggle() + end) + return scratch +end + +local default = createScratch("clear", 1000, 650, 'v') +local ncmpcpp = createScratch("ncmpcpp", 800, 500, 'z') diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/swallow.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/swallow.lua new file mode 100644 index 0000000..8288b09 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/swallow.lua @@ -0,0 +1,83 @@ +-- documenting my shit because someone thought i write good code +local awful = require("awful") +local helpers = require("helpers") +local dontSuckMe = {} -- this is for classes that you dont want to be swallowed +-- eg local dontSuckMe = {"nemo", "firefox"} + +local checkForSucc = function(child, parent) + local canSuc = false + if not helpers.inTable(dontSuckMe, child) and parent == "org.wezfurlong.wezterm" and child ~= "org.wezfurlong.wezterm" then -- write the class of your terminal here + canSuc = true + end + return canSuc +end + +-- get the terminal window that executed the command maybe +local getDaddy = function(child, cb) + awful.spawn.easy_async(string.format("pstree -p %s", child), function(output, _, _, _) + cb(nil, output) + end) +end + +-- this function was straight out ripped from bling +-- from what i understand this basically makes the window focused and on top +function on(c) + local current_tag = c.screen.selected_tag + ctags = { current_tag } + for k, tag in pairs(c:tags()) do + if tag ~= current_tag then + table.insert(ctags, tag) + end + end + c:tags(ctags) + c:raise() + client.focus = c +end + +-- move the parent with the child +local sync = function(c, p) + if not c.valid or not p.valid then + return + end + if p.modal then + return + end + c.floating = p.floating + c.maximized = p.maximized + c.above = p.above + c.below = p.below + c:geometry(p:geometry()) +end + +-- this does the opposite off on() and you guessed it, also copied from bling +function off(c) + current_tag = c.screen.selected_tag + local ctags = {} + for k, tag in pairs(c:tags()) do + if tag ~= current_tag then + table.insert(ctags, tag) + end + end + c:tags(ctags) + c.sticky = false +end + +-- the main implementation +local handle = function(c) + local daddy = awful.client.focus.history.get(c.screen, 1) -- read the history to get the parent terminal + if not daddy or daddy.type == "dialog" or daddy.type == "splash" then return end + getDaddy(c.pid, function(e, pid) + if (tostring(pid):find("(" .. tostring(daddy.pid) .. ")")) and checkForSucc(c.class, daddy.class) then -- check if the parent exists and the window can be swallowed + c:connect_signal("unmanage", function() + if daddy then + on(daddy) + sync(c, daddy) + end + end) + + sync(c, daddy) + off(daddy) + end + end) +end +client.connect_signal("manage", handle) -- executing it diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/tags.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/tags.lua new file mode 100644 index 0000000..28c6b9c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/tags.lua @@ -0,0 +1,5 @@ +local awful = require "awful" + +screen.connect_signal("request::desktop_decoration", function(s) + awful.tag({ "1", "2", "3", " " }, s, awful.layout.layouts[1]) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/main/wallpaper.lua b/modules/home-manager/ricing/awesomewm/dotfiles/main/wallpaper.lua new file mode 100644 index 0000000..6a5eb64 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/main/wallpaper.lua @@ -0,0 +1,17 @@ +local gears = require "gears" +local beautiful = require "beautiful" +local helpeers = require "helpers" + + +local function set_wall(s) + local d = helpeers.readJson(gears.filesystem.get_cache_dir() .. 'json/settings.json') + if d.wallpaper == "colorful" then + gears.wallpaper.maximized(beautiful.wallpaper, s, beautiful.mbg) + else + gears.wallpaper.set(beautiful.bg3) + end +end + +screen.connect_signal("request::wallpaper", function(s) + set_wall(s) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/base.lua b/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/base.lua new file mode 100644 index 0000000..61cedfb --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/base.lua @@ -0,0 +1,285 @@ +-- Copyleft © 2022 Saimoomedits +--most stuff copied from guy above + + +local naughty = require("naughty") +local beautiful = require("beautiful") +local wibox = require("wibox") +local awful = require("awful") +local dpi = beautiful.xresources.apply_dpi +local helpers = require("helpers") +local ruled = require("ruled") +local menubar = require("menubar") +local animation = require("mods.animation") +local gears = require("gears") + + + +naughty.connect_signal("request::icon", function(n, context, hints) + if context ~= "app_icon" then return end + + local path = menubar.utils.lookup_icon(hints.app_icon) or menubar.utils.lookup_icon(hints.app_icon:lower()) + + if path then n.icon = path end +end) + + +-- naughty config +naughty.config.defaults.ontop = true +naughty.config.defaults.screen = awful.screen.focused() +naughty.config.defaults.timeout = 10 +naughty.config.defaults.title = "Ding!" +naughty.config.defaults.position = "top_right" + + +-- Timeouts +naughty.config.presets.low.timeout = 10 +naughty.config.presets.critical.timeout = 0 + +-- ruled notification +ruled.notification.connect_signal("request::rules", function() + ruled.notification.append_rule { + rule = {}, + properties = { screen = awful.screen.preferred, implicit_timeout = 6 } + } +end) + + + +-- connect to each display +-------------------------- +naughty.connect_signal("request::display", function(n) + -- action widget + local action_widget = { + { + { + id = "text_role", + align = "center", + valign = "center", + font = beautiful.sans .. " 10", + widget = wibox.widget.textbox + }, + left = dpi(6), + right = dpi(6), + widget = wibox.container.margin + }, + bg = beautiful.mbg, + forced_height = dpi(30), + shape = helpers.rrect(2), + widget = wibox.container.background + } + + + -- actions + local actions = wibox.widget { + notification = n, + base_layout = wibox.widget { + spacing = dpi(8), + layout = wibox.layout.flex.horizontal + }, + widget_template = action_widget, + style = { underline_normal = false, underline_selected = true }, + widget = naughty.list.actions + } + + + + -- image + local image_n = wibox.widget { + { + { + opacity = 0.9, + image = n.icon and helpers.cropSurface(1, gears.surface.load_uncached(n.icon)) or + gears.filesystem.get_configuration_dir() .. "theme/assets/" .. "bell.png", + resize = true, + halign = "center", + valign = "center", + clip_shape = helpers.rrect(50), + widget = wibox.widget.imagebox, + }, + strategy = "exact", + height = dpi(50), + width = dpi(50), + widget = wibox.container.constraint, + }, + id = "arc", + widget = wibox.container.arcchart, + max_value = 100, + min_value = 0, + value = 100, + rounded_edge = true, + thickness = dpi(4), + start_angle = 4.71238898, + bg = beautiful.blue, + colors = { beautiful.fg }, + forced_width = dpi(80), + forced_height = dpi(80) + } + local anim = animation:new { + duration = 6, + target = 100, + reset_on_stop = false, + easing = animation.easing.linear, + update = function(_, pos) + image_n:get_children_by_id('arc')[1].value = pos + end, + } + anim:connect_signal("ended", function() + n:destroy() + end) + + -- title + local title_n = wibox.widget { + { + { + markup = n.title, + font = beautiful.sans .. " 12", + align = "right", + valign = "center", + widget = wibox.widget.textbox + }, + forced_width = dpi(240), + widget = wibox.container.scroll.horizontal, + step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, + speed = 50 + }, + margins = { right = 15 }, + widget = wibox.container.margin + } + + + local message_n = wibox.widget { + { + { + markup = helpers.colorizeText("" .. n.message .. "", beautiful.fg .. "BF"), + font = beautiful.sans .. " 12", + align = "left", + valign = "center", + wrap = "char", + widget = wibox.widget.textbox + }, + forced_width = dpi(240), + layout = wibox.layout.fixed.horizontal + }, + margins = { right = 15 }, + widget = wibox.container.margin + } + + + -- app name + local aname = '' + if n.app_name ~= '' then + aname = n.app_name + else + aname = 'naughty' + end + local app_name_n = wibox.widget { + markup = helpers.colorizeText(aname, beautiful.fg .. "BF"), + font = beautiful.sans .. " 10", + align = "left", + valign = "center", + widget = wibox.widget.textbox + } + + local time_n = wibox.widget { + { + markup = helpers.colorizeText("now", beautiful.fg .. "BF"), + font = beautiful.sans .. " 10", + align = "right", + valign = "center", + widget = wibox.widget.textbox + }, + margins = { right = 20 }, + widget = wibox.container.margin + } + + local close = wibox.widget { + markup = helpers.colorizeText('󰝥', beautiful.red), + font = beautiful.icon .. " 12", + align = "ceneter", + valign = "center", + widget = wibox.widget.textbox + } + + close:buttons(gears.table.join( + awful.button({}, 1, function() n:destroy(naughty.notification_closed_reason.dismissed_by_user) end))) + + + -- extra info + local notif_info = wibox.widget { + app_name_n, + { + widget = wibox.widget.separator, + shape = gears.shape.circle, + forced_height = dpi(4), + forced_width = dpi(4), + color = beautiful.fg .. "BF" + }, + time_n, + layout = wibox.layout.fixed.horizontal, + spacing = dpi(7) + } + + + + + local widget = naughty.layout.box { + notification = n, + bg = beautiful.bg, + shape = helpers.rrect(8), + widget_template = { + { + { + -- top bit + { + { + { + close, + nil, + notif_info, + layout = wibox.layout.align.horizontal, + expand = "none" + }, + margins = { left = dpi(15), right = dpi(15), top = dpi(10), bottom = dpi(10) }, + widget = wibox.container.margin + }, + widget = wibox.container.background, + bg = beautiful.mbg, + }, + layout = wibox.layout.fixed.vertical + }, + { + -- body + { + { + title_n, + message_n, + layout = wibox.layout.fixed.vertical, + spacing = dpi(3) + }, + nil, + image_n, + layout = wibox.layout.align.horizontal, + expand = "none" + }, + margins = { left = dpi(15), top = dpi(10), right = dpi(10) }, + widget = wibox.container.margin + }, + { + -- foot + actions, + margins = dpi(10), + widget = wibox.container.margin + }, + layout = wibox.layout.fixed.vertical, + spacing = dpi(10) + }, + widget = wibox.container.background, + shape = helpers.rrect(8), + bg = beautiful.bg, + } + } + + widget.buttons = {} + anim:start() +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/init.lua new file mode 100644 index 0000000..d6c181b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/init.lua @@ -0,0 +1 @@ +require("misc.dings.base") diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/music.lua b/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/music.lua new file mode 100644 index 0000000..787ed00 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/dings/music.lua @@ -0,0 +1,10 @@ +local naughty = require("naughty") +local bling = require("mods.playerctl") +local playerctl = bling.lib() + +playerctl:connect_signal("metadata", + function(_, title, artist, album_path, album, new, player_name) + if new == true then + naughty.notify({ title = 'New Song', text = title .. " by " .. artist, image = album_path }) + end + end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/misc/init.lua new file mode 100644 index 0000000..2d2a72f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/init.lua @@ -0,0 +1,3 @@ +require "misc.titlebar" +require "misc.music" +require "misc.dings" diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/music.lua b/modules/home-manager/ricing/awesomewm/dotfiles/misc/music.lua new file mode 100644 index 0000000..cf72e2b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/music.lua @@ -0,0 +1,304 @@ +local awful = require 'awful' +require 'awful.autofocus' +local wibox = require 'wibox' +local gears = require 'gears' +local beautiful = require("beautiful") +local ruled = require("ruled") +local helpers = require("helpers") +local playerctl = require("mods.playerctl").lib() +local dpi = beautiful.xresources.apply_dpi + +local art = wibox.widget { + image = helpers.cropSurface(1, gears.surface.load_uncached(beautiful.songdefpicture)), + clip_shape = helpers.rrect(10), + opacity = 0.75, + resize = true, + forced_height = dpi(60), + forced_width = dpi(60), + valign = 'center', + widget = wibox.widget.imagebox +} +local leftart = wibox.widget { + image = beautiful.songdefpicture, + clip_shape = helpers.rrect(10), + opacity = 0.75, + resize = true, + forced_height = dpi(250), + forced_width = dpi(250), + valign = 'center', + widget = wibox.widget.imagebox +} +local prev = wibox.widget { + align = 'center', + font = beautiful.icon .. " 24", + markup = helpers.colorizeText('󰒮', beautiful.fg), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:previous() + end) + }, +} +local next = wibox.widget { + align = 'center', + font = beautiful.icon .. " 24", + markup = helpers.colorizeText('󰒭', beautiful.fg), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:next() + end) + }, +} + +local play = wibox.widget { + align = 'center', + font = beautiful.icon .. " 24", + markup = helpers.colorizeText('󰐊', beautiful.blue), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:play_pause() + end) + }, +} +local shufflebtn = wibox.widget { + align = 'center', + font = beautiful.icon .. " 13", + markup = helpers.colorizeText('󰒝', beautiful.fg), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:cycle_shuffle() + end) + } +} +playerctl:connect_signal("shuffle", function(_, shuffle) + shufflebtn.markup = shuffle and helpers.colorizeText('󰒝', beautiful.blue) or helpers.colorizeText('󰒝', + beautiful.fg) +end) +local repeatt = wibox.widget { + align = 'center', + font = beautiful.icon .. " 13", + markup = helpers.colorizeText('󰑖', beautiful.fg), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:cycle_loop_status() + end) + } +} +playerctl:connect_signal("loop_status", function(_, loop_status) + if loop_status:match('none') then + repeatt.markup = helpers.colorizeText('󰑖', beautiful.fg) + elseif loop_status:match('track') then + repeatt.markup = helpers.colorizeText('󰑘', beautiful.magenta) + else + repeatt.markup = helpers.colorizeText('󰑖', beautiful.magenta) + end +end) + +local createHandle = function(width, height, tl, tr, br, bl, radius) + return function(cr) + gears.shape.partially_rounded_rect(cr, width, height, tl, tr, br, bl, radius) + end +end +local slider = wibox.widget { + bar_shape = helpers.rrect(0), + bar_height = 3, + handle_color = beautiful.blue, + bar_color = beautiful.blue .. '33', + bar_active_color = beautiful.blue, + handle_shape = createHandle(18, 3, false, false, false, false, 0), + handle_margins = { top = 3 }, + handle_width = 18, + forced_height = 10, + maximum = 100, + widget = wibox.widget.slider, +} + +local songname = wibox.widget { + markup = helpers.colorizeText('Nothing Playing', beautiful.fg), + align = 'left', + valign = 'center', + forced_width = dpi(40), + font = beautiful.sans .. " 12", + widget = wibox.widget.textbox +} +local leftname = wibox.widget { + markup = helpers.colorizeText('Nothing Playing', beautiful.fg), + valign = 'center', + align = 'center', + font = beautiful.sans .. " 16", + widget = wibox.widget.textbox +} +local artistname = wibox.widget { + markup = helpers.colorizeText('None', beautiful.fg), + align = 'left', + valign = 'center', + forced_height = dpi(20), + font = beautiful.sans .. " 11", + widget = wibox.widget.textbox +} +local leftartist = wibox.widget { + markup = helpers.colorizeText('None', beautiful.fg), + align = 'center', + valign = 'center', + forced_height = dpi(20), + font = beautiful.sans .. " 11", + widget = wibox.widget.textbox +} +local is_prog_hovered = false +slider:connect_signal('mouse::enter', function() + is_prog_hovered = true +end) +slider:connect_signal('mouse::leave', function() + is_prog_hovered = false +end) +slider:connect_signal('property::value', function(_, value) + if is_prog_hovered then + playerctl:set_position(value) + end +end) +playerctl:connect_signal("position", function(_, interval_sec, length_sec) + slider.maximum = length_sec or 100 + slider.value = interval_sec or 0 +end) + +playerctl:connect_signal("metadata", function(_, title, artist, album_path, album, new, player_name) + if player_name == "mpd" then + if album_path == "" then + album_path = beautiful.songdefpicture + end + if string.len(title) > 30 then + title = string.sub(title, 0, 30) .. "..." + end + if string.len(artist) > 22 then + artist = string.sub(artist, 0, 22) .. "..." + end + songname:set_markup_silently(helpers.colorizeText(title or "NO", beautiful.fg)) + leftname:set_markup_silently(helpers.colorizeText(title or "NO", beautiful.fg)) + leftartist:set_markup_silently(helpers.colorizeText(' ' .. artist or "WT" .. ' ', beautiful.fg)) + artistname:set_markup_silently(helpers.colorizeText(artist or "HM", beautiful.fg)) + art:set_image(gears.surface.load_uncached(album_path)) + leftart:set_image(gears.surface.load_uncached(album_path)) + end +end) + + +playerctl:connect_signal("playback_status", function(_, playing) + play.markup = playing and helpers.colorizeText("󰏤", beautiful.blue) or helpers.colorizeText("󰐊", beautiful.blue) +end) +local createTopButton = function(c, icon, click, color) + local widget = wibox.widget { + { + { + markup = helpers.colorizeText(icon, color), + valign = 'center', + forced_height = dpi(20), + font = beautiful.icon .. " 18", + widget = wibox.widget.textbox + }, + margins = { + left = 8, + right = 8 + }, + widget = wibox.container.margin, + }, + buttons = awful.button({}, 1, function() + helpers.clickKey(c, click) + end), + bg = beautiful.mbg, + widget = wibox.container.background + } + return widget +end + +local bottom = function(c) + local playtab = createTopButton(c, '󰲸', '1', beautiful.blue) + local vistab = createTopButton(c, '󰐰', '8', beautiful.blue) + vistab:add_button(awful.button({}, 3, function() + helpers.clickKey(c, '8 ') + end)) + awful.titlebar(c, { position = "bottom", size = dpi(100), bg = beautiful.mbg }):setup { + slider, + { + { + { + { + art, + { + { + songname, + artistname, + forced_width = 400, + layout = wibox.layout.fixed.vertical, + }, + align = 'center', + widget = wibox.container.place + }, + spacing = 13, + layout = wibox.layout.fixed.horizontal, + }, + margins = { + top = 15, + bottom = 15, + left = 10, + right = 10, + }, + widget = wibox.container.margin, + }, + { + { + shufflebtn, + prev, + { + { + play, + margins = 4, + widget = wibox.container.margin + }, + shape = helpers.rrect(3), + bg = beautiful.blue .. '11', + widget = wibox.container.background + }, + next, + repeatt, + spacing = 15, + layout = wibox.layout.fixed.horizontal, + }, + align = 'center', + widget = wibox.container.place, + }, + { + playtab, + vistab, + spacing = 10, + layout = wibox.layout.fixed.horizontal, + }, + expand = 'none', + layout = wibox.layout.align.horizontal, + }, + widget = wibox.container.margin, + left = 15, + right = 15 + }, + layout = wibox.layout.fixed.vertical, + } +end + +local final = function(c) + bottom(c) +end + + +ruled.client.connect_signal("request::rules", function() + ruled.client.append_rule { + id = "music", + rule_any = { + class = { "ncmpcpppad" }, + role = { "pop-up" }, + }, + callback = final + } +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/airplanemode b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/airplanemode new file mode 100644 index 0000000..4266a3d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/airplanemode @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +STATUS="$(rfkill list | sed -n 2p | awk '{print $3}')" + + +toggle() { + if [[ $STATUS == "no" ]]; then + getroot 'pkexec rfkill block all' + notify-send --urgency=normal "Airplane Mode" "Airplane mode has been turned on!" + else + getroot 'pkexec rfkill unblock all' + notify-send --urgency=normal "Airplane Mode" "Airplane mode has been turned off!" + fi +} + + +if [[ $1 == "--toggle" ]]; then + toggle +fi diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/bluetooth b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/bluetooth new file mode 100644 index 0000000..db76e39 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/bluetooth @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +toggle() { + STATUS="$(bluetoothctl show | grep Powered | awk '{print $2}')" + if [ $STATUS == "yes" ]; then + bluetoothctl power off + notify-send -a "Bluetooth" --urgency=normal "Bluetooth" "Bluetooth has been turned off." + else + bluetoothctl power on + notify-send -a "Bluetooth" --urgency=normal "Bluetooth" "Bluetooth has been turned on." + fi +} + + +if [[ $1 == "--toggle" ]]; then + toggle +fi diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/picom b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/picom new file mode 100644 index 0000000..6c0cd21 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/picom @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +toggle(){ + if [[ ! `pidof picom` ]]; then + picom & + else + pkill -9 picom + fi +} + +if [[ $1 == "--toggle" ]]; then + toggle +fi + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/redshift b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/redshift new file mode 100644 index 0000000..964fb56 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/redshift @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +is_active=$(cat ~/.cache/redshift) + +toggle() { + if [[ $is_active == *"true"* ]]; then + redshift -x && echo false > ~/.cache/redshift + else + redshift -O 4000 && echo true > ~/.cache/redshift + fi +} + +if [[ $1 == "--toggle" ]]; then + toggle +fi diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/wifi b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/wifi new file mode 100644 index 0000000..f02ad33 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/scripts/wifi @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +STATUS=$(nmcli | grep wlan0 | awk 'FNR == 1 {print $2}') +SSID=$(iwgetid -r) +STRENGTH=$(awk 'NR==3 {printf("%.0f",$3*10/7)}' /proc/net/wireless) + +toggle() { + if [[ $STATUS == "connected" ]]; then + nmcli radio wifi off + notify-send -a "wifi" --urgency=normal "Wi-Fi" "Wi-Fi has been turned off!" + else + nmcli radio wifi on + notify-send -a "wifi" --urgency=normal "Wi-Fi" "Wi-Fi has been turned on, you are back online!" + fi +} + + +if [[ $1 == "--toggle" ]]; then + toggle +fi diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/misc/titlebar.lua b/modules/home-manager/ricing/awesomewm/dotfiles/misc/titlebar.lua new file mode 100644 index 0000000..a997f3d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/misc/titlebar.lua @@ -0,0 +1,103 @@ +local awful = require "awful" +local gears = require "gears" +local wibox = require "wibox" +local beautiful = require "beautiful" +local helpers = require "helpers" +local getIcon = require "mods.getIcon" +local dpi = beautiful.xresources.apply_dpi + +----- Titlebar +local get_titlebar = function(c) + -- Button + local buttons = gears.table.join({ + awful.button({}, 1, function() + c:activate { context = "titlebar", action = "mouse_move" } + end), + awful.button({}, 3, function() + c:activate { context = "titlebar", action = "mouse_resize" } + end) + }) + + -- Titlebar's decorations + local left = wibox.widget { + { + { + awful.titlebar.widget.closebutton(c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.minimizebutton(c), + spacing = dpi(5), + layout = wibox.layout.fixed.horizontal, + }, + widget = wibox.container.margin, + margins = 8 + }, + shape = helpers.rrect(5), + widget = wibox.container.background, + bg = beautiful.mbg + } + + local middle = wibox.widget { + buttons = buttons, + layout = wibox.layout.fixed.horizontal, + } + + local right = wibox.widget { + { + { + { + widget = wibox.widget.imagebox, + image = getIcon(c, c.class, c.class), + forced_width = 30, + clip_shape = helpers.rrect(100), + resize = true, + }, + widget = wibox.container.place, + halign = "center", + }, + margins = dpi(5), + widget = wibox.container.margin + }, + bg = beautiful.mbg, + shape = helpers.rrect(5), + widget = wibox.container.background + } + + local container = wibox.widget { + bg = beautiful.bar, + shape = function(cr, w, h) gears.shape.partially_rounded_rect(cr, w, h, true, true, false, false, 0) end, + widget = wibox.container.background, + } + + c:connect_signal("focus", function() container.bg = beautiful.bg end) + c:connect_signal("unfocus", function() container.bg = beautiful.bg end) + + return wibox.widget { + { + { + left, + middle, + right, + layout = wibox.layout.align.horizontal, + }, + margins = { top = dpi(5), bottom = dpi(5), left = dpi(5), right = dpi(5) }, + widget = wibox.container.margin, + }, + widget = container, + } +end + +local function top(c) + local titlebar = awful.titlebar(c, { + position = 'top', + size = dpi(50), + bg = beautiful.transparent + }) + + titlebar:setup { + widget = get_titlebar(c) + } +end + +client.connect_signal("request::titlebars", function(c) + top(c) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/init.lua new file mode 100644 index 0000000..df164af --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/init.lua @@ -0,0 +1,239 @@ +------------------------------------------- +-- @author https://github.com/Kasper24 +-- @copyright 2021-2022 Kasper24 +------------------------------------------- + +local GLib = require("lgi").GLib +local gobject = require("gears.object") +local gtable = require("gears.table") +local subscribable = require("mods.animation.subscribable") +local tween = require("mods.animation.tween") +local ipairs = ipairs +local table = table +local pairs = pairs + +local animation_manager = {} +animation_manager.easing = +{ + linear = "linear", + inQuad = "inQuad", + outQuad = "outQuad", + inOutQuad = "inOutQuad", + outInQuad = "outInQuad", + inCubic = "inCubic", + outCubic = "outCubic", + inOutCubic = "inOutCubic", + outInCubic = "outInCubic", + inQuart = "inQuart", + outQuart = "outQuart", + inOutQuart = "inOutQuart", + outInQuart = "outInQuart", + inQuint = "inQuint", + outQuint = "outQuint", + inOutQuint = "inOutQuint", + outInQuint = "outInQuint", + inSine = "inSine", + outSine = "outSine", + inOutSine = "inOutSine", + outInSine = "outInSine", + inExpo = "inExpo", + outExpo = "outExpo", + inOutExpo = "inOutExpo", + outInExpo = "outInExpo", + inCirc = "inCirc", + outCirc = "outCirc", + inOutCirc = "inOutCirc", + outInCirc = "outInCirc", + inElastic = "inElastic", + outElastic = "outElastic", + inOutElastic = "inOutElastic", + outInElastic = "outInElastic", + inBack = "inBack", + outBack = "outBack", + inOutBack = "inOutBack", + outInBack = "outInBack", + inBounce = "inBounce", + outBounce = "outBounce", + inOutBounce = "inOutBounce", + outInBounce = "outInBounce" +} + +local animation = {} + +local instance = nil + +local ANIMATION_FRAME_DELAY = 5 + +local function micro_to_milli(micro) + return micro / 1000 +end + +local function second_to_micro(sec) + return sec * 1000000 +end + +local function second_to_milli(sec) + return sec * 1000 +end + +function animation:start(args) + args = args or {} + + -- Awestoer/Rubbto compatibility + -- I'd rather this always be a table, but Awestoer/Rubbto + -- except the :set() method to have 1 number value parameter + -- used to set the target + local is_table = type(args) == "table" + local initial = is_table and (args.pos or self.pos) or self.pos + local subject = is_table and (args.subject or self.subject) or self.subject + local target = is_table and (args.target or self.target) or args + local duration = is_table and (args.duration or self.duration) or self.duration + local easing = is_table and (args.easing or self.easing) or self.easing + + duration = self._private.anim_manager._private.instant == true and 0.01 or duration + + if self.tween == nil or self.reset_on_stop == true then + self.tween = tween.new + { + initial = initial, + subject = subject, + target = target, + duration = second_to_micro(duration), + easing = easing + } + end + + if self._private.anim_manager._private.animations[self.index] == nil then + table.insert(self._private.anim_manager._private.animations, self) + end + + self.state = true + self.last_elapsed = GLib.get_monotonic_time() + + self.started:fire() + self:emit_signal("started") +end + +function animation:set(args) + self:start(args) + self:emit_signal("set") +end + +function animation:stop() + self.state = false + self:emit_signal("stopped") +end + +function animation:abort(reset) + animation:stop(reset) + self:emit_signal("aborted") +end + +function animation:initial() + return self._private.initial +end + +function animation_manager:set_instant(value) + self._private.instant = value +end + +function animation_manager:new(args) + args = args or {} + + args.pos = args.pos or 0 + args.subject = args.subject or nil + args.target = args.target or nil + args.duration = args.duration or 0 + args.easing = args.easing or nil + args.loop = args.loop or false + args.signals = args.signals or {} + args.update = args.update or nil + args.reset_on_stop = args.reset_on_stop == nil and true or args.reset_on_stop + + -- Awestoer/Rubbto compatibility + args.subscribed = args.subscribed or nil + local ret = subscribable() + ret.started = subscribable() + ret.ended = subscribable() + if args.subscribed ~= nil then + ret:subscribe(args.subscribed) + end + + for sig, sigfun in pairs(args.signals) do + ret:connect_signal(sig, sigfun) + end + if args.update ~= nil then + ret:connect_signal("update", args.update) + end + + gtable.crush(ret, args, true) + gtable.crush(ret, animation, true) + + ret._private = {} + ret._private.anim_manager = self + ret._private.initial = args.pos + + return ret +end + +local function new() + local ret = gobject {} + gtable.crush(ret, animation_manager, true) + + ret._private = {} + ret._private.animations = {} + ret._private.instant = false + + GLib.timeout_add + ( + GLib.PRIORITY_DEFAULT, + ANIMATION_FRAME_DELAY, + function() + for index, animation in ipairs(ret._private.animations) do + if animation.state == true then + -- compute delta time + local time = GLib.get_monotonic_time() + local delta = time - animation.last_elapsed + animation.last_elapsed = time + + -- If pos is true, the animation has ended + local pos = animation.tween:update(delta) + if pos == true then + -- Loop the animation, don't end it. + -- Useful for widgets like the spinning cicle + if animation.loop == true then + animation.tween:reset() + else + -- Snap to end + animation.pos = animation.tween.target + animation:fire(animation.pos) + animation:emit_signal("update", animation.pos) + + animation.state = false + animation.ended:fire(pos) + table.remove(ret._private.animations, index) + animation:emit_signal("ended", animation.pos) + end + -- Animation in process, keep updating + else + animation.pos = pos + animation:fire(animation.pos) + animation:emit_signal("update", animation.pos) + end + else + table.remove(ret._private.animations, index) + end + end + + -- call again the function after cooldown + return true + end + ) + + return ret +end + +if not instance then + instance = new() +end +return instance diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/subscribable.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/subscribable.lua new file mode 100644 index 0000000..642b787 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/subscribable.lua @@ -0,0 +1,41 @@ +------------------------------------------- +-- @author https://github.com/Kasper24 +-- @copyright 2021-2022 Kasper24 +-- Adopted from rubato +------------------------------------------- + + +local gobject = require("gears.object") + +-- Kidna copying awesotre's stores on a surface level for added compatibility +local function subscribable(args) + local ret = gobject {} + local subscribed = {} + + -- Subscrubes a function to the object so that it's called when `fire` is + -- Calls subscribe_callback if it exists as well + function ret:subscribe(func) + local id = tostring(func):gsub("function: ", "") + subscribed[id] = func + + if self.subscribe_callback then self.subscribe_callback(func) end + end + + -- Unsubscribes a function and calls unsubscribe_callback if it exists + function ret:unsubscribe(func) + if not func then + subscribed = {} + else + local id = tostring(func):gsub("function: ", "") + subscribed[id] = nil + end + + if self.unsubscribe_callback then self.unsubscribe_callback(func) end + end + + function ret:fire(...) for _, func in pairs(subscribed) do func(...) end end + + return ret +end + +return subscribable diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/tween.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/tween.lua new file mode 100644 index 0000000..a31bfb5 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/animation/tween.lua @@ -0,0 +1,527 @@ +------------------------------------------- +-- @author https://github.com/Kasper24 +-- @copyright 2021-2022 Kasper24 +------------------------------------------- + +-- easing + +-- Adapted from https://github.com/EmmanuelOga/easing. See LICENSE.txt for credits. +-- For all easing functions: +-- t = time == how much time has to pass for the tweening to complete +-- b = begin == starting property value +-- c = change == ending - beginning +-- d = duration == running time. How much time has passed *right now* + +local gobject = require("gears.object") +local gtable = require("gears.table") + +local tween = { + _VERSION = 'tween 2.1.1', + _DESCRIPTION = 'tweening for lua', + _URL = 'https://github.com/kikito/tween.lua', + _LICENSE = [[ + MIT LICENSE + Copyright (c) 2014 Enrique García Cota, Yuichi Tateno, Emmanuel Oga + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ]] +} + +local pow, sin, cos, pi, sqrt, abs, asin = math.pow, math.sin, math.cos, math.pi, math.sqrt, math.abs, math.asin + +-- linear +local function linear(t, b, c, d) + return c * t / d + b +end + +-- quad +local function inQuad(t, b, c, d) + return c * pow(t / d, 2) + b +end + +local function outQuad(t, b, c, d) + t = t / d + return -c * t * (t - 2) + b +end + +local function inOutQuad(t, b, c, d) + t = t / d * 2 + if t < 1 then + return c / 2 * pow(t, 2) + b + end + return -c / 2 * ((t - 1) * (t - 3) - 1) + b +end + +local function outInQuad(t, b, c, d) + if t < d / 2 then + return outQuad(t * 2, b, c / 2, d) + end + return inQuad((t * 2) - d, b + c / 2, c / 2, d) +end + +-- cubic +local function inCubic(t, b, c, d) + return c * pow(t / d, 3) + b +end + +local function outCubic(t, b, c, d) + return c * (pow(t / d - 1, 3) + 1) + b +end + +local function inOutCubic(t, b, c, d) + t = t / d * 2 + if t < 1 then + return c / 2 * t * t * t + b + end + t = t - 2 + return c / 2 * (t * t * t + 2) + b +end + +local function outInCubic(t, b, c, d) + if t < d / 2 then + return outCubic(t * 2, b, c / 2, d) + end + return inCubic((t * 2) - d, b + c / 2, c / 2, d) +end + +-- quart +local function inQuart(t, b, c, d) + return c * pow(t / d, 4) + b +end + +local function outQuart(t, b, c, d) + return -c * (pow(t / d - 1, 4) - 1) + b +end + +local function inOutQuart(t, b, c, d) + t = t / d * 2 + if t < 1 then + return c / 2 * pow(t, 4) + b + end + return -c / 2 * (pow(t - 2, 4) - 2) + b +end + +local function outInQuart(t, b, c, d) + if t < d / 2 then + return outQuart(t * 2, b, c / 2, d) + end + return inQuart((t * 2) - d, b + c / 2, c / 2, d) +end + +-- quint +local function inQuint(t, b, c, d) + return c * pow(t / d, 5) + b +end + +local function outQuint(t, b, c, d) + return c * (pow(t / d - 1, 5) + 1) + b +end + +local function inOutQuint(t, b, c, d) + t = t / d * 2 + if t < 1 then + return c / 2 * pow(t, 5) + b + end + return c / 2 * (pow(t - 2, 5) + 2) + b +end + +local function outInQuint(t, b, c, d) + if t < d / 2 then + return outQuint(t * 2, b, c / 2, d) + end + return inQuint((t * 2) - d, b + c / 2, c / 2, d) +end + +-- sine +local function inSine(t, b, c, d) + return -c * cos(t / d * (pi / 2)) + c + b +end + +local function outSine(t, b, c, d) + return c * sin(t / d * (pi / 2)) + b +end + +local function inOutSine(t, b, c, d) + return -c / 2 * (cos(pi * t / d) - 1) + b +end + +local function outInSine(t, b, c, d) + if t < d / 2 then + return outSine(t * 2, b, c / 2, d) + end + return inSine((t * 2) - d, b + c / 2, c / 2, d) +end + +-- expo +local function inExpo(t, b, c, d) + if t == 0 then + return b + end + return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001 +end + +local function outExpo(t, b, c, d) + if t == d then + return b + c + end + return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b +end + +local function inOutExpo(t, b, c, d) + if t == 0 then + return b + end + if t == d then + return b + c + end + t = t / d * 2 + if t < 1 then + return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005 + end + return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b +end + +local function outInExpo(t, b, c, d) + if t < d / 2 then + return outExpo(t * 2, b, c / 2, d) + end + return inExpo((t * 2) - d, b + c / 2, c / 2, d) +end + +-- circ +local function inCirc(t, b, c, d) + return (-c * (sqrt(1 - pow(t / d, 2)) - 1) + b) +end + +local function outCirc(t, b, c, d) + return (c * sqrt(1 - pow(t / d - 1, 2)) + b) +end + +local function inOutCirc(t, b, c, d) + t = t / d * 2 + if t < 1 then + return -c / 2 * (sqrt(1 - t * t) - 1) + b + end + t = t - 2 + return c / 2 * (sqrt(1 - t * t) + 1) + b +end + +local function outInCirc(t, b, c, d) + if t < d / 2 then + return outCirc(t * 2, b, c / 2, d) + end + return inCirc((t * 2) - d, b + c / 2, c / 2, d) +end + +-- elastic +local function calculatePAS(p, a, c, d) + p, a = p or d * 0.3, a or 0 + if a < abs(c) then + return p, c, p / 4 + end -- p, a, s + return p, a, p / (2 * pi) * asin(c / a) -- p,a,s +end + +local function inElastic(t, b, c, d, a, p) + local s + if t == 0 then + return b + end + t = t / d + if t == 1 then + return b + c + end + p, a, s = calculatePAS(p, a, c, d) + t = t - 1 + return -(a * pow(2, 10 * t) * sin((t * d - s) * (2 * pi) / p)) + b +end + +local function outElastic(t, b, c, d, a, p) + local s + if t == 0 then + return b + end + t = t / d + if t == 1 then + return b + c + end + p, a, s = calculatePAS(p, a, c, d) + return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b +end + +local function inOutElastic(t, b, c, d, a, p) + local s + if t == 0 then + return b + end + t = t / d * 2 + if t == 2 then return b + c end + p, a, s = calculatePAS(p, a, c, d) + t = t - 1 + if t < 0 then + return -0.5 * (a * pow(2, 10 * t) * sin((t * d - s) * (2 * pi) / p)) + b + end + return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) * 0.5 + c + b +end + +local function outInElastic(t, b, c, d, a, p) + if t < d / 2 then + return outElastic(t * 2, b, c / 2, d, a, p) + end + return inElastic((t * 2) - d, b + c / 2, c / 2, d, a, p) +end + +-- back +local function inBack(t, b, c, d, s) + s = s or 1.70158 + t = t / d + return c * t * t * ((s + 1) * t - s) + b +end + +local function outBack(t, b, c, d, s) + s = s or 1.70158 + t = t / d - 1 + return c * (t * t * ((s + 1) * t + s) + 1) + b +end + +local function inOutBack(t, b, c, d, s) + s = (s or 1.70158) * 1.525 + t = t / d * 2 + if t < 1 then + return c / 2 * (t * t * ((s + 1) * t - s)) + b + end + t = t - 2 + return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b +end + +local function outInBack(t, b, c, d, s) + if t < d / 2 then + return outBack(t * 2, b, c / 2, d, s) + end + return inBack((t * 2) - d, b + c / 2, c / 2, d, s) +end + +-- bounce +local function outBounce(t, b, c, d) + t = t / d + if t < 1 / 2.75 then + return c * (7.5625 * t * t) + b + end + if t < 2 / 2.75 then + t = t - (1.5 / 2.75) + return c * (7.5625 * t * t + 0.75) + b + elseif t < 2.5 / 2.75 then + t = t - (2.25 / 2.75) + return c * (7.5625 * t * t + 0.9375) + b + end + t = t - (2.625 / 2.75) + return c * (7.5625 * t * t + 0.984375) + b +end + +local function inBounce(t, b, c, d) + return c - outBounce(d - t, 0, c, d) + b +end + +local function inOutBounce(t, b, c, d) + if t < d / 2 then + return inBounce(t * 2, 0, c, d) * 0.5 + b + end + return outBounce(t * 2 - d, 0, c, d) * 0.5 + c * .5 + b +end + +local function outInBounce(t, b, c, d) + if t < d / 2 then + return outBounce(t * 2, b, c / 2, d) + end + return inBounce((t * 2) - d, b + c / 2, c / 2, d) +end + +tween.easing = +{ + linear = linear, + inQuad = inQuad, outQuad = outQuad, inOutQuad = inOutQuad, outInQuad = outInQuad, + inCubic = inCubic, outCubic = outCubic, inOutCubic = inOutCubic, outInCubic = outInCubic, + inQuart = inQuart, outQuart = outQuart, inOutQuart = inOutQuart, outInQuart = outInQuart, + inQuint = inQuint, outQuint = outQuint, inOutQuint = inOutQuint, outInQuint = outInQuint, + inSine = inSine, outSine = outSine, inOutSine = inOutSine, outInSine = outInSine, + inExpo = inExpo, outExpo = outExpo, inOutExpo = inOutExpo, outInExpo = outInExpo, + inCirc = inCirc, outCirc = outCirc, inOutCirc = inOutCirc, outInCirc = outInCirc, + inElastic = inElastic, outElastic = outElastic, inOutElastic = inOutElastic, outInElastic = outInElastic, + inBack = inBack, outBack = outBack, inOutBack = inOutBack, outInBack = outInBack, + inBounce = inBounce, outBounce = outBounce, inOutBounce = inOutBounce, outInBounce = outInBounce +} + +-- Private interface +local function copyTables(destination, keysTable, valuesTable) + valuesTable = valuesTable or keysTable + local mt = getmetatable(keysTable) + if mt and getmetatable(destination) == nil then + setmetatable(destination, mt) + end + + for k, v in pairs(keysTable) do + if type(v) == 'table' then + destination[k] = copyTables({}, v, valuesTable[k]) + else + destination[k] = valuesTable[k] + end + end + return destination +end + +local function checkSubjectAndTargetRecursively(subject, target, path) + path = path or {} + local targetType, newPath + for k, targetValue in pairs(target) do + targetType, newPath = type(targetValue), copyTables({}, path) + table.insert(newPath, tostring(k)) + if targetType == 'number' then + assert(type(subject[k]) == 'number', + "Parameter '" .. table.concat(newPath, '/') .. "' is missing from subject or isn't a number") + elseif targetType == 'table' then + checkSubjectAndTargetRecursively(subject[k], targetValue, newPath) + else + assert(targetType == 'number', + "Parameter '" .. table.concat(newPath, '/') .. "' must be a number or table of numbers") + end + end +end + +local function checkNewParams(initial, duration, subject, target, easing) + -- assert(type(initial) == 'number' and duration > 0, "duration must be a positive number. Was " .. tostring(duration)) + -- assert(type(duration) == 'number' and duration > 0, "duration must be a positive number. Was " .. tostring(duration)) + assert(type(easing) == 'function', "easing must be a function. Was " .. tostring(easing)) + + if subject and target then + local tsubject = type(subject) + assert(tsubject == 'table' or tsubject == 'userdata', + "subject must be a table or userdata. Was " .. tostring(subject)) + assert(type(target) == 'table', "target must be a table. Was " .. tostring(target)) + checkSubjectAndTargetRecursively(subject, target) + end +end + +local function getEasingFunction(easing) + easing = easing or "linear" + if type(easing) == 'string' then + local name = easing + easing = tween.easing[name] + if type(easing) ~= 'function' then + error("The easing function name '" .. name .. "' is invalid") + end + end + return easing +end + +local function performEasingOnSubject(subject, target, initial, clock, duration, easing) + local t, b, c, d + for k, v in pairs(target) do + if type(v) == 'table' then + performEasingOnSubject(subject[k], v, initial[k], clock, duration, easing) + else + t, b, c, d = clock, initial[k], v - initial[k], duration + subject[k] = easing(t, b, c, d) + end + end +end + +local function performEasing(table, initial, target, clock, duration, easing) + if type(target) == "table" then + local t, b, c, d + for k, v in pairs(target) do + if type(v) == 'table' then + table[k] = {} + performEasing(table[k], initial[k], v, clock, duration, easing) + else + t, b, c, d = clock, initial[k], v - initial[k], duration + table[k] = easing(t, b, c, d) + end + end + + return table + else + local t, b, c, d = clock, initial, target - initial, duration + return easing(t, b, c, d) + end +end + +-- Public interface +local Tween = {} + +function Tween:set(clock) + assert(type(clock) == 'number', "clock must be a positive number or 0") + + if self.subject and self.initial == 0 then + self.initial = copyTables({}, self.target, self.subject) + end + + self.clock = clock + + if self.clock <= 0 then + self.clock = 0 + if self.subject then + copyTables(self.subject, self.initial) + end + elseif self.clock >= self.duration then -- the tween has expired + self.clock = self.duration + + if self.subject then + copyTables(self.subject, self.target) + end + else + if self.subject then + performEasingOnSubject(self.subject, self.target, self.initial, self.clock, self.duration, self.easing) + else + local pos = {} + return performEasing(pos, self.initial, self.target, self.clock, self.duration, self.easing) + end + end + + return self.clock >= self.duration +end + +function Tween:update(dt) + assert(type(dt) == 'number', "dt must be a number") + return self:set(self.clock + dt) +end + +function Tween:reset() + return self:set(0) +end + +function tween.new(args) + args = args or {} + + args.initial = args.initial or 0 + args.subject = args.subject or nil + args.target = args.target or nil + args.duration = args.duration or 0 + args.easing = args.easing or nil + + args.easing = getEasingFunction(args.easing) + checkNewParams(args.initial, args.duration, args.subject, args.target, args.easing) + + local ret = gobject {} + ret.clock = 0 + + gtable.crush(ret, args, true) + gtable.crush(ret, Tween, true) + + return ret +end + +return tween diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/getIcon.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/getIcon.lua new file mode 100644 index 0000000..02ab395 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/getIcon.lua @@ -0,0 +1,103 @@ +local gfs = require("gears.filesystem") +local gears = require("gears") +local theme_path = gfs.get_configuration_dir() .. "/theme/" +local icon_cache = {} +local helpers = require("helpers") +local t = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/settings.json").iconTheme + + +local custom = { + { + name = "clearpad", + to = "terminal" + }, + { + name = "ncmpcpppad", + to = "deepin-music-player" + }, +} + +local function hasValue(str) + local f = false + local ind = 0 + for i, j in ipairs(custom) do + if j.name == str then + f = true + ind = i + break + end + end + return f, ind +end + + +local function Get_icon(client, program_string, class_string) + client = client or nil + program_string = program_string or nil + class_string = class_string or nil + + if (client or program_string or class_string) then + local clientName + local isCustom, pos = hasValue(class_string) + if isCustom == true then + clientName = custom[pos].to .. ".svg" + elseif client then + if client.class then + clientName = string.lower(client.class:gsub(" ", "")) .. ".svg" + elseif client.name then + clientName = string.lower(client.name:gsub(" ", "")) .. ".svg" + else + if client.icon then + return client.icon + else + return t .. "/apps/default-application.svg" + end + end + else + if program_string then + clientName = program_string .. ".svg" + else + clientName = class_string .. ".svg" + end + end + + for index, icon in ipairs(icon_cache) do + if icon:match(clientName) then + return icon + end + end + + local iconDir = t .. "/apps/" + local ioStream = io.open(iconDir .. clientName, "r") + if ioStream ~= nil then + icon_cache[#icon_cache + 1] = iconDir .. clientName + return iconDir .. clientName + else + clientName = clientName:gsub("^%l", string.upper) + iconDir = t .. "/apps//" + ioStream = io.open(iconDir .. clientName, "r") + if ioStream ~= nil then + icon_cache[#icon_cache + 1] = iconDir .. clientName + return iconDir .. clientName + elseif not class_string then + return t .. "/apps/default-application.svg" + else + clientName = class_string .. ".svg" + iconDir = t .. "/apps/" + ioStream = io.open(iconDir .. clientName, "r") + if ioStream ~= nil then + icon_cache[#icon_cache + 1] = iconDir .. clientName + return iconDir .. clientName + else + return t .. "/apps/default-application.svg" + end + end + end + end + if client then + return t .. "/apps/default-application.svg" + end +end + + +return Get_icon diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/inspect.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/inspect.lua new file mode 100644 index 0000000..3ea22a9 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/inspect.lua @@ -0,0 +1,344 @@ +local inspect = { + _VERSION = 'inspect.lua 3.1.0', + _URL = 'http://github.com/kikito/inspect.lua', + _DESCRIPTION = 'human-readable representations of tables', + _LICENSE = [[ + MIT LICENSE + Copyright (c) 2013 Enrique García Cota + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ]] +} + +local tostring = tostring + +inspect.KEY = setmetatable({}, { __tostring = function() return 'inspect.KEY' end }) +inspect.METATABLE = setmetatable({}, { __tostring = function() return 'inspect.METATABLE' end }) + +local function rawpairs(t) + return next, t, nil +end + +-- Apostrophizes the string if it has quotes, but not aphostrophes +-- Otherwise, it returns a regular quoted string +local function smartQuote(str) + if str:match('"') and not str:match("'") then + return "'" .. str .. "'" + end + return '"' .. str:gsub('"', '\\"') .. '"' +end + +-- \a => '\\a', \0 => nil +local shortControlCharEscapes = { + ["\a"] = "\\a", + ["\b"] = "\\b", + ["\f"] = "\\f", + ["\n"] = "\\n", + ["\r"] = "\\r", + ["\t"] = "\\t", + ["\v"] = "\\v", + ["\127"] = "\\127", +} +local longControlCharEscapes = { ["\127"] = "\127" } -- \a => nil, \0 => \000, 31 => \031 +for i = 0, 31 do + local ch = string.char(i) + if not shortControlCharEscapes[ch] then + shortControlCharEscapes[ch] = "\\" .. i + longControlCharEscapes[ch] = string.format("\\%03d", i) + end +end +--longControlCharEscapes["\127"]="\\127" + +local function escape(str) + return (str:gsub("\\", "\\\\") + :gsub("(%c)%f[0-9]", longControlCharEscapes) + :gsub("%c", shortControlCharEscapes)) +end + +local function isIdentifier(str) + return type(str) == 'string' and str:match("^[_%a][_%a%d]*$") +end + +local function isSequenceKey(k, sequenceLength) + return type(k) == 'number' + and 1 <= k + and k <= sequenceLength + and math.floor(k) == k +end + +local defaultTypeOrders = { + ['number'] = 1, + ['boolean'] = 2, + ['string'] = 3, + ['table'] = 4, + ['function'] = 5, + ['userdata'] = 6, + ['thread'] = 7 +} + +local function sortKeys(a, b) + local ta, tb = type(a), type(b) + + -- strings and numbers are sorted numerically/alphabetically + if ta == tb and (ta == 'string' or ta == 'number') then return a < b end + + local dta, dtb = defaultTypeOrders[ta], defaultTypeOrders[tb] + -- Two default types are compared according to the defaultTypeOrders table + if dta and dtb then + return defaultTypeOrders[ta] < defaultTypeOrders[tb] + elseif dta then + return true -- default types before custom ones + elseif dtb then + return false -- custom types after default ones + end + + -- custom types are sorted out alphabetically + return ta < tb +end + +-- For implementation reasons, the behavior of rawlen & # is "undefined" when +-- tables aren't pure sequences. So we implement our own # operator. +local function getSequenceLength(t) + local len = 1 + local v = rawget(t, len) + while v ~= nil do + len = len + 1 + v = rawget(t, len) + end + return len - 1 +end + +local function getNonSequentialKeys(t) + local keys, keysLength = {}, 0 + local sequenceLength = getSequenceLength(t) + for k, _ in rawpairs(t) do + if not isSequenceKey(k, sequenceLength) then + keysLength = keysLength + 1 + keys[keysLength] = k + end + end + table.sort(keys, sortKeys) + return keys, keysLength, sequenceLength +end + +local function countTableAppearances(t, tableAppearances) + tableAppearances = tableAppearances or {} + + if type(t) == 'table' then + if not tableAppearances[t] then + tableAppearances[t] = 1 + for k, v in rawpairs(t) do + countTableAppearances(k, tableAppearances) + countTableAppearances(v, tableAppearances) + end + countTableAppearances(getmetatable(t), tableAppearances) + else + tableAppearances[t] = tableAppearances[t] + 1 + end + end + + return tableAppearances +end + +local copySequence = function(s) + local copy, len = {}, #s + for i = 1, len do copy[i] = s[i] end + return copy, len +end + +local function makePath(path, ...) + local keys = { ... } + local newPath, len = copySequence(path) + for i = 1, #keys do + newPath[len + i] = keys[i] + end + return newPath +end + +local function processRecursive(process, item, path, visited) + if item == nil then return nil end + if visited[item] then return visited[item] end + + local processed = process(item, path) + if type(processed) == 'table' then + local processedCopy = {} + visited[item] = processedCopy + local processedKey + + for k, v in rawpairs(processed) do + processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited) + if processedKey ~= nil then + processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited) + end + end + + local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited) + if type(mt) ~= 'table' then mt = nil end -- ignore not nil/table __metatable field + setmetatable(processedCopy, mt) + processed = processedCopy + end + return processed +end + + + +------------------------------------------------------------------- + +local Inspector = {} +local Inspector_mt = { __index = Inspector } + +function Inspector:puts(...) + local args = { ... } + local buffer = self.buffer + local len = #buffer + for i = 1, #args do + len = len + 1 + buffer[len] = args[i] + end +end + +function Inspector:down(f) + self.level = self.level + 1 + f() + self.level = self.level - 1 +end + +function Inspector:tabify() + self:puts(self.newline, string.rep(self.indent, self.level)) +end + +function Inspector:alreadyVisited(v) + return self.ids[v] ~= nil +end + +function Inspector:getId(v) + local id = self.ids[v] + if not id then + local tv = type(v) + id = (self.maxIds[tv] or 0) + 1 + self.maxIds[tv] = id + self.ids[v] = id + end + return tostring(id) +end + +function Inspector:putKey(k) + if isIdentifier(k) then return self:puts(k) end + self:puts("[") + self:putValue(k) + self:puts("]") +end + +function Inspector:putTable(t) + if t == inspect.KEY or t == inspect.METATABLE then + self:puts(tostring(t)) + elseif self:alreadyVisited(t) then + self:puts('') + elseif self.level >= self.depth then + self:puts('{...}') + else + if self.tableAppearances[t] > 1 then self:puts('<', self:getId(t), '>') end + + local nonSequentialKeys, nonSequentialKeysLength, sequenceLength = getNonSequentialKeys(t) + local mt = getmetatable(t) + + self:puts('{') + self:down(function() + local count = 0 + for i = 1, sequenceLength do + if count > 0 then self:puts(',') end + self:puts(' ') + self:putValue(t[i]) + count = count + 1 + end + + for i = 1, nonSequentialKeysLength do + local k = nonSequentialKeys[i] + if count > 0 then self:puts(',') end + self:tabify() + self:putKey(k) + self:puts(' = ') + self:putValue(t[k]) + count = count + 1 + end + + if type(mt) == 'table' then + if count > 0 then self:puts(',') end + self:tabify() + self:puts(' = ') + self:putValue(mt) + end + end) + + if nonSequentialKeysLength > 0 or type(mt) == 'table' then -- result is multi-lined. Justify closing } + self:tabify() + elseif sequenceLength > 0 then -- array tables have one extra space before closing } + self:puts(' ') + end + + self:puts('}') + end +end + +function Inspector:putValue(v) + local tv = type(v) + + if tv == 'string' then + self:puts(smartQuote(escape(v))) + elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or + tv == 'cdata' or tv == 'ctype' then + self:puts(tostring(v)) + elseif tv == 'table' then + self:putTable(v) + else + self:puts('<', tv, ' ', self:getId(v), '>') + end +end + +------------------------------------------------------------------- + +function inspect.inspect(root, options) + options = options or {} + + local depth = options.depth or math.huge + local newline = options.newline or '\n' + local indent = options.indent or ' ' + local process = options.process + + if process then + root = processRecursive(process, root, {}, {}) + end + + local inspector = setmetatable({ + depth = depth, + level = 0, + buffer = {}, + ids = {}, + maxIds = {}, + newline = newline, + indent = indent, + tableAppearances = countTableAppearances(root) + }, Inspector_mt) + + inspector:putValue(root) + + return table.concat(inspector.buffer) +end + +setmetatable(inspect, { __call = function(_, ...) return inspect.inspect(...) end }) + +return inspect diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/json.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/json.lua new file mode 100644 index 0000000..9bdc02c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/json.lua @@ -0,0 +1,383 @@ +-- +-- json.lua +-- +-- Copyright (c) 2020 rxi +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy of +-- this software and associated documentation files (the "Software"), to deal in +-- the Software without restriction, including without limitation the rights to +-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +-- of the Software, and to permit persons to whom the Software is furnished to do +-- so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in all +-- copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +-- SOFTWARE. +-- + +local json = { _version = "0.1.2" } + +------------------------------------------------------------------------------- +-- Encode +------------------------------------------------------------------------------- + +local encode + +local escape_char_map = { + ["\\"] = "\\", + ["\""] = "\"", + ["\b"] = "b", + ["\f"] = "f", + ["\n"] = "n", + ["\r"] = "r", + ["\t"] = "t", +} + +local escape_char_map_inv = { ["/"] = "/" } +for k, v in pairs(escape_char_map) do + escape_char_map_inv[v] = k +end + + +local function escape_char(c) + return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) +end + + +local function encode_nil(val) + return "null" +end + + +local function encode_table(val, stack) + local res = {} + stack = stack or {} + + -- Circular reference? + if stack[val] then error("circular reference") end + + stack[val] = true + + if rawget(val, 1) ~= nil or next(val) == nil then + -- Treat as array -- check keys are valid and it is not sparse + local n = 0 + for k in pairs(val) do + if type(k) ~= "number" then + error("invalid table: mixed or invalid key types") + end + n = n + 1 + end + if n ~= #val then + error("invalid table: sparse array") + end + -- Encode + for i, v in ipairs(val) do + table.insert(res, encode(v, stack)) + end + stack[val] = nil + return "[" .. table.concat(res, ",") .. "]" + else + -- Treat as an object + for k, v in pairs(val) do + if type(k) ~= "string" then + error("invalid table: mixed or invalid key types") + end + table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) + end + stack[val] = nil + return "{" .. table.concat(res, ",") .. "}" + end +end + + +local function encode_string(val) + return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' +end + + +local function encode_number(val) + -- Check for NaN, -inf and inf + if val ~= val or val <= -math.huge or val >= math.huge then + error("unexpected number value '" .. tostring(val) .. "'") + end + return string.format("%.14g", val) +end + + +local type_func_map = { + ["nil"] = encode_nil, + ["table"] = encode_table, + ["string"] = encode_string, + ["number"] = encode_number, + ["boolean"] = tostring, +} + + +encode = function(val, stack) + local t = type(val) + local f = type_func_map[t] + if f then + return f(val, stack) + end + error("unexpected type '" .. t .. "'") +end + + +function json.encode(val) + return (encode(val)) +end + +------------------------------------------------------------------------------- +-- Decode +------------------------------------------------------------------------------- + +local parse + +local function create_set(...) + local res = {} + for i = 1, select("#", ...) do + res[select(i, ...)] = true + end + return res +end + +local space_chars = create_set(" ", "\t", "\r", "\n") +local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",") +local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") +local literals = create_set("true", "false", "null") + +local literal_map = { + ["true"] = true, + ["false"] = false, + ["null"] = nil, +} + + +local function next_char(str, idx, set, negate) + for i = idx, #str do + if set[str:sub(i, i)] ~= negate then + return i + end + end + return #str + 1 +end + + +local function decode_error(str, idx, msg) + local line_count = 1 + local col_count = 1 + for i = 1, idx - 1 do + col_count = col_count + 1 + if str:sub(i, i) == "\n" then + line_count = line_count + 1 + col_count = 1 + end + end + error(string.format("%s at line %d col %d", msg, line_count, col_count)) +end + + +local function codepoint_to_utf8(n) + -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa + local f = math.floor + if n <= 0x7f then + return string.char(n) + elseif n <= 0x7ff then + return string.char(f(n / 64) + 192, n % 64 + 128) + elseif n <= 0xffff then + return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) + elseif n <= 0x10ffff then + return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, + f(n % 4096 / 64) + 128, n % 64 + 128) + end + error(string.format("invalid unicode codepoint '%x'", n)) +end + + +local function parse_unicode_escape(s) + local n1 = tonumber(s:sub(1, 4), 16) + local n2 = tonumber(s:sub(7, 10), 16) + -- Surrogate pair? + if n2 then + return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) + else + return codepoint_to_utf8(n1) + end +end + + +local function parse_string(str, i) + local res = "" + local j = i + 1 + local k = j + + while j <= #str do + local x = str:byte(j) + + if x < 32 then + decode_error(str, j, "control character in string") + elseif x == 92 then -- `\`: Escape + res = res .. str:sub(k, j - 1) + j = j + 1 + local c = str:sub(j, j) + if c == "u" then + local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1) + or str:match("^%x%x%x%x", j + 1) + or decode_error(str, j - 1, "invalid unicode escape in string") + res = res .. parse_unicode_escape(hex) + j = j + #hex + else + if not escape_chars[c] then + decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string") + end + res = res .. escape_char_map_inv[c] + end + k = j + 1 + elseif x == 34 then -- `"`: End of string + res = res .. str:sub(k, j - 1) + return res, j + 1 + end + + j = j + 1 + end + + decode_error(str, i, "expected closing quote for string") +end + + +local function parse_number(str, i) + local x = next_char(str, i, delim_chars) + local s = str:sub(i, x - 1) + local n = tonumber(s) + if not n then + decode_error(str, i, "invalid number '" .. s .. "'") + end + return n, x +end + + +local function parse_literal(str, i) + local x = next_char(str, i, delim_chars) + local word = str:sub(i, x - 1) + if not literals[word] then + decode_error(str, i, "invalid literal '" .. word .. "'") + end + return literal_map[word], x +end + + +local function parse_array(str, i) + local res = {} + local n = 1 + i = i + 1 + while 1 do + local x + i = next_char(str, i, space_chars, true) + -- Empty / end of array? + if str:sub(i, i) == "]" then + i = i + 1 + break + end + -- Read token + x, i = parse(str, i) + res[n] = x + n = n + 1 + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "]" then break end + if chr ~= "," then decode_error(str, i, "expected ']' or ','") end + end + return res, i +end + + +local function parse_object(str, i) + local res = {} + i = i + 1 + while 1 do + local key, val + i = next_char(str, i, space_chars, true) + -- Empty / end of object? + if str:sub(i, i) == "}" then + i = i + 1 + break + end + -- Read key + if str:sub(i, i) ~= '"' then + decode_error(str, i, "expected string for key") + end + key, i = parse(str, i) + -- Read ':' delimiter + i = next_char(str, i, space_chars, true) + if str:sub(i, i) ~= ":" then + decode_error(str, i, "expected ':' after key") + end + i = next_char(str, i + 1, space_chars, true) + -- Read value + val, i = parse(str, i) + -- Set + res[key] = val + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "}" then break end + if chr ~= "," then decode_error(str, i, "expected '}' or ','") end + end + return res, i +end + + +local char_func_map = { + ['"'] = parse_string, + ["0"] = parse_number, + ["1"] = parse_number, + ["2"] = parse_number, + ["3"] = parse_number, + ["4"] = parse_number, + ["5"] = parse_number, + ["6"] = parse_number, + ["7"] = parse_number, + ["8"] = parse_number, + ["9"] = parse_number, + ["-"] = parse_number, + ["t"] = parse_literal, + ["f"] = parse_literal, + ["n"] = parse_literal, + ["["] = parse_array, + ["{"] = parse_object, +} + + +parse = function(str, idx) + local chr = str:sub(idx, idx) + local f = char_func_map[chr] + if f then + return f(str, idx) + end + decode_error(str, idx, "unexpected character '" .. chr .. "'") +end + + +function json.decode(str) + if type(str) ~= "string" then + error("expected argument of type string, got " .. type(str)) + end + local res, idx = parse(str, next_char(str, 1, space_chars, true)) + idx = next_char(str, idx, space_chars, true) + if idx <= #str then + decode_error(str, idx, "trailing garbage") + end + return res +end + +return json diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/menu.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/menu.lua new file mode 100644 index 0000000..3dc767a --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/menu.lua @@ -0,0 +1,342 @@ +local awful = require("awful") +local gtable = require("gears.table") +local gtimer = require("gears.timer") +local wibox = require("wibox") +local beautiful = require("beautiful") +local helpers = require("helpers") +local dpi = beautiful.xresources.apply_dpi +local setmetatable = setmetatable +local ipairs = ipairs +local capi = { awesome = awesome, mouse = mouse, tag = tag } + +local menu = { mt = {} } + +function menu:set_pos(args) + args = args or {} + + local coords = args.coords + local wibox = args.wibox + local widget = args.widget + local offset = args.offset or { x = 0, y = 0 } + + if offset.x == nil then + offset.x = 0 + end + if offset.y == nil then + offset.y = 0 + end + + local screen_workarea = awful.screen.focused().workarea + local screen_w = screen_workarea.x + screen_workarea.width + local screen_h = screen_workarea.y + screen_workarea.height + + if not coords and wibox and widget then + coords = helpers.get_widget_geometry(wibox, widget) + else + coords = args.coords or capi.mouse.coords() + end + + if coords.x + self.width > screen_w then + if self.parent_menu ~= nil then + self.x = coords.x - (self.width * 2) - offset.x + else + self.x = coords.x - self.width + offset.x + end + else + self.x = coords.x + offset.x + end + + if coords.y + self.height > screen_h then + self.y = screen_h - self.height + offset.y + else + self.y = coords.y + offset.y + end +end + +function menu:hide_parents_menus() + if self.parent_menu ~= nil then + self.parent_menu:hide(true) + end +end + +function menu:hide_children_menus() + if self.widget then + for _, button in ipairs(self.widget.children) do + if button.sub_menu ~= nil then + button.sub_menu:hide() + end + end + end +end + +function menu:hide(hide_parents) + if self.visible == false then + return + end + + -- Hide self + self.visible = false + + -- Hides all child menus + self:hide_children_menus() + + if hide_parents == true then + self:hide_parents_menus() + end +end + +function menu:show(args) + if self.visible == true then + return + end + + self.can_hide = false + + gtimer({ + timeout = 0.1, + autostart = true, + call_now = false, + single_shot = true, + callback = function() + self.can_hide = true + end, + }) + + -- Hide sub menus belonging to the menu of self + if self.parent_menu ~= nil then + for _, button in ipairs(self.parent_menu.widget.children) do + if button.sub_menu ~= nil and button.sub_menu ~= self then + button.sub_menu:hide() + end + end + end + + self:set_pos(args) + self.visible = true + + capi.awesome.emit_signal("menu::toggled_on", self) +end + +function menu:toggle(args) + if self.visible == true then + self:hide() + else + self:show(args) + end +end + +function menu:add(widget) + if widget.sub_menu then + widget.sub_menu.parent_menu = self + end + widget.menu = self + self.widget:add(widget) +end + +function menu:remove(widget) + self.widget:remove(widget) +end + +function menu:reset() + self.widget:reset() +end + +function menu.menu(widgets, width) + local widget = awful.popup({ + x = 32500, + type = "menu", + visible = false, + ontop = true, + minimum_width = width or dpi(300), + maximum_width = width or dpi(300), + shape = helpers.rrect(9), + bg = beautiful.main_menu_bg, + widget = wibox.layout.fixed.vertical, + }) + gtable.crush(widget, menu, true) + + awful.mouse.append_client_mousebinding(awful.button({ "Any" }, 1, function(c) + if widget.can_hide == true then + widget:hide(true) + end + end)) + + awful.mouse.append_client_mousebinding(awful.button({ "Any" }, 3, function(c) + if widget.can_hide == true then + widget:hide(true) + end + end)) + + awful.mouse.append_global_mousebinding(awful.button({ "Any" }, 1, function(c) + if widget.can_hide == true then + widget:hide(true) + end + end)) + + awful.mouse.append_global_mousebinding(awful.button({ "Any" }, 3, function(c) + if widget.can_hide == true then + widget:hide(true) + end + end)) + + capi.tag.connect_signal("property::selected", function(t) + widget:hide(true) + end) + + capi.awesome.connect_signal("menu::toggled_on", function(menu) + if menu ~= widget and menu.parent_menu == nil then + widget:hide(true) + end + end) + + for _, menu_widget in ipairs(widgets) do + widget:add(menu_widget) + end + + return widget +end + +function menu.sub_menu_button(args) + args = args or {} + + args.icon = args.icon or nil + args.icon_size = args.icon_size or 16 + args.text = args.text or "" + args.text_size = args.text_size or 12 + args.sub_menu = args.sub_menu or nil + + local icon = args.icon ~= nil + and wibox.widget { + font = args.icon.font .. " " .. args.icon_size, + markup = helpers.colorizeText(args.icon.icon, helpers.randomColor()), + widget = wibox.widget.textbox, + halign = "start", + forced_width = 40, + } or nil + + local widget = wibox.widget { + { + { + layout = wibox.layout.align.horizontal, + forced_width = dpi(270), + { + layout = wibox.layout.fixed.horizontal, + spacing = dpi(10), + icon, + { + font = beautiful.sans .. " " .. args.text_size, + markup = args.text, + widget = wibox.widget.textbox, + halign = "start" + }, + }, + nil, + { + font = beautiful.icon .. " " .. "18", + markup = "󰅂", + widget = wibox.widget.textbox, + halign = "start" + }, + }, + widget = wibox.container.margin, + margins = 10 + }, + bg = beautiful.bg, + forced_height = 48, + shape = helpers.rrect(9), + widget = wibox.container.background, + } + widget:connect_signal("mouse::enter", function(self) + local coords = helpers.get_widget_geometry(self.menu, self) + coords.x = coords.x + self.menu.x + self.menu.width + coords.y = coords.y + self.menu.y + args.sub_menu:show({ coords = coords, offset = { x = -5 } }) + end) + widget.sub_menu = args.sub_menu + + return widget +end + +function menu.button(args) + args = args or {} + + args.icon = args.icon or nil + args.icon_size = args.icon_size or 16 + args.image = args.image + args.text = args.text or "" + args.text_size = args.text_size or 12 + args.on_press = args.on_press or nil + + local icon = nil + + if args.icon ~= nil then + icon = wibox.widget { + font = args.icon.font .. " " .. args.icon_size, + markup = helpers.colorizeText(args.icon.icon, helpers.randomColor()), + widget = wibox.widget.textbox, + halign = "start" + } + elseif args.image ~= nil then + icon = wibox.widget({ + widget = wibox.widget.imagebox, + image = args.image, + }) + end + + local text_widget = wibox.widget { + font = beautiful.sans .. " " .. args.text_size, + markup = args.text, + widget = wibox.widget.textbox, + halign = "start" + } + + local widget = wibox.widget { + { + { + layout = wibox.layout.fixed.horizontal, + spacing = dpi(15), + icon, + text_widget, + }, + widget = wibox.container.margin, + margins = 10 + }, + bg = beautiful.bg, + forced_height = 48, + shape = helpers.rrect(9), + buttons = { + awful.button({}, 1, function() + args.on_press(menu, text_widget) + menu:hide(true) + end) + }, + widget = wibox.container.background, + } + widget:connect_signal("mouse::enter", function(self) + if self.menu.widget then self.menu:hide_children_menus() end + end) + return widget +end + +function menu.separator() + return wibox.widget({ + widget = wibox.container.margin, + top = 10, + bottom = 10, + left = 40, + right = 40, + { + widget = wibox.widget.separator, + forced_height = dpi(2), + orientation = "horizontal", + thickness = dpi(1), + color = beautiful.fg .. "29", + }, + }) +end + +function menu.mt:__call(...) + return menu.menu(...) +end + +return setmetatable(menu, menu.mt) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/overflow.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/overflow.lua new file mode 100644 index 0000000..079e0db --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/overflow.lua @@ -0,0 +1,534 @@ +------------------------------------------- +-- @author https://github.com/Kasper24 +-- @copyright 2021-2022 Kasper24 +------------------------------------------- +--------------------------------------------------------------------------- +-- A layout that allows its children to take more space than what's available +-- in the surrounding container. If the content does exceed the available +-- size, a scrollbar is added and scrolling behavior enabled. +-- +-- @DOC_wibox_layout_defaults_overflow_EXAMPLE@ +-- @author Lucas Schwiderski +-- @copyright 2021 Lucas Schwiderski +-- @layoutmod wibox.layout.overflow +-- @supermodule wibox.layout.fixed +--------------------------------------------------------------------------- +local base = require('wibox.widget.base') +local fixed = require('wibox.layout.fixed') +local separator = require('wibox.widget.separator') +local gtable = require('gears.table') +local gshape = require('gears.shape') +local gobject = require('gears.object') +local beautiful = require('beautiful') +local dpi = beautiful.xresources.apply_dpi +local mousegrabber = mousegrabber + +local overflow = { + mt = {} +} + +-- Determine the required space to draw the layout's children and, if necessary, +-- the scrollbar. +function overflow:fit(context, orig_width, orig_height) + local widgets = self._private.widgets + local num_widgets = #widgets + if num_widgets < 1 then + return 0, 0 + end + + local width, height = orig_width, orig_height + local scrollbar_width = self._private.scrollbar_width + local scrollbar_enabled = self._private.scrollbar_enabled + local used_in_dir, used_max = 0, 0 + local is_y = self._private.dir == "y" + local avail_in_dir = is_y and orig_height or orig_width + + -- Set the direction covered by scrolling to the maximum value + -- to allow widgets to take as much space as they want. + if is_y then + height = math.huge + else + width = math.huge + end + + -- First, determine widget sizes. + -- Only when the content doesn't fit and needs scrolling should + -- we reduce content size to make space for a scrollbar. + for _, widget in ipairs(widgets) do + local w, h = base.fit_widget(self, context, widget, width, height) + + if is_y then + used_max = math.max(used_max, w) + used_in_dir = used_in_dir + h + else + used_max = math.max(used_max, h) + used_in_dir = used_in_dir + w + end + end + + local spacing = self._private.spacing * (num_widgets - 1) + used_in_dir = used_in_dir + spacing + + local need_scrollbar = scrollbar_enabled and used_in_dir > avail_in_dir + + -- Even if `used_max == orig_(width|height)` already, `base.fit_widget` + -- will clamp return values, so we can "overextend" here. + if need_scrollbar then + used_max = used_max + scrollbar_width + end + + if is_y then + return used_max, used_in_dir + else + return used_in_dir, used_max + end +end + +-- Layout children, scrollbar and spacing widgets. +-- Only those widgets that are currently visible will be placed. +function overflow:layout(context, orig_width, orig_height) + local result = {} + local is_y = self._private.dir == "y" + local widgets = self._private.widgets + local avail_in_dir = is_y and orig_height or orig_width + local scrollbar_width = self._private.scrollbar_width + local scrollbar_enabled = self._private.scrollbar_enabled + local scrollbar_position = self._private.scrollbar_position + local width, height = orig_width, orig_height + local widget_x, widget_y = 0, 0 + local used_in_dir, used_max = 0, 0 + + -- Set the direction covered by scrolling to the maximum value + -- to allow widgets to take as much space as they want. + if is_y then + height = math.huge + else + width = math.huge + end + + -- First, determine widget sizes. + -- Only when the content doesn't fit and needs scrolling should + -- we reduce content size to make space for a scrollbar. + for _, widget in pairs(widgets) do + local w, h = base.fit_widget(self, context, widget, width, height) + + if is_y then + used_max = math.max(used_max, w) + used_in_dir = used_in_dir + h + else + used_max = math.max(used_max, h) + used_in_dir = used_in_dir + w + end + end + + used_in_dir = used_in_dir + self._private.spacing * (#widgets - 1) + + -- Save size for scrolling behavior + self._private.avail_in_dir = avail_in_dir + self._private.used_in_dir = used_in_dir + + local need_scrollbar = used_in_dir > avail_in_dir and scrollbar_enabled + + local scroll_position = self._private.scroll_factor + + if need_scrollbar then + local scrollbar_widget = self._private.scrollbar_widget + local bar_x, bar_y = 0, 0 + local bar_w, bar_h + -- The percentage of how much of the content can be visible within + -- the available space + local visible_percent = avail_in_dir / used_in_dir + -- Make scrollbar length reflect `visible_percent` + -- TODO: Apply a default minimum length + local bar_length = math.floor(visible_percent * avail_in_dir) + local bar_pos = (avail_in_dir - bar_length) * self._private.scroll_factor + + if is_y then + bar_w, bar_h = base.fit_widget(self, context, scrollbar_widget, scrollbar_width, bar_length) + bar_y = bar_pos + + if scrollbar_position == "left" then + widget_x = widget_x + bar_w + elseif scrollbar_position == "right" then + bar_x = orig_width - bar_w + end + + self._private.bar_length = bar_h + + width = width - bar_w + else + bar_w, bar_h = base.fit_widget(self, context, scrollbar_widget, bar_length, scrollbar_width) + bar_x = bar_pos + + if scrollbar_position == "top" then + widget_y = widget_y + bar_h + elseif scrollbar_position == "bottom" then + bar_y = orig_height - bar_h + end + + self._private.bar_length = bar_w + + height = height - bar_h + end + + table.insert(result, base.place_widget_at(scrollbar_widget, math.floor(bar_x), math.floor(bar_y), + math.floor(bar_w), math.floor(bar_h))) + end + + local pos, spacing = 0, self._private.spacing + local interval = used_in_dir - avail_in_dir + + local spacing_widget = self._private.spacing_widget + if spacing_widget then + if is_y then + local _ + _, spacing = base.fit_widget(self, context, spacing_widget, width, spacing) + else + spacing = base.fit_widget(self, context, spacing_widget, spacing, height) + end + end + + for i, w in ipairs(widgets) do + local content_x, content_y + local content_w, content_h = base.fit_widget(self, context, w, + need_scrollbar and width - self._private.scrollbar_spacing or width, height) + + -- When scrolling down, the content itself moves up -> substract + local scrolled_pos = pos - (scroll_position * interval) + + -- Stop processing completely once we're passed the visible portion + if scrolled_pos > avail_in_dir then + break + end + + if is_y then + content_x, content_y = widget_x, scrolled_pos + pos = pos + content_h + spacing + + if self._private.fill_space then + content_w = width + end + else + content_x, content_y = scrolled_pos, widget_y + pos = pos + content_w + spacing + + if self._private.fill_space then + content_h = height + end + end + + local is_in_view = is_y and (scrolled_pos + content_h > 0) or (scrolled_pos + content_w > 0) + + if is_in_view then + -- Add the spacing widget, but not before the first widget + if i > 1 and spacing_widget then + table.insert(result, + base.place_widget_at(spacing_widget, -- The way how spacing is added for regular widgets + -- and the `spacing_widget` is disconnected: + -- The offset for regular widgets is added to `pos` one + -- iteration _before_ the one where the widget is actually + -- placed. + -- Because of that, the placement for the spacing widget + -- needs to substract that offset to be placed right after + -- the previous regular widget. + math.floor(is_y and content_x or (content_x - spacing)), + math.floor(is_y and (content_y - spacing) or content_y), + math.floor(is_y and content_w or spacing), math.floor(is_y and spacing or content_h))) + end + table.insert(result, base.place_widget_at(w, math.floor(content_x), math.floor(content_y), + math.floor(need_scrollbar and content_w - self._private.scrollbar_spacing or content_w), + math.floor(content_h))) + end + end + + return result +end + +function overflow:before_draw_children(_, cr, width, height) + -- Clip drawing for children to the space we're allowed to draw in + cr:rectangle(0, 0, width, height) + cr:clip() +end + +--- The amount of units to advance per scroll event. +-- +-- This affects calls to `scroll` and the default mouse wheel handler. +-- +-- The default is `10`. +-- +-- @property step +-- @tparam number step The step size. +function overflow:set_step(step) + self._private.step = step + -- We don't need to emit enything here, since changing step only really + -- takes effect the next time the user scrolls +end + +--- Scroll the layout's content by `amount * step`. +-- +-- A positive amount scroll down/right, a negative amount scrolls up/left. +-- +-- The amount of units scrolled is affected by `step`. +-- +-- @method overflow:scroll +-- @tparam number amount The amount to scroll by. +-- @emits property::overflow::scroll_factor +-- @emitstparam property::overflow::scroll_factor number scroll_factor The new +-- scroll factor. +-- @emits widget::layout_changed +-- @emits widget::redraw_needed +function overflow:scroll(amount) + if amount == 0 then + return + end + local interval = self._private.used_in_dir + local delta = self._private.step / interval + + local factor = self._private.scroll_factor + (delta * amount) + self:set_scroll_factor(factor) +end + +--- The scroll factor. +-- +-- The scroll factor represents how far the layout's content is currently +-- scrolled. It is represented as a fraction from `0` to `1`, where `0` is the +-- start of the content and `1` is the end. +-- +-- @property scroll_factor +-- @tparam number scroll_factor The scroll factor. +-- @propemits true false + +function overflow:set_scroll_factor(factor) + local current = self._private.scroll_factor + local interval = self._private.used_in_dir - self._private.avail_in_dir + if current == factor -- the content takes less space than what is available, i.e. everything + -- is already visible + or interval <= 0 -- the scroll factor is out of range + or (current <= 0 and factor < 0) or (current >= 1 and factor > 1) then + return + end + + self._private.scroll_factor = math.min(1, math.max(factor, 0)) + + self:emit_signal("widget::layout_changed") + self:emit_signal("property::scroll_factor", factor) +end + +function overflow:get_scroll_factor() + return self._private.scroll_factor +end + +--- The scrollbar width. +-- +-- For horizontal scrollbars, this is the scrollbar height +-- +-- The default is `5`. +-- +-- @DOC_wibox_layout_overflow_scrollbar_width_EXAMPLE@ +-- +-- @property scrollbar_width +-- @tparam number scrollbar_width The scrollbar width. +-- @propemits true false + +function overflow:set_scrollbar_width(width) + if self._private.scrollbar_width == width then + return + end + + self._private.scrollbar_width = width + + self:emit_signal("widget::layout_changed") + self:emit_signal("property::scrollbar_width", width) +end + +--- The scrollbar position. +-- +-- For horizontal scrollbars, this can be `"top"` or `"bottom"`, +-- for vertical scrollbars this can be `"left"` or `"right"`. +-- The default is `"right"`/`"bottom"`. +-- +-- @DOC_wibox_layout_overflow_scrollbar_position_EXAMPLE@ +-- +-- @property scrollbar_position +-- @tparam string scrollbar_position The scrollbar position. +-- @propemits true false + +function overflow:set_scrollbar_position(position) + if self._private.scrollbar_position == position then + return + end + + self._private.scrollbar_position = position + + self:emit_signal("widget::layout_changed") + self:emit_signal("property::scrollbar_position", position) +end + +function overflow:get_scrollbar_position() + return self._private.scrollbar_position +end + +--- The scrollbar visibility. +-- +-- If this is set to `false`, no scrollbar will be rendered, even if the layout's +-- content overflows. Mouse wheel scrolling will work regardless. +-- +-- The default is `true`. +-- +-- @property scrollbar_enabled +-- @tparam boolean scrollbar_enabled The scrollbar visibility. +-- @propemits true false + +function overflow:set_scrollbar_enabled(enabled) + if self._private.scrollbar_enabled == enabled then + return + end + + self._private.scrollbar_enabled = enabled + + self:emit_signal("widget::layout_changed") + self:emit_signal("property::scrollbar_enabled", enabled) +end + +function overflow:get_scrollbar_enabled() + return self._private.scrollbar_enabled +end + +-- Wraps a callback function for `mousegrabber` that is capable of +-- updating the scroll factor. +local function build_grabber(container, initial_x, initial_y, geo) + local is_y = container._private.dir == "y" + local bar_interval = container._private.avail_in_dir - container._private.bar_length + local start_pos = container._private.scroll_factor * bar_interval + local start = is_y and initial_y or initial_x + + -- Calculate a matrix transforming from screen coordinates into widget + -- coordinates. + -- This is required for mouse movement to work when the widget has been + -- transformed by something like `wibox.container.rotate`. + local matrix_from_device = geo.hierarchy:get_matrix_from_device() + local wgeo = geo.drawable.drawable:geometry() + local matrix = matrix_from_device:translate( -wgeo.x, -wgeo.y) + + return function(mouse) + if not mouse.buttons[1] then + return false + end + + local x, y = matrix:transform_point(mouse.x, mouse.y) + local pos = is_y and y or x + container:set_scroll_factor((start_pos + (pos - start)) / bar_interval) + + return true + end +end + +-- Applies a mouse button signal using `build_grabber` to a scrollbar widget. +local function apply_scrollbar_mouse_signal(container, w) + w:connect_signal('button::press', function(_, x, y, button_id, _, geo) + if button_id ~= 1 then + return + end + mousegrabber.run(build_grabber(container, x, y, geo), "fleur") + end) +end + +--- The scrollbar widget. +-- This widget is rendered as the scrollbar element. +-- +-- The default is `wibox.widget.separator{ shape = gears.shape.rectangle }`. +-- +-- @DOC_wibox_layout_overflow_scrollbar_widget_EXAMPLE@ +-- +-- @property scrollbar_widget +-- @tparam widget scrollbar_widget The scrollbar widget. +-- @propemits true false + +function overflow:set_scrollbar_widget(widget) + local w = base.make_widget_from_value(widget) + + apply_scrollbar_mouse_signal(self, w) + + self._private.scrollbar_widget = w + + self:emit_signal("widget::layout_changed") + self:emit_signal("property::scrollbar_widget", widget) +end + +function overflow:get_scrollbar_widget() + return self._private.scrollbar_widget +end + +function overflow:set_scrollbar_spacing(spacing) + self._private.scrollbar_spacing = spacing + + self:emit_signal("widget::layout_changed") + self:emit_signal("property::scrollbar_spacing", spacing) +end + +function overflow:get_scrollbar_spacing() + return self._private.scrollbar_spacing +end + +local function new(dir, ...) + local ret = fixed[dir](...) + + gtable.crush(ret, overflow, true) + ret.widget_name = gobject.modulename(2) + -- Tell the widget system to prevent clicks outside the layout's extends + -- to register with child widgets, even if they actually extend that far. + -- This prevents triggering button presses on hidden/clipped widgets. + ret.clip_child_extends = true + + -- Manually set the scroll factor here. We don't know the bounding size yet. + ret._private.scroll_factor = 0 + + -- Apply defaults. Bypass setters to avoid signals. + ret._private.step = 10 + ret._private.fill_space = true + ret._private.scrollbar_width = 5 + ret._private.scrollbar_enabled = true + ret._private.scrollbar_position = dir == "vertical" and "right" or "bottom" + ret._private.scrollbar_spacing = dpi(15) + + local scrollbar_widget = separator({ + shape = gshape.rectangle + }) + apply_scrollbar_mouse_signal(ret, scrollbar_widget) + ret._private.scrollbar_widget = scrollbar_widget + + ret:connect_signal('button::press', function(self, _, _, button) + if button == 4 then + self:scroll( -1) + elseif button == 5 then + self:scroll(1) + end + end) + + return ret +end + +--- Returns a new horizontal overflow layout. +-- Child widgets are placed similar to `wibox.layout.fixed`, except that +-- they may take as much width as they want. If the total width of all child +-- widgets exceeds the width available whithin the layout's outer container +-- a scrollbar will be added and scrolling behavior enabled. +-- @tparam widget ... Widgets that should be added to the layout. +-- @constructorfct wibox.layout.overflow.horizontal +function overflow.horizontal(...) + return new("horizontal", ...) +end + +--- Returns a new vertical overflow layout. +-- Child widgets are placed similar to `wibox.layout.fixed`, except that +-- they may take as much height as they want. If the total height of all child +-- widgets exceeds the height available whithin the layout's outer container +-- a scrollbar will be added and scrolling behavior enabled. +-- @tparam widget ... Widgets that should be added to the layout. +-- @constructorfct wibox.layout.overflow.horizontal +function overflow.vertical(...) + return new("vertical", ...) +end + +return setmetatable(overflow, overflow.mt) + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/init.lua new file mode 100644 index 0000000..e60d77d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/init.lua @@ -0,0 +1,46 @@ +local awful = require("awful") +local gtimer = require("gears.timer") +local beautiful = require("beautiful") +local naughty = require("naughty") + +-- Use CLI backend as default as it is supported on most if not all systems +local backend_config = beautiful.playerctl_backend or "playerctl_cli" +local backends = { + playerctl_cli = require(... .. ".playerctl_cli"), + playerctl_lib = require(... .. ".playerctl_lib"), +} + +local backend = nil + +local function enable_wrapper(args) + local open = naughty.action { name = "Open" } + + open:connect_signal("invoked", function() + awful.spawn("xdg-open https://blingcorp.github.io/bling/#/signals/pctl") + end) + + gtimer.delayed_call(function() + naughty.notify({ + title = "Bling Error", + text = "Global signals are deprecated! Please take a look at the playerctl documentation.", + app_name = "Bling Error", + app_icon = "system-error", + actions = { open } + }) + end) + + backend_config = (args and args.backend) or backend_config + backend = backends[backend_config](args) + return backend +end + +local function disable_wrapper() + backend:disable() +end + +return { + lib = backends.playerctl_lib, + cli = backends.playerctl_cli, + enable = enable_wrapper, + disable = disable_wrapper +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/playerctl_cli.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/playerctl_cli.lua new file mode 100644 index 0000000..e220f53 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/playerctl_cli.lua @@ -0,0 +1,355 @@ +-- Playerctl signals +-- +-- Provides: +-- metadata +-- title (string) +-- artist (string) +-- album_path (string) +-- album (string) +-- player_name (string) +-- position +-- interval_sec (number) +-- length_sec (number) +-- playback_status +-- playing (boolean) +-- volume +-- volume (number) +-- loop_status +-- loop_status (string) +-- shuffle +-- shuffle (bool) +-- no_players +-- (No parameters) + +local awful = require("awful") +local gobject = require("gears.object") +local gtable = require("gears.table") +local gtimer = require("gears.timer") +local gstring = require("gears.string") +local beautiful = require("beautiful") +local setmetatable = setmetatable +local tonumber = tonumber +local ipairs = ipairs +local type = type +local capi = { awesome = awesome } + +local playerctl = { mt = {} } + +local function save_image_async_curl(url, filepath, callback) + awful.spawn.with_line_callback(string.format("curl -L -s %s -o %s", url, filepath), + { + exit = callback + }) +end + +function playerctl:disable() + self._private.metadata_timer:stop() + self._private.metadata_timer = nil + awful.spawn.with_shell("killall playerctl") +end + +function playerctl:pause(player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " pause") + else + awful.spawn.with_shell(self._private.cmd .. "pause") + end +end + +function playerctl:play(player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " play") + else + awful.spawn.with_shell(self._private.cmd .. "play") + end +end + +function playerctl:stop(player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " stop") + else + awful.spawn.with_shell(self._private.cmd .. "stop") + end +end + +function playerctl:play_pause(player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " play-pause") + else + awful.spawn.with_shell(self._private.cmd .. "play-pause") + end +end + +function playerctl:previous(player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " previous") + else + awful.spawn.with_shell(self._private.cmd .. "previous") + end +end + +function playerctl:next(player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " next") + else + awful.spawn.with_shell(self._private.cmd .. "next") + end +end + +function playerctl:set_loop_status(loop_status, player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " loop " .. loop_status) + else + awful.spawn.with_shell(self._private.cmd .. "loop " .. loop_status) + end +end + +function playerctl:cycle_loop_status(player) + local function set_loop_status(loop_status) + if loop_status == "None" then + self:set_loop_status("Track") + elseif loop_status == "Track" then + self:set_loop_status("Playlist") + elseif loop_status == "Playlist" then + self:set_loop_status("None") + end + end + + if player ~= nil then + awful.spawn.easy_async_with_shell("playerctl --player=" .. player .. " loop", function(stdout) + set_loop_status(stdout) + end) + else + set_loop_status(self._private.loop_status) + end +end + +function playerctl:set_position(position, player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " position " .. position) + else + awful.spawn.with_shell(self._private.cmd .. "position " .. position) + end +end + +function playerctl:set_shuffle(shuffle, player) + shuffle = shuffle and "on" or "off" + + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " shuffle " .. shuffle) + else + awful.spawn.with_shell(self._private.cmd .. "shuffle " .. shuffle) + end +end + +function playerctl:cycle_shuffle(player) + if player ~= nil then + awful.spawn.easy_async_with_shell("playerctl --player=" .. player .. " shuffle", function(stdout) + local shuffle = stdout == "on" and true or false + self:set_shuffle(not self._private.shuffle) + end) + else + self:set_shuffle(not self._private.shuffle) + end +end + +function playerctl:set_volume(volume, player) + if player ~= nil then + awful.spawn.with_shell("playerctl --player=" .. player .. " volume " .. volume) + else + awful.spawn.with_shell(self._private.cmd .. "volume " .. volume) + end +end + +local function emit_player_metadata(self) + local metadata_cmd = self._private.cmd .. + "metadata --format 'title_{{title}}artist_{{artist}}art_url_{{mpris:artUrl}}player_name_{{playerName}}album_{{album}}' -F" + + awful.spawn.with_line_callback(metadata_cmd, { + stdout = function(line) + local title = gstring.xml_escape(line:match('title_(.*)artist_')) or "" + local artist = gstring.xml_escape(line:match('artist_(.*)art_url_')) or "" + local art_url = line:match('art_url_(.*)player_name_') or "" + local player_name = line:match('player_name_(.*)album_') or "" + local album = gstring.xml_escape(line:match('album_(.*)')) or "" + + art_url = art_url:gsub('%\n', '') + if player_name == "spotify" then + art_url = art_url:gsub("open.spotify.com", "i.scdn.co") + end + + if self._private.metadata_timer + and self._private.metadata_timer.started + then + self._private.metadata_timer:stop() + end + + self._private.metadata_timer = gtimer { + timeout = self.debounce_delay, + autostart = true, + single_shot = true, + callback = function() + if title and title ~= "" then + if art_url ~= "" then + local art_path = os.tmpname() + save_image_async_curl(art_url, art_path, function() + self:emit_signal("metadata", title, artist, art_path, album, player_name) + capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, art_path) + end) + else + self:emit_signal("metadata", title, artist, "", album, player_name) + capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, "") + end + else + self:emit_signal("no_players") + capi.awesome.emit_signal("bling::playerctl::no_players") + end + end + } + + collectgarbage("collect") + end, + }) +end + +local function emit_player_position(self) + local position_cmd = self._private.cmd .. "position" + local length_cmd = self._private.cmd .. "metadata mpris:length" + + awful.widget.watch(position_cmd, self.interval, function(_, interval) + awful.spawn.easy_async_with_shell(length_cmd, function(length) + local length_sec = tonumber(length) -- in microseconds + local interval_sec = tonumber(interval) -- in seconds + if length_sec and interval_sec then + if interval_sec >= 0 and length_sec > 0 then + self:emit_signal("position", interval_sec, length_sec / 1000000) + capi.awesome.emit_signal("bling::playerctl::position", interval_sec, length_sec / 1000000) + end + end + end) + collectgarbage("collect") + end) +end + +local function emit_player_playback_status(self) + local status_cmd = self._private.cmd .. "status -F" + + awful.spawn.with_line_callback(status_cmd, { + stdout = function(line) + if line:find("Playing") then + self:emit_signal("playback_status", true) + capi.awesome.emit_signal("bling::playerctl::status", true) + else + self:emit_signal("playback_status", false) + capi.awesome.emit_signal("bling::playerctl::status", false) + end + end, + }) +end + +local function emit_player_volume(self) + local volume_cmd = self._private.cmd .. "volume -F" + + awful.spawn.with_line_callback(volume_cmd, { + stdout = function(line) + self:emit_signal("volume", tonumber(line)) + end, + }) +end + +local function emit_player_loop_status(self) + local loop_status_cmd = self._private.cmd .. "loop -F" + + awful.spawn.with_line_callback(loop_status_cmd, { + stdout = function(line) + self._private.loop_status = line + self:emit_signal("loop_status", line:lower()) + end, + }) +end + +local function emit_player_shuffle(self) + local shuffle_cmd = self._private.cmd .. "shuffle -F" + + awful.spawn.with_line_callback(shuffle_cmd, { + stdout = function(line) + if line:find("On") then + self._private.shuffle = true + self:emit_signal("shuffle", true) + else + self._private.shuffle = false + self:emit_signal("shuffle", false) + end + end, + }) +end + +local function parse_args(self, args) + if args.player then + self._private.cmd = self._private.cmd .. "--player=" + + if type(args.player) == "string" then + self._private.cmd = self._private.cmd .. args.player .. " " + elseif type(args.player) == "table" then + for index, player in ipairs(args.player) do + self._private.cmd = self._private.cmd .. player + if index < #args.player then + self._private.cmd = self._private.cmd .. "," + else + self._private.cmd = self._private.cmd .. " " + end + end + end + end + + if args.ignore then + self._private.cmd = self._private.cmd .. "--ignore-player=" + + if type(args.ignore) == "string" then + self._private.cmd = self._private.cmd .. args.ignore .. " " + elseif type(args.ignore) == "table" then + for index, player in ipairs(args.ignore) do + self._private.cmd = self._private.cmd .. player + if index < #args.ignore then + self._private.cmd = self._private.cmd .. "," + else + self._private.cmd = self._private.cmd .. " " + end + end + end + end +end + +local function new(args) + args = args or {} + + local ret = gobject {} + gtable.crush(ret, playerctl, true) + + ret.interval = args.interval or beautiful.playerctl_position_update_interval or 1 + ret.debounce_delay = args.debounce_delay or beautiful.playerctl_debounce_delay or 0.35 + + ret._private = {} + ret._private.metadata_timer = nil + ret._private.cmd = "playerctl " + parse_args(ret, args) + + emit_player_metadata(ret) + emit_player_position(ret) + emit_player_playback_status(ret) + emit_player_volume(ret) + emit_player_loop_status(ret) + emit_player_shuffle(ret) + + return ret +end + +function playerctl.mt:__call(...) + return new(...) +end + +-- On startup instead of on playerctl object init to make it +-- possible to have more than one of these running +awful.spawn.with_shell("killall playerctl") + +return setmetatable(playerctl, playerctl.mt) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/playerctl_lib.lua b/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/playerctl_lib.lua new file mode 100644 index 0000000..faf9a4c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/mods/playerctl/playerctl_lib.lua @@ -0,0 +1,569 @@ +-- Playerctl signals +-- +-- Provides: +-- metadata +-- title (string) +-- artist (string) +-- album_path (string) +-- album (string) +-- new (bool) +-- player_name (string) +-- position +-- interval_sec (number) +-- length_sec (number) +-- player_name (string) +-- playback_status +-- playing (boolean) +-- player_name (string) +-- seeked +-- position (number) +-- player_name (string) +-- volume +-- volume (number) +-- player_name (string) +-- loop_status +-- loop_status (string) +-- player_name (string) +-- shuffle +-- shuffle (boolean) +-- player_name (string) +-- exit +-- player_name (string) +-- no_players +-- (No parameters) + +local awful = require("awful") +local gobject = require("gears.object") +local gtable = require("gears.table") +local gtimer = require("gears.timer") +local gstring = require("gears.string") +local beautiful = require("beautiful") +local setmetatable = setmetatable +local ipairs = ipairs +local pairs = pairs +local type = type +local capi = { awesome = awesome } + +local playerctl = { mt = {} } + + +local function save_image_async_curl(url, filepath, callback) + awful.spawn.with_line_callback(string.format("curl -L -s %s -o %s", url, filepath), + { + exit = callback + }) +end + +function playerctl:disable() + -- Restore default settings + self.ignore = {} + self.priority = {} + self.update_on_activity = true + self.interval = 1 + self.debounce_delay = 0.35 + + -- Reset timers + self._private.manager = nil + self._private.metadata_timer:stop() + self._private.metadata_timer = nil + self._private.position_timer:stop() + self._private.position_timer = nil + + -- Reset default values + self._private.last_position = -1 + self._private.last_length = -1 + self._private.last_player = nil + self._private.last_title = "" + self._private.last_artist = "" + self._private.last_artUrl = "" +end + +function playerctl:pause(player) + player = player or self._private.manager.players[1] + if player then + player:pause() + end +end + +function playerctl:play(player) + player = player or self._private.manager.players[1] + if player then + player:play() + end +end + +function playerctl:stop(player) + player = player or self._private.manager.players[1] + if player then + player:stop() + end +end + +function playerctl:play_pause(player) + player = player or self._private.manager.players[1] + if player then + player:play_pause() + end +end + +function playerctl:previous(player) + player = player or self._private.manager.players[1] + if player then + player:previous() + end +end + +function playerctl:next(player) + player = player or self._private.manager.players[1] + if player then + player:next() + end +end + +function playerctl:set_loop_status(loop_status, player) + player = player or self._private.manager.players[1] + if player then + player:set_loop_status(loop_status) + end +end + +function playerctl:cycle_loop_status(player) + player = player or self._private.manager.players[1] + if player then + if player.loop_status == "NONE" then + player:set_loop_status("TRACK") + elseif player.loop_status == "TRACK" then + player:set_loop_status("PLAYLIST") + elseif player.loop_status == "PLAYLIST" then + player:set_loop_status("NONE") + end + end +end + +function playerctl:set_position(position, player) + player = player or self._private.manager.players[1] + if player then + player:set_position(position * 1000000) + end +end + +function playerctl:set_shuffle(shuffle, player) + player = player or self._private.manager.players[1] + if player then + player:set_shuffle(shuffle) + end +end + +function playerctl:cycle_shuffle(player) + player = player or self._private.manager.players[1] + if player then + player:set_shuffle(not player.shuffle) + end +end + +function playerctl:set_volume(volume, player) + player = player or self._private.manager.players[1] + if player then + player:set_volume(volume) + end +end + +function playerctl:get_manager() + return self._private.manager +end + +function playerctl:get_active_player() + return self._private.manager.players[1] +end + +function playerctl:get_player_of_name(name) + for _, player in ipairs(self._private.manager.players) do + if player.player_name == name then + return player + end + end + + return nil +end + +local function emit_metadata_signal(self, title, artist, artUrl, album, new, player_name) + title = gstring.xml_escape(title) + artist = gstring.xml_escape(artist) + album = gstring.xml_escape(album) + + -- Spotify client doesn't report its art URL's correctly... + if player_name == "spotify" then + artUrl = artUrl:gsub("open.spotify.com", "i.scdn.co") + end + + if artUrl ~= "" then + local art_path = os.tmpname() + save_image_async_curl(artUrl, art_path, function() + self:emit_signal("metadata", title, artist, art_path, album, new, player_name) + capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, art_path, player_name) + end) + else + capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, "", player_name) + self:emit_signal("metadata", title, artist, "", album, new, player_name) + end +end + +local function metadata_cb(self, player, metadata) + if self.update_on_activity then + self._private.manager:move_player_to_top(player) + end + + local data = metadata.value + + local title = data["xesam:title"] or "" + local artist = data["xesam:artist"][1] or "" + for i = 2, #data["xesam:artist"] do + artist = artist .. ", " .. data["xesam:artist"][i] + end + local artUrl = data["mpris:artUrl"] or "" + local album = data["xesam:album"] or "" + + if player == self._private.manager.players[1] then + self._private.active_player = player + + -- Callback can be called even though values we care about haven't + -- changed, so check to see if they have + if + player ~= self._private.last_player + or title ~= self._private.last_title + or artist ~= self._private.last_artist + or artUrl ~= self._private.last_artUrl + then + if (title == "" and artist == "" and artUrl == "") then return end + + if self._private.metadata_timer ~= nil and self._private.metadata_timer.started then + self._private.metadata_timer:stop() + end + + self._private.metadata_timer = gtimer { + timeout = self.debounce_delay, + autostart = true, + single_shot = true, + callback = function() + emit_metadata_signal(self, title, artist, artUrl, album, true, player.player_name) + end + } + + -- Re-sync with position timer when track changes + self._private.position_timer:again() + self._private.last_player = player + self._private.last_title = title + self._private.last_artist = artist + self._private.last_artUrl = artUrl + end + end +end + +local function position_cb(self) + local player = self._private.manager.players[1] + if player then + local position = player:get_position() / 1000000 + local length = (player.metadata.value["mpris:length"] or 0) / 1000000 + if position ~= self._private.last_position or length ~= self._private.last_length then + capi.awesome.emit_signal("bling::playerctl::position", position, length, player.player_name) + self:emit_signal("position", position, length, player.player_name) + self._private.last_position = position + self._private.last_length = length + end + end +end + +local function playback_status_cb(self, player, status) + if self.update_on_activity then + self._private.manager:move_player_to_top(player) + end + + if player == self._private.manager.players[1] then + self._private.active_player = player + + -- Reported as PLAYING, PAUSED, or STOPPED + if status == "PLAYING" then + self:emit_signal("playback_status", true, player.player_name) + capi.awesome.emit_signal("bling::playerctl::status", true, player.player_name) + else + self:emit_signal("playback_status", false, player.player_name) + capi.awesome.emit_signal("bling::playerctl::status", false, player.player_name) + end + end +end + +local function seeked_cb(self, player, position) + if self.update_on_activity then + self._private.manager:move_player_to_top(player) + end + + if player == self._private.manager.players[1] then + self._private.active_player = player + self:emit_signal("seeked", position / 1000000, player.player_name) + end +end + +local function volume_cb(self, player, volume) + if self.update_on_activity then + self._private.manager:move_player_to_top(player) + end + + if player == self._private.manager.players[1] then + self._private.active_player = player + self:emit_signal("volume", volume, player.player_name) + end +end + +local function loop_status_cb(self, player, loop_status) + if self.update_on_activity then + self._private.manager:move_player_to_top(player) + end + + if player == self._private.manager.players[1] then + self._private.active_player = player + self:emit_signal("loop_status", loop_status:lower(), player.player_name) + end +end + +local function shuffle_cb(self, player, shuffle) + if self.update_on_activity then + self._private.manager:move_player_to_top(player) + end + + if player == self._private.manager.players[1] then + self._private.active_player = player + self:emit_signal("shuffle", shuffle, player.player_name) + end +end + +local function exit_cb(self, player) + if player == self._private.manager.players[1] then + self:emit_signal("exit", player.player_name) + end +end + +-- Determine if player should be managed +local function name_is_selected(self, name) + if self.ignore[name.name] then + return false + end + + if #self.priority > 0 then + for _, arg in pairs(self.priority) do + if arg == name.name or arg == "%any" then + return true + end + end + return false + end + + return true +end + +-- Create new player and connect it to callbacks +local function init_player(self, name) + if name_is_selected(self, name) then + local player = self._private.lgi_Playerctl.Player.new_from_name(name) + self._private.manager:manage_player(player) + player.on_metadata = function(player, metadata) + metadata_cb(self, player, metadata) + end + player.on_playback_status = function(player, playback_status) + playback_status_cb(self, player, playback_status) + end + player.on_seeked = function(player, position) + seeked_cb(self, player, position) + end + player.on_volume = function(player, volume) + volume_cb(self, player, volume) + end + player.on_loop_status = function(player, loop_status) + loop_status_cb(self, player, loop_status) + end + player.on_shuffle = function(player, shuffle_status) + shuffle_cb(self, player, shuffle_status) + end + player.on_exit = function(player, shuffle_status) + exit_cb(self, player) + end + + -- Start position timer if its not already running + if not self._private.position_timer.started then + self._private.position_timer:again() + end + end +end + +-- Determine if a player name comes before or after another according to the +-- priority order +local function player_compare_name(self, name_a, name_b) + local any_index = math.huge + local a_match_index = nil + local b_match_index = nil + + if name_a == name_b then + return 0 + end + + for index, name in ipairs(self.priority) do + if name == "%any" then + any_index = (any_index == math.huge) and index or any_index + elseif name == name_a then + a_match_index = a_match_index or index + elseif name == name_b then + b_match_index = b_match_index or index + end + end + + if not a_match_index and not b_match_index then + return 0 + elseif not a_match_index then + return (b_match_index < any_index) and 1 or -1 + elseif not b_match_index then + return (a_match_index < any_index) and -1 or 1 + elseif a_match_index == b_match_index then + return 0 + else + return (a_match_index < b_match_index) and -1 or 1 + end +end + +-- Sorting function used by manager if a priority order is specified +local function player_compare(self, a, b) + local player_a = self._private.lgi_Playerctl.Player(a) + local player_b = self._private.lgi_Playerctl.Player(b) + return player_compare_name(self, player_a.player_name, player_b.player_name) +end + +local function get_current_player_info(self, player) + local title = player:get_title() or "" + local artist = player:get_artist() or "" + local artUrl = player:print_metadata_prop("mpris:artUrl") or "" + local album = player:get_album() or "" + + emit_metadata_signal(self, title, artist, artUrl, album, false, player.player_name) + playback_status_cb(self, player, player.playback_status) + volume_cb(self, player, player.volume) + loop_status_cb(self, player, player.loop_status) + shuffle_cb(self, player, player.shuffle) +end + +local function start_manager(self) + self._private.manager = self._private.lgi_Playerctl.PlayerManager() + + if #self.priority > 0 then + self._private.manager:set_sort_func(function(a, b) + return player_compare(self, a, b) + end) + end + + -- Timer to update track position at specified interval + self._private.position_timer = gtimer { + timeout = self.interval, + callback = function() + position_cb(self) + end, + } + + -- Manage existing players on startup + for _, name in ipairs(self._private.manager.player_names) do + init_player(self, name) + end + + if self._private.manager.players[1] then + get_current_player_info(self, self._private.manager.players[1]) + end + + local _self = self + + -- Callback to manage new players + function self._private.manager:on_name_appeared(name) + init_player(_self, name) + end + + function self._private.manager:on_player_appeared(player) + if player == self.players[1] then + _self._private.active_player = player + end + end + + function self._private.manager:on_player_vanished(player) + if #self.players == 0 then + _self._private.metadata_timer:stop() + _self._private.position_timer:stop() + _self:emit_signal("no_players") + capi.awesome.emit_signal("bling::playerctl::no_players") + elseif player == _self._private.active_player then + _self._private.active_player = self.players[1] + get_current_player_info(_self, self.players[1]) + end + end +end + +local function parse_args(self, args) + self.ignore = {} + if type(args.ignore) == "string" then + self.ignore[args.ignore] = true + elseif type(args.ignore) == "table" then + for _, name in pairs(args.ignore) do + self.ignore[name] = true + end + end + + self.priority = {} + if type(args.player) == "string" then + self.priority[1] = args.player + elseif type(args.player) == "table" then + self.priority = args.player + end +end + +local function new(args) + args = args or {} + + local ret = gobject {} + gtable.crush(ret, playerctl, true) + + -- Grab settings from beautiful variables if not set explicitly + args.ignore = args.ignore or beautiful.playerctl_ignore + args.player = args.player or beautiful.playerctl_player + if args.update_on_activity ~= nil then + ret.update_on_activity = args.update_on_activity + else + ret.update_on_activity = beautiful.playerctl_update_on_activity ~= false + end + ret.interval = args.interval or beautiful.playerctl_position_update_interval or 1 + ret.debounce_delay = args.debounce_delay or beautiful.playerctl_debounce_delay or 0.35 + parse_args(ret, args) + + ret._private = {} + + -- Metadata callback for title, artist, and album art + ret._private.last_player = nil + ret._private.last_title = "" + ret._private.last_artist = "" + ret._private.last_artUrl = "" + + -- Track position callback + ret._private.last_position = -1 + ret._private.last_length = -1 + + -- Grab playerctl library + ret._private.lgi_Playerctl = require("lgi").Playerctl + ret._private.manager = nil + ret._private.metadata_timer = nil + ret._private.position_timer = nil + + -- Ensure main event loop has started before starting player manager + gtimer.delayed_call(function() + start_manager(ret) + end) + + return ret +end + +function playerctl.mt:__call(...) + return new(...) +end + +return setmetatable(playerctl, playerctl.mt) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/rc.lua b/modules/home-manager/ricing/awesomewm/dotfiles/rc.lua new file mode 100644 index 0000000..43fd25d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/rc.lua @@ -0,0 +1,29 @@ +local awful = require "awful" +local gears = require "gears" +local beautiful = require "beautiful" + +awful.spawn.with_shell("bash ~/.config/awesome/main/autorun.sh") +require "setup":generate() + +beautiful.init(gears.filesystem.get_configuration_dir() .. "theme/init.lua") + +require "main" +require "awful.autofocus" + +-- init widget +require "misc" +require "ui" +require "signal" + + +gears.timer { + timeout = 5, + autostart = true, + call_now = true, + callback = function() + collectgarbage "collect" + end, +} + +collectgarbage("setpause", 110) +collectgarbage("setstepmul", 1000) \ No newline at end of file diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/setup/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/setup/init.lua new file mode 100644 index 0000000..4de9033 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/setup/init.lua @@ -0,0 +1,38 @@ +local json = require("mods.json") +local helpers = require("helpers") +local gfs = require("gears.filesystem") + +local M = {} + +M.defaultData = { + colorscheme = "cat", + gaps = 10, + iconTheme = "~/.local/share/icons/hicolor/", + openWeatherApi = "KEY_HERE", + showDesktopIcons = true, + pfp = "/home/" .. string.gsub(os.getenv('USER'), '^%l', string.lower) .. "/.config/awesome/theme/assets/pfp.png", + wallpaper = "colorful", +} + +M.path = gfs.get_cache_dir() .. "json/settings.json" + +function M:generate() + if not helpers.file_exists(self.path) then + local w = assert(io.open(self.path, "w")) + w:write(json.encode(self.defaultData, nil, { pretty = true, indent = " ", align_keys = false, array_newline = true })) + w:close() + M.settings = self.defaultData + else + local r = assert(io.open(self.path, "rb")) + local t = r:read("*all") + r:close() + local settings = json.decode(t) + M.settings = settings + end + + if not helpers.file_exists(gfs.get_cache_dir() .. "lock/lock.jpg") then + os.execute("mkdir -p ~/.cache/awesome/lock") + end +end + +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/airplane.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/airplane.lua new file mode 100644 index 0000000..a6faf1e --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/airplane.lua @@ -0,0 +1,20 @@ +local awful = require('awful') +local gears = require('gears') +local naughty = require("naughty") + +local function emit_airplane_status() + awful.spawn.easy_async_with_shell( + "bash -c \"rfkill list | sed -n 2p | awk '{print $3}'\" ", function(stdout) + local status = stdout:match("yes") -- boolean + awesome.emit_signal('signal::airplane', status) + end) +end + +gears.timer { + timeout = 2, + call_now = true, + autostart = true, + callback = function() + emit_airplane_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/bluetooth.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/bluetooth.lua new file mode 100644 index 0000000..012f086 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/bluetooth.lua @@ -0,0 +1,21 @@ +local awful = require('awful') +local gears = require('gears') + +local function emit_bluetooth_status() + awful.spawn.easy_async_with_shell( + "bash -c 'bluetoothctl show | grep -i powered:'", function(stdout) + local status = stdout:match("yes") -- boolean + awesome.emit_signal('signal::bluetooth', status) + end) +end + +-- Refreshing +------------- +gears.timer { + timeout = 2, + call_now = true, + autostart = true, + callback = function() + emit_bluetooth_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/init.lua new file mode 100644 index 0000000..9513aea --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/init.lua @@ -0,0 +1,3 @@ +require("signal.connection.wifi") +require("signal.connection.bluetooth") +require("signal.connection.airplane") diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/wifi.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/wifi.lua new file mode 100644 index 0000000..62eed53 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/connection/wifi.lua @@ -0,0 +1,23 @@ +local awful = require('awful') +local gears = require('gears') + +-- Network Fetching and Signal Emitting +--------------------------------------- +local function emit_network_status() + awful.spawn.easy_async_with_shell( + "bash -c 'nmcli networking connectivity check'", function(stdout) + local status = not stdout:match("none") -- boolean + awesome.emit_signal('signal::network', status) + end) +end + +-- Refreshing +------------- +gears.timer { + timeout = 2, + call_now = true, + autostart = true, + callback = function() + emit_network_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/init.lua new file mode 100644 index 0000000..7f8dc6b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/init.lua @@ -0,0 +1,3 @@ +require("signal.system") +require("signal.connection") +require("signal.stats") diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/cpu.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/cpu.lua new file mode 100644 index 0000000..4e6e8b3 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/cpu.lua @@ -0,0 +1,20 @@ +local awful = require('awful') +local gears = require('gears') +local function emit_cpu_status() + awful.spawn.easy_async_with_shell( + "bash -c \"roundvalue $(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}')\"" + , + function(stdout) + stdout = tonumber(stdout) + awesome.emit_signal('signal::cpu', stdout) + end) +end + +gears.timer { + timeout = 60, + call_now = true, + autostart = true, + callback = function() + emit_cpu_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/disk.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/disk.lua new file mode 100644 index 0000000..5fc6fe9 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/disk.lua @@ -0,0 +1,21 @@ +local awful = require('awful') +local gears = require('gears') +local function emit_disk_status() + awful.spawn.easy_async_with_shell( + "bash -c \"df --output=pcent / | sed '1d;s/^ //;s/%//'\"" + , + function(stdout) + stdout = stdout:gsub("%s+", "") + stdout = tonumber(stdout) + awesome.emit_signal('signal::disk', stdout) + end) +end + +gears.timer { + timeout = 600, + call_now = true, + autostart = true, + callback = function() + emit_disk_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/init.lua new file mode 100644 index 0000000..7ae2cc7 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/init.lua @@ -0,0 +1,5 @@ +require("signal.stats.weather") +require("signal.stats.uptime") +require("signal.stats.cpu") +require("signal.stats.disk") +require("signal.stats.memory") diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/memory.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/memory.lua new file mode 100644 index 0000000..351ae02 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/memory.lua @@ -0,0 +1,20 @@ +local awful = require('awful') +local gears = require('gears') +local function emit_mem_status() + awful.spawn.easy_async_with_shell( + "bash -c \"roundvalue $(free | grep Mem | awk '{print $3/$2 * 100.0}')\"" + , + function(stdout) + stdout = tonumber(stdout) + awesome.emit_signal('signal::memory', stdout) + end) +end + +gears.timer { + timeout = 60, + call_now = true, + autostart = true, + callback = function() + emit_mem_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/uptime.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/uptime.lua new file mode 100644 index 0000000..4ceedfb --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/uptime.lua @@ -0,0 +1,20 @@ +local awful = require('awful') +local gears = require('gears') +local function emit_uptime_status() + awful.spawn.easy_async_with_shell( + "bash -c \"uptime --pretty | sed 's/up\\s*//g' | sed 's/\\s*days/d/g' | sed 's/\\s*hours/h/g' | sed 's/\\s*minutes/m/g'\"" + , + function(stdout) + stdout = stdout:gsub("%s+", "") + awesome.emit_signal('signal::uptime', stdout) + end) +end + +gears.timer { + timeout = 60, + call_now = true, + autostart = true, + callback = function() + emit_uptime_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/weather.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/weather.lua new file mode 100644 index 0000000..95175d6 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/stats/weather.lua @@ -0,0 +1,107 @@ +local awful = require("awful") +local gears = require("gears") +local filesystem = gears.filesystem +local json = require("mods.json") +local helpers = require("helpers") +local icon_dir = filesystem.get_configuration_dir() .. "theme/assets/weather/icons/" +local thumb_dir = filesystem.get_configuration_dir() .. "theme/assets/weather/images/" + +local GET_FORECAST_CMD = [[bash -c "curl -s --show-error -X GET '%s'"]] + +local icon_map = { + ["01d"] = "weather-clear-sky", + ["02d"] = "weather-few-clouds", + ["04d"] = "weather-few-clouds", + ["03d"] = "weather-clouds", + ["09d"] = "weather-showers-scattered", + ["09n"] = "weather-showers-scattered", + ["10d"] = "weather-showers", + ["11d"] = "weather-strom", + ["13d"] = "weather-snow", + ["50d"] = "weather-fog", + ["01n"] = "weather-clear-night", + ["02n"] = "weather-few-clouds-night", + ["03n"] = "weather-clouds-night", + ["04n"] = "weather-clouds-night", + ["10n"] = "weather-showers", + ["11n"] = "weather-strom", + ["13n"] = "weather-snow", + ["50n"] = "weather-fog", +} + + +local image_map = { + ["01d"] = "weather-clear-sky", + ["02d"] = "weather-clouds", + ["04d"] = "weather-clouds", + ["03d"] = "weather-clouds", + ["09d"] = "weather-showers-scattered", + ["09n"] = "weather-showers-scattered", + ["10d"] = "weather-showers", + ["11d"] = "weather-strom", + ["13d"] = "weather-snow", + ["50d"] = "weather-fog", + ["01n"] = "weather-clear-night", + ["02n"] = "weather-clouds-night", + ["03n"] = "weather-clouds-night", + ["04n"] = "weather-clouds-night", + ["10n"] = "weather-showers", + ["11n"] = "weather-strom", + ["13n"] = "weather-snow", + ["50n"] = "weather-fog", +} + +local api_key = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/settings.json").openWeatherApi +local coordinates = { "28.6446772", "77.320955" } + +local show_hourly_forecast = true +local show_daily_forecast = true +local units = "metric" + +local url = ( + "https://api.openweathermap.org/data/2.5/onecall" + .. "?lat=" + .. coordinates[1] + .. "&lon=" + .. coordinates[2] + .. "&appid=" + .. api_key + .. "&units=" + .. units + .. "&exclude=minutely" + .. (show_hourly_forecast == false and ",hourly" or "") + .. (show_daily_forecast == false and ",daily" or "") +) + + + + +awful.widget.watch(string.format(GET_FORECAST_CMD, url), 600, function(_, stdout, stderr) + local result = json.decode(stdout) + -- Current weather setup + local out = { + desc = result.current.weather[1].description:gsub("^%l", string.upper), + humidity = result.current.humidity, + temp = math.floor(result.current.temp), + feelsLike = math.floor(result.current.feels_like), + image = icon_dir .. icon_map[result.current.weather[1].icon] .. ".svg", + thumb = thumb_dir .. image_map[result.current.weather[1].icon] .. ".jpg", + hourly = { + result.hourly[1], + result.hourly[2], + result.hourly[3], + result.hourly[4], + result.hourly[5], + result.hourly[6], + }, + daily = { + result.daily[1], + result.daily[2], + result.daily[3], + result.daily[4], + result.daily[5], + result.daily[6], + } + } + awesome.emit_signal("signal::weather", out) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/battery.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/battery.lua new file mode 100644 index 0000000..3761461 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/battery.lua @@ -0,0 +1,34 @@ +local awful = require('awful') +local gears = require('gears') +local gfs = gears.filesystem + +-- Battery Fetching and Signal Emitting +--------------------------------------- +-- Battery information script +local battery_script = +"bash -c 'echo $(cat /sys/class/power_supply/BAT0/capacity) echo $(cat /sys/class/power_supply/BAT0/status)'" + +local function battery_emit() + awful.spawn.easy_async_with_shell( + battery_script, function(stdout) + -- The battery level and status are saved as a string. Then the level + -- is stored separately as a string, then converted to int. The status + -- is stored as a bool, and also as an int for registering changes in + -- battery status. + local level = string.match(stdout:match('(%d+)'), '(%d+)') + local level_int = tonumber(level) -- integer + local power = not stdout:match('Discharging') -- boolean + awesome.emit_signal('signal::battery', level_int, power) + end) +end + +-- Refreshing +------------- +gears.timer { + timeout = 20, + call_now = true, + autostart = true, + callback = function() + battery_emit() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/brightness.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/brightness.lua new file mode 100644 index 0000000..423df13 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/brightness.lua @@ -0,0 +1,24 @@ +local awful = require('awful') +local gears = require('gears') + +local brightness_script = +"bash -c 'echo $(($(cat /sys/class/backlight/*/brightness) * 100 / $(cat /sys/class/backlight/*/max_brightness)))'" + +local function emit_brightness() + awful.spawn.easy_async_with_shell( + brightness_script, function(stdout) + local level_cur = tonumber(stdout) + awesome.emit_signal('signal::brightness', level_cur) + end) +end + +-- Refreshing +------------- +gears.timer { + timeout = 1, + call_now = true, + autostart = true, + callback = function() + emit_brightness() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/dnd.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/dnd.lua new file mode 100644 index 0000000..6348eb4 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/dnd.lua @@ -0,0 +1,19 @@ +local gears = require('gears') +local naughty = require("naughty") +-- Network Fetching and Signal Emitting +--------------------------------------- +local function emit_dnd_status() + local status = naughty.is_suspended() + awesome.emit_signal('signal::dnd', status) +end + +-- Refreshing +------------- +gears.timer { + timeout = 2, + call_now = true, + autostart = true, + callback = function() + emit_dnd_status() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/init.lua new file mode 100644 index 0000000..676e8d7 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/init.lua @@ -0,0 +1,5 @@ +require("signal.system.dnd") +require("signal.system.brightness") +require("signal.system.volume") +require("signal.system.battery") +require("signal.system.redshift") diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/microphone.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/microphone.lua new file mode 100644 index 0000000..093d639 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/microphone.lua @@ -0,0 +1,21 @@ +local awful = require('awful') +local gears = require('gears') + +local function mic_emit() + awful.spawn.easy_async_with_shell( + "bash -c 'pamixer --source 1 --get-mute'", function(value) + local stringtoboolean = { ["true"] = false, ["false"] = true } + value = value:gsub("%s+", "") + value = stringtoboolean[value] + awesome.emit_signal('signal::mic', value) -- integer + end) +end + +gears.timer { + timeout = 1, + call_now = true, + autostart = true, + callback = function() + mic_emit() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/redshift.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/redshift.lua new file mode 100644 index 0000000..ff2d47a --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/redshift.lua @@ -0,0 +1,22 @@ +local awful = require('awful') +local gears = require('gears') + +local function light_emit() + awful.spawn.easy_async_with_shell( + "bash -c 'cat ~/.cache/redshift'", function(stdout) + local status = stdout:match("true") -- boolean + awesome.emit_signal('signal::redshift', status) + end) +end + +-- Microphone Fetching and Signal Emitting +-- Refreshing +------------- +gears.timer { + timeout = 2, + call_now = true, + autostart = true, + callback = function() + light_emit() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/volume.lua b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/volume.lua new file mode 100644 index 0000000..f14c1c6 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/signal/system/volume.lua @@ -0,0 +1,22 @@ +local awful = require('awful') +local gears = require('gears') + +local function volume_emit() + awful.spawn.easy_async_with_shell( + "bash -c 'pamixer --get-volume'", function(stdout) + local volume_int = tonumber(stdout) -- integer + awesome.emit_signal('signal::volume', volume_int) -- integer + end) +end + +-- Microphone Fetching and Signal Emitting +-- Refreshing +------------- +gears.timer { + timeout = 1, + call_now = true, + autostart = true, + callback = function() + volume_emit() + end +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/awesome.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/awesome.svg new file mode 100644 index 0000000..616fbcf --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/awesome.svg @@ -0,0 +1,43 @@ + + + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/bell.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/bell.png new file mode 100644 index 0000000..49ac044 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/bell.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/defsong.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/defsong.jpg new file mode 100644 index 0000000..a7a08f3 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/defsong.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/floating.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/floating.png new file mode 100644 index 0000000..1723575 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/floating.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/neofetch.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/neofetch.png new file mode 100644 index 0000000..3c965bb Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/neofetch.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/nix.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/nix.svg new file mode 100644 index 0000000..9a70a14 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/nix.svg @@ -0,0 +1,513 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/nixos.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/nixos.png new file mode 100644 index 0000000..8ae430f Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/nixos.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/notif.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/notif.png new file mode 100644 index 0000000..204aeda Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/notif.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/pfp.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/pfp.png new file mode 100644 index 0000000..9984e6c Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/pfp.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/pomo.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/pomo.jpg new file mode 100644 index 0000000..97a97a5 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/pomo.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/systray.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/systray.png new file mode 100644 index 0000000..05fc45a Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/systray.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/tile.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/tile.png new file mode 100644 index 0000000..2d50939 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/tile.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_1.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_1.png new file mode 100644 index 0000000..772462b Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_1.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_2.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_2.png new file mode 100644 index 0000000..1f3db05 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_2.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_normal.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_normal.svg new file mode 100644 index 0000000..acc2f7f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/close_normal.svg @@ -0,0 +1 @@ + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_1.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_1.png new file mode 100644 index 0000000..4f5a7f0 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_1.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_2.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_2.png new file mode 100644 index 0000000..400aba1 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_2.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_normal.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_normal.svg new file mode 100644 index 0000000..8d73698 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/titlebar/minimize_normal.svg @@ -0,0 +1 @@ + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/tsukkisaidmetoaddthis.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/tsukkisaidmetoaddthis.png new file mode 100644 index 0000000..ce38389 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/tsukkisaidmetoaddthis.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clear-night.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clear-night.svg new file mode 100644 index 0000000..ecf451a --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clear-night.svg @@ -0,0 +1,3 @@ + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clear-sky.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clear-sky.svg new file mode 100644 index 0000000..e84065c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clear-sky.svg @@ -0,0 +1,3 @@ + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clouds-night.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clouds-night.svg new file mode 100644 index 0000000..1a00dff --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clouds-night.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clouds.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clouds.svg new file mode 100644 index 0000000..1a00dff --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-clouds.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-few-clouds-night.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-few-clouds-night.svg new file mode 100644 index 0000000..e8243ae --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-few-clouds-night.svg @@ -0,0 +1,4 @@ + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-few-clouds.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-few-clouds.svg new file mode 100644 index 0000000..7279f9f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-few-clouds.svg @@ -0,0 +1,3 @@ + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-fog.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-fog.svg new file mode 100644 index 0000000..81d0a39 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-fog.svg @@ -0,0 +1,3 @@ + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-freezing-rain.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-freezing-rain.svg new file mode 100644 index 0000000..d83c93a --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-freezing-rain.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-overcast-symbolic.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-overcast-symbolic.svg new file mode 100644 index 0000000..8843c15 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-overcast-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-overcast.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-overcast.svg new file mode 100644 index 0000000..e85bb96 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-overcast.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-showers-scattered.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-showers-scattered.svg new file mode 100644 index 0000000..7749e85 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-showers-scattered.svg @@ -0,0 +1,4 @@ + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-showers.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-showers.svg new file mode 100644 index 0000000..b0f387f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-showers.svg @@ -0,0 +1,4 @@ + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow-rain.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow-rain.svg new file mode 100644 index 0000000..391fac5 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow-rain.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow-scattered.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow-scattered.svg new file mode 100644 index 0000000..9be2009 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow-scattered.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow.svg new file mode 100644 index 0000000..d1f7d1c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-snow.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-storm.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-storm.svg new file mode 100644 index 0000000..cb2cba6 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-storm.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-windy.svg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-windy.svg new file mode 100644 index 0000000..65bec4f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/icons/weather-windy.svg @@ -0,0 +1,3 @@ + + + diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clear-night.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clear-night.jpg new file mode 100644 index 0000000..a5a36c2 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clear-night.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clear-sky.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clear-sky.jpg new file mode 100644 index 0000000..799b4dc Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clear-sky.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clouds-night.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clouds-night.jpg new file mode 100644 index 0000000..8d2c696 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-clouds-night.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-fog.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-fog.jpg new file mode 100644 index 0000000..925eb08 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-fog.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-showers-scattered.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-showers-scattered.jpg new file mode 100644 index 0000000..41439b9 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-showers-scattered.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-showers.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-showers.jpg new file mode 100644 index 0000000..e6f942e Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-showers.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-snow.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-snow.jpg new file mode 100644 index 0000000..a579d1c Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-snow.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-stroms.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-stroms.jpg new file mode 100644 index 0000000..83fb291 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weather-stroms.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weathers-cloud.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weathers-cloud.jpg new file mode 100644 index 0000000..441dabd Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/weather/images/weathers-cloud.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/wedding-bells.png b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/wedding-bells.png new file mode 100644 index 0000000..ba0ab04 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/assets/wedding-bells.png differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/biscuit.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/biscuit.lua new file mode 100644 index 0000000..7cc55a9 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/biscuit.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'biscuit' +m.ok = "#989F56" +m.warn = "#E46A3A" +m.err = "#CA3F3F" +m.dis = "#9F569A" +m.pri = "#629386" +m.bg = "#181515" +m.mbg = "#211b1b" +m.bg3 = "#2d2424" +m.bg4 = "#352a2a" +m.fg = "#ffe9c7" +m.fg3 = "#D5CAC3" +m.fg2 = "#E5D8CB" +m.fg4 = "#614f4f" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/cat.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/cat.lua new file mode 100644 index 0000000..deb583a --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/cat.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'cat' +m.ok = "#7fd98f" +m.warn = "#efa17f" +m.err = "#e56e70" +m.dis = "#d476da" +m.pri = "#7c98e4" +m.mbg = "#11111b" +m.bg = "#0d0d15" +m.bg3 = "#161623" +m.bg4 = "#292c35" +m.fg = "#f5e0dc" +m.fg2 = "#e5e0dc" +m.fg3 = "#b5bfe2" +m.fg4 = "#83889a" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/decay.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/decay.lua new file mode 100644 index 0000000..8358d5b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/decay.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'decay' +m.ok = "#78DBA9" +m.warn = "#e9a180" +m.err = "#e26c7c" +m.dis = "#b47fd7" +m.pri = "#7297d9" +m.mbg = "#1b1f25" +m.bg = "#13161a" +m.bg3 = "#1b1f25" +m.bg4 = "#21262e" +m.fg = "#dee1e6" +m.fg2 = "#e5e0dc" +m.fg3 = "#BFBFBF" +m.fg4 = "#485263" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/everblush.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/everblush.lua new file mode 100644 index 0000000..4217dd1 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/everblush.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'everblush' +m.ok = "#6faf7f" +m.warn = "#e59063" +m.err = "#e86b6b" +m.pri = "#6fa4cc" +m.dis = "#ce89df" +m.bg = "#151a1c" +m.mbg = "#1d2326" +m.bg3 = "#22292d" +m.bg4 = "#2e383d" +m.fg = "#dad0bc" +m.fg2 = "#d4d5d5" +m.fg3 = "#d3c6aa" +m.fg4 = "#5a5858" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/forest.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/forest.lua new file mode 100644 index 0000000..1a1fde7 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/forest.lua @@ -0,0 +1,17 @@ +local M = {} +M.type = "dark" +M.name = 'forest' +M.pri = "#7fbbb3" +M.warn = "#d29571" +M.err = "#e76365" +M.ok = "#7cc277" +M.dis = "#d491b1" +M.bg = "#0c1012" +M.mbg = "#101618" +M.bg3 = "#1c2121" +M.bg4 = "#232a2d" +M.fg2 = "#dadada" +M.fg = "#dedada" +M.fg3 = "#bdc3c2" +M.fg4 = "#404749" +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/fovere.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/fovere.lua new file mode 100644 index 0000000..8e3c611 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/fovere.lua @@ -0,0 +1,17 @@ +local M = {} +M.type = "dark" +M.name = 'fovere' +M.pri = "#c297d5" +M.warn = "#fcc48c" +M.err = "#cf5555" +M.ok = "#6dc383" +M.dis = "#a7b3fb" +M.bg = "#111012" +M.mbg = "#1d1a1f" +M.bg3 = "#221d23" +M.bg4 = "#252027" +M.fg2 = "#e6e6e6" +M.fg = "#dadada" +M.fg3 = "#c9c9c9" +M.fg4 = "#6f6f6f" +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/fullerene.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/fullerene.lua new file mode 100644 index 0000000..eb66db2 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/fullerene.lua @@ -0,0 +1,17 @@ +local M = {} +M.type = "dark" +M.name = 'fullerene' +M.pri = "#738be7" +M.warn = "#e1a36b" +M.err = "#c1374b" +M.ok = "#32ae80" +M.dis = "#9e7ad5" +M.bg = "#0c0c0c" +M.mbg = "#161616" +M.bg3 = "#1f1f1f" +M.bg4 = "#222222" +M.fg2 = "#f4f4f4" +M.fg = "#e0e0e0" +M.fg3 = "#c6c6c6" +M.fg4 = "#6f6f6f" +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/kizu.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/kizu.lua new file mode 100644 index 0000000..bf3eb71 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/kizu.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'kizu' +m.ok = "#7cd39f" +m.warn = "#de876d" +m.err = "#ee6a70" +m.dis = "#bc85e1" +m.pri = "#7ba5dd" +m.bg = "#080c0d" +m.mbg = "#0f1415" +m.bg3 = "#131718" +m.bg4 = "#151a1c" +m.fg = "#C5C8C9" +m.fg3 = "#c4c4c4" +m.fg2 = "#b7b8b8" +m.fg4 = "#6e7071" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/nirvana.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/nirvana.lua new file mode 100644 index 0000000..17d2ed3 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/nirvana.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'nirvana' +m.ok = "#8fa176" +m.err = "#af575b" +m.warn = "#d8b170" +m.dis = "#a07ea7" +m.pri = "#7d95ae" +m.bg = "#121111" +m.mbg = "#191919" +m.bg3 = "#1b1b1b" +m.bg4 = "#272727" +m.fg = "#dfdddd" +m.fg3 = "#cfdddd" +m.fg2 = "#b7b7b7" +m.fg4 = "#5a5858" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/oxo.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/oxo.lua new file mode 100644 index 0000000..8f8e3eb --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/oxo.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'oxo' +m.pri = "#78a9ff" +m.warn = "#ff7eb6" +m.err = "#ee5396" +m.dis = "#3ddbd9" +m.ok = "#42be65" +m.bg = "#111111" +m.mbg = "#181818" +m.bg3 = "#1d1d1d" +m.bg4 = "#252525" +m.fg = "#dadada" +m.fg3 = "#b3b9b8" +m.fg2 = "#bdc3c2" +m.fg4 = "#696969" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/rose.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/rose.lua new file mode 100644 index 0000000..85f8292 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/rose.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'rose' +m.ok = "#449ec2" +m.warn = "#f09670" +m.err = "#ee5c85" +m.dis = "#bd97eb" +m.pri = "#89cdd9" +m.bg = "#191724" +m.mbg = "#1f1c2c" +m.bg3 = "#221f31" +m.bg4 = "#29253b" +m.fg = "#e0def4" +m.fg2 = "#cecde1" +m.fg3 = "#c0bfd2" +m.fg4 = "#83889a" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/solarized.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/solarized.lua new file mode 100644 index 0000000..855e355 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/solarized.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'solarized' +m.pri = "#387098" +m.warn = "#b86229" +m.err = "#b03a38" +m.dis = "#9751aa" +m.ok = "#7b9524" +m.bg = "#021a20" +m.mbg = "#022028" +m.bg3 = "#00252f" +m.bg4 = "#002d39" +m.fg = "#fdf6e3" +m.fg3 = "#eee8d5" +m.fg2 = "#e5dfcd" +m.fg4 = "#657b83" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/stardewnight.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/stardewnight.lua new file mode 100644 index 0000000..2bccbb1 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/stardewnight.lua @@ -0,0 +1,17 @@ +local M = {} +M.type = "dark" +M.name = 'stardewnight' +M.ok = "#55b682" +M.warn = "#ff9c6a" +M.err = "#f25c5c" +M.pri = "#7aaaff" +M.dis = "#f17ac6" +M.bg = "#16161a" +M.mbg = "#212126" +M.bg3 = "#2a2a30" +M.bg4 = "#373740" +M.fg = "#e9ecf2" +M.fg2 = "#d9ecf2" +M.fg3 = "#DCDFE4" +M.fg4 = "#676778" +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/swamp.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/swamp.lua new file mode 100644 index 0000000..74b73a6 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/swamp.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'swamp' +m.ok = "#736f4e" +m.warn = "#db930d" +m.err = "#96294d" +m.dis = "#508991" +m.pri = "#91506c" +m.bg = "#1d1a11" +m.mbg = "#242015" +m.bg3 = "#242115" +m.bg4 = "#292518" +m.fg = "#ebe0bb" +m.fg3 = "#ebe0bb" +m.fg2 = "#e1d6b3" +m.fg4 = "#8b815e" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/sweetpastel.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/sweetpastel.lua new file mode 100644 index 0000000..bf4d5f9 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/sweetpastel.lua @@ -0,0 +1,17 @@ +local M = {} +M.type = "dark" +M.name = 'sweetpastel' +M.ok = "#b4e3ad" +M.warn = "#f1c192" +M.err = "#e5a3a1" +M.pri = "#a3bbe7" +M.dis = "#ceace8" +M.bg = "#15181b" +M.mbg = "#1b1f23" +M.bg3 = "#222629" +M.bg4 = "#262b30" +M.fg = "#F8F9FA" +M.fg2 = "#e8F9FA" +M.fg3 = "#eeeff0" +M.fg4 = "#515c68" +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/verdant.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/verdant.lua new file mode 100644 index 0000000..9d1c708 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/verdant.lua @@ -0,0 +1,17 @@ +local M = {} +M.type = "dark" +M.name = 'verdant' +M.ok = "#56966e" +M.warn = "#dc8c61" +M.err = "#c14d53" +M.pri = "#6e95bd" +M.dis = "#a56db1" +M.bg = "#0c0c0c" +M.mbg = "#131313" +M.bg3 = "#1b1b1b" +M.bg4 = "#272727" +M.fg = "#dfdddd" +M.fg2 = "#b7b7b7" +M.fg3 = "#a4b5b5" +M.fg4 = "#5a5858" +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/vixima.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/vixima.lua new file mode 100644 index 0000000..c4b7b1b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/colors/vixima.lua @@ -0,0 +1,17 @@ +local m = {} +m.type = "dark" +m.name = 'vixima' +m.ok = "#65DB3D" +m.warn = "#F57F3D" +m.err = "#FA3867" +m.dis = "#A771EF" +m.pri = "#4CB2E5" +m.bg = "#17181C" +m.mbg = "#1E1F24" +m.bg3 = "#26272B" +m.bg4 = "#333438" +m.fg = "#e4e5e7" +m.fg3 = "#CBCCCE" +m.fg2 = "#B0B1B4" +m.fg4 = "#8f9093" +return m diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/theme/init.lua new file mode 100644 index 0000000..5bdda93 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/theme/init.lua @@ -0,0 +1,141 @@ +local xresources = require "beautiful.xresources" +local rnotification = require "ruled.notification" +local dpi = xresources.apply_dpi +local gears = require "gears" +local gfs = require "gears.filesystem" +local helpers = require "helpers" +local settings = require "setup".settings +-- Var +local themes_path = gfs.get_configuration_dir() .. "theme/" +local home = os.getenv 'HOME' + +local theme = {} + +local data = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/settings.json") + + + +----- User Preferences ----- + + +theme.pfp = data.pfp +theme.user = string.gsub(os.getenv('USER'), '^%l', string.upper) +theme.hostname = os.getenv('HOST') +----- Font ----- +local themeName = settings.colorscheme +local colors = require("theme.colors." .. themeName) + + +theme.wallpaper = themes_path .. "walls/" .. colors.name .. ".jpg" +theme.iconThemePath = settings.iconTheme +theme.scheme = themeName +theme.sans = "Rubik" +theme.mono = "Iosevka Nerd Font" +theme.icon = "Material Design Icons" +theme.font = "Rubik 12" +theme.prompt_font = theme.font +----- General/default Settings ----- + +theme.bg_normal = colors.bg +theme.bg_focus = colors.bg +theme.bg_urgent = colors.bg +theme.bg_minimize = colors.bg +theme.bg_systray = colors.mbg + +theme.style = colors.type + +theme.fg_normal = colors.fg +theme.fg_focus = theme.fg_normal +theme.fg_urgent = theme.fg_normal +theme.fg_minimize = theme.fg_normal + +theme.useless_gap = dpi(tonumber(data.gaps)) +theme.border_width = dpi(0) + +-- Colors + +theme.blue = colors.pri +theme.yellow = colors.warn +theme.green = colors.ok +theme.red = colors.err +theme.magenta = colors.dis +theme.transparent = "#00000000" + +theme.fg = colors.fg + +theme.bg = colors.bg +theme.bg_alt = colors.mbg + +theme.mbg = colors.mbg +theme.bg3 = colors.bg3 +theme.bg4 = colors.bg4 + +theme.fg = colors.fg +theme.fg1 = colors.fg2 +theme.fg2 = colors.fg3 +theme.fg3 = colors.fg4 + +-- Menu + +theme.menu_height = dpi(40) +theme.menu_width = dpi(200) +theme.menu_bg_focus = theme.bg +theme.menu_bg_normal = theme.bg +theme.submenu = ">" + + +theme.taglist_bg = theme.bg .. "00" +theme.taglist_bg_focus = theme.blue +theme.taglist_fg_focus = theme.fg +theme.taglist_bg_urgent = theme.red +theme.taglist_fg_urgent = theme.fg +theme.taglist_bg_occupied = colors.fg3 .. '33' +theme.taglist_fg_occupied = theme.fg +theme.taglist_bg_empty = colors.fg3 .. '33' +theme.taglist_fg_empty = colors.fg +theme.taglist_disable_icon = true + + +theme.tasklist_bg_normal = theme.bg +theme.tasklist_bg_focus = theme.bg2 +theme.tasklist_bg_minimize = theme.bg3 + +-- titlebar's buttons +theme.titlebar_close_button_normal = gears.color.recolor_image(themes_path .. "assets/titlebar/close_1.png", + theme.bg3) +theme.titlebar_close_button_focus = gears.color.recolor_image(themes_path .. "assets/titlebar/close_2.png", + theme.red) + +theme.layout_floating = gears.color.recolor_image(themes_path .. "assets/floating.png", + theme.fg) +theme.layout_tile = gears.color.recolor_image(themes_path .. "assets/tile.png", + theme.fg) + +theme.nixos = themes_path .. "assets/nixos.png" +theme.titlebar_minimize_button_normal = gears.color.recolor_image( + themes_path .. "assets/titlebar/minimize_1.png", theme.bg3) +theme.titlebar_minimize_button_focus = gears.color.recolor_image( + themes_path .. "assets/titlebar/minimize_2.png", theme.green) + +theme.titlebar_maximized_button_normal_inactive = gears.color.recolor_image(themes_path .. "assets/titlebar/close_1.png", + theme.bg3) +theme.titlebar_maximized_button_focus_inactive = gears.color.recolor_image(themes_path .. "assets/titlebar/close_1.png", + theme.yellow) +theme.titlebar_maximized_button_normal_active = gears.color.recolor_image(themes_path .. "assets/titlebar/close_1.png", + theme.bg3) +theme.titlebar_maximized_button_focus_active = gears.color.recolor_image(themes_path .. "assets/titlebar/close_1.png", + theme.yellow) + +theme.icon_theme = "Reversal" + + +theme.songdefpicture = themes_path .. "/assets/defsong.jpg" + +rnotification.connect_signal('request::rules', function() + rnotification.append_rule { + rule = { urgency = 'critical' }, + properties = { bg = '#ff0000', fg = '#ffffff' } + } +end) + +return theme diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/biscuit.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/biscuit.jpg new file mode 100644 index 0000000..41e963c Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/biscuit.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/cat.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/cat.jpg new file mode 100644 index 0000000..6fe4808 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/cat.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/decay.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/decay.jpg new file mode 100644 index 0000000..0518901 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/decay.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/everblush.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/everblush.jpg new file mode 100644 index 0000000..0b45b58 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/everblush.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/forest.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/forest.jpg new file mode 100644 index 0000000..2aae176 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/forest.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/fovere.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/fovere.jpg new file mode 100644 index 0000000..50644a7 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/fovere.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/fullerene.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/fullerene.jpg new file mode 100644 index 0000000..f608185 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/fullerene.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/ghost.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/ghost.jpg new file mode 100644 index 0000000..d6926f2 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/ghost.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/groove.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/groove.jpg new file mode 100644 index 0000000..4c4f0c6 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/groove.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/kizu.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/kizu.jpg new file mode 100644 index 0000000..8ee0160 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/kizu.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/nirvana.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/nirvana.jpg new file mode 100644 index 0000000..9c31851 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/nirvana.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/oxo.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/oxo.jpg new file mode 100644 index 0000000..da7f8e8 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/oxo.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/rose.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/rose.jpg new file mode 100644 index 0000000..21148f8 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/rose.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/solarized.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/solarized.jpg new file mode 100644 index 0000000..892ace7 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/solarized.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/stardewnight.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/stardewnight.jpg new file mode 100644 index 0000000..0b1332d Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/stardewnight.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/swamp.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/swamp.jpg new file mode 100644 index 0000000..2f320b0 Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/swamp.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/sweetpastel.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/sweetpastel.jpg new file mode 100644 index 0000000..3d669ae Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/sweetpastel.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/verdant.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/verdant.jpg new file mode 100644 index 0000000..f600f2b Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/verdant.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/vixima.jpg b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/vixima.jpg new file mode 100644 index 0000000..8a255ad Binary files /dev/null and b/modules/home-manager/ricing/awesomewm/dotfiles/theme/walls/vixima.jpg differ diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/init.lua new file mode 100644 index 0000000..176fd30 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/init.lua @@ -0,0 +1,174 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local helpers = require('helpers') + +local profile = require("ui.bar.mods.profile") +local tags = require("ui.bar.mods.tags") +local task = require("ui.bar.mods.task") +local battery = require("ui.bar.mods.battery") +local wifi = require("ui.bar.mods.wifi") +local bluetooth = require("ui.bar.mods.bluetooth") +local music = require("ui.bar.mods.music") +local hourminutes = require("ui.bar.mods.time") +local layout = require("ui.bar.mods.layout") +local systray = require("ui.bar.mods.systray") + +local function init(s) + local wibar = awful.wibar { + position = "bottom", + height = 60, + ontop = false, + width = 1920, + bg = beautiful.bg, + fg = beautiful.fg1, + screen = s, + widget = { + + { + { + { + profile, + layout, + { + { + { + align = 'center', + font = beautiful.icon .. " 16", + markup = helpers.colorizeText('󱓟', beautiful.fg), + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + top = 10, + bottom = 10, + left = 10, + right = 10 + }, + widget = wibox.container.background, + shape = helpers.rrect(5), + bg = beautiful.mbg, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::dash') + end) + }, + }, + { + { + tags(s), + widget = wibox.container.margin, + left = 15, + right = 15, + }, + shape = helpers.rrect(5), + widget = wibox.container.background, + bg = beautiful.mbg, + }, + spacing = 15, + layout = wibox.layout.fixed.horizontal + }, + widget = wibox.container.place, + valign = "center" + }, + widget = wibox.container.margin, + left = 15, + }, + { + { + { + task.widget, + widget = wibox.container.margin, + }, + widget = wibox.container.place, + valign = "center", + halign = "left", + }, + widget = wibox.container.margin, + }, + { + { + { + systray, + music, + { + { + { + battery, + wifi, + bluetooth, + spacing = 15, + layout = wibox.layout.fixed.horizontal + }, + widget = wibox.container.margin, + top = 10, + bottom = 10, + left = 10, + right = 10 + }, + widget = wibox.container.background, + shape = helpers.rrect(5), + bg = beautiful.mbg, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::control') + end) + }, + }, + hourminutes, + { + { + { + { + align = 'center', + font = beautiful.icon .. " 16", + markup = helpers.colorizeText('󰂜', beautiful.fg), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::notify') + end) + }, + }, + { + align = 'center', + font = beautiful.icon .. " 16", + markup = helpers.colorizeText('󰐥', beautiful.red), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::exit') + end) + }, + }, + spacing = 20, + layout = wibox.layout.fixed.horizontal + }, + widget = wibox.container.margin, + top = 10, + bottom = 10, + left = 10, + right = 10 + }, + widget = wibox.container.background, + shape = helpers.rrect(5), + bg = beautiful.mbg, + }, + layout = wibox.layout.fixed.horizontal, + spacing = 10, + }, + widget = wibox.container.place, + valign = "center", + }, + widget = wibox.container.margin, + right = 10, + }, + layout = wibox.layout.align.horizontal, + } + } + return wibar +end + +screen.connect_signal('request::desktop_decoration', function(s) + s.wibox = init(s) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/battery.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/battery.lua new file mode 100644 index 0000000..6768d28 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/battery.lua @@ -0,0 +1,48 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local beautiful = require("beautiful") +local awful = require("awful") + +local battery = wibox.widget { + { + max_value = 100, + value = 69, + id = "prog", + forced_height = 22, + forced_width = 45, + paddings = 3, + border_color = beautiful.fg .. "99", + background_color = beautiful.mbg, + bar_shape = helpers.rrect(3), + color = beautiful.blue, + border_width = 1.25, + shape = helpers.rrect(5), + widget = wibox.widget.progressbar + }, + { + { + bg = beautiful.fg .. "99", + forced_height = 10, + forced_width = 2, + shape = helpers.rrect(10), + widget = wibox.container.background, + }, + widget = wibox.container.place, + valign = "center", + }, + spacing = 3, + layout = wibox.layout.fixed.horizontal +} +awesome.connect_signal("signal::battery", function(value) + local b = battery:get_children_by_id("prog")[1] + b.value = value + if value > 80 then + b.color = beautiful.green + elseif value > 20 then + b.color = beautiful.blue + else + b.color = beautiful.red + end +end) + +return battery diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/bluetooth.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/bluetooth.lua new file mode 100644 index 0000000..538bce4 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/bluetooth.lua @@ -0,0 +1,23 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local helpers = require("helpers") + +local blue = wibox.widget { + font = beautiful.icon .. " 16", + markup = helpers.colorizeText("󰂯", beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "center" +} + +awesome.connect_signal("signal::bluetooth", function(value) + if value then + blue.markup = helpers.colorizeText("󰂯", beautiful.blue) + else + blue.markup = helpers.colorizeText("󰂲", beautiful.fg2 .. "99") + end +end) + +return blue diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/layout.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/layout.lua new file mode 100644 index 0000000..3df5ee8 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/layout.lua @@ -0,0 +1,44 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local helpers = require('helpers') +local layouts = awful.widget.layoutbox { + buttons = { + awful.button { + modifiers = {}, + button = 1, + on_press = function() awful.layout.inc(1) end, + }, + awful.button { + modifiers = {}, + button = 3, + on_press = function() awful.layout.inc(-1) end, + }, + awful.button { + modifiers = {}, + button = 4, + on_press = function() awful.layout.inc(-1) end, + }, + awful.button { + modifiers = {}, + button = 5, + on_press = function() awful.layout.inc(1) end, + }, + } +} +local widget = { + { + { + layouts, + clip_shape = helpers.rrect(3), + widget = wibox.container.margin + }, + margins = 10, + widget = wibox.container.margin + }, + bg = beautiful.mbg, + forced_height = 30, + shape = helpers.rrect(5), + widget = wibox.container.background +} +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/music.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/music.lua new file mode 100644 index 0000000..e15aa1f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/music.lua @@ -0,0 +1,95 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local pctl = require("mods.playerctl") +local helpers = require("helpers") +local playerctl = pctl.lib() +local art = wibox.widget { + image = helpers.cropSurface(5.8, gears.surface.load_uncached(beautiful.songdefpicture)), + opacity = 0.3, + forced_height = dpi(36), + shape = helpers.rrect(5), + forced_width = dpi(240), + widget = wibox.widget.imagebox +} +playerctl:connect_signal("metadata", function(_, title, artist, album_path, album, new, player_name) + -- Set art widget + art.image = helpers.cropSurface(5.8, gears.surface.load_uncached(album_path)) +end) +local next = wibox.widget { + align = 'center', + font = beautiful.icon .. " 18", + text = '󰒭', + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:next() + end) + }, +} + +local prev = wibox.widget { + align = 'center', + font = beautiful.icon .. " 18", + text = '󰒮', + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:previous() + end) + }, +} +local play = wibox.widget { + align = 'center', + font = beautiful.icon .. " 20", + markup = helpers.colorizeText('󰐊', beautiful.fg), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:play_pause() + end) + }, +} +playerctl:connect_signal("playback_status", function(_, playing, player_name) + play.markup = playing and helpers.colorizeText("󰏤", beautiful.fg) or helpers.colorizeText("󰐊", beautiful.fg) +end) +local finalwidget = wibox.widget { + { + art, + { + { + widget = wibox.widget.textbox, + }, + bg = { + type = "linear", + from = { 0, 0 }, + to = { 250, 0 }, + stops = { { 0, beautiful.bg .. "00" }, { 1, beautiful.mbg } } + }, + widget = wibox.container.background, + }, + { + { + { + align = 'center', + font = beautiful.icon .. " 18", + markup = helpers.colorizeText('󰋎', beautiful.fg), + widget = wibox.widget.textbox, + }, + nil, + { prev, play, next, spacing = 8, layout = wibox.layout.fixed.horizontal }, + layout = wibox.layout.align.horizontal, + }, + widget = wibox.container.margin, + left = 6, + right = 6, + }, + layout = wibox.layout.stack, + }, + widget = wibox.container.background, + shape = helpers.rrect(5), +} + +return finalwidget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/profile.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/profile.lua new file mode 100644 index 0000000..00d75cf --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/profile.lua @@ -0,0 +1,20 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local beautiful = require("beautiful") +local awful = require("awful") + +local profile = wibox.widget { + widget = wibox.widget.imagebox, + image = beautiful.pfp, + forced_height = 40, + forced_width = 40, + clip_shape = helpers.rrect(40), + resize = true, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::launcher') + end) + }, +} + +return profile diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/systray.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/systray.lua new file mode 100644 index 0000000..efbd5c2 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/systray.lua @@ -0,0 +1,63 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local helpers = require("helpers") +local wibox = require("wibox") +local dpi = require("beautiful").xresources.apply_dpi + +-- TOGGLER + +local togglertext = wibox.widget { + font = beautiful.icon .. " 20", + text = "󰅁", + valign = "center", + align = "center", + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('systray::toggle') + end) + }, + widget = wibox.widget.textbox, +} + +-- TRAY + +local systray = wibox.widget { + { + { + base_size = 18, + widget = wibox.widget.systray, + }, + widget = wibox.container.place, + valign = "center", + }, + visible = false, + left = 10, + right = 8, + widget = wibox.container.margin +} + +awesome.connect_signal('systray::toggle', function() + if systray.visible then + systray.visible = false + togglertext.text = '󰅁' + else + systray.visible = true + togglertext.text = '󰅂' + end +end) + +local widget = wibox.widget { + { + { + systray, + togglertext, + layout = wibox.layout.fixed.horizontal, + }, + shape = helpers.rrect(2), + bg = beautiful.mbg, + widget = wibox.container.background, + }, + margins = 0, + widget = wibox.container.margin, +} +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/tags.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/tags.lua new file mode 100644 index 0000000..426c33d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/tags.lua @@ -0,0 +1,68 @@ +local awful = require("awful") +local wibox = require("wibox") +local gears = require("gears") +local helpers = require("helpers") +local animation = require("mods.animation") +local beautiful = require("beautiful") +return function(s) + local taglist = awful.widget.taglist { + layout = { + spacing = 8, + layout = wibox.layout.fixed.horizontal, + }, + style = { + shape = helpers.rrect(9) + }, + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = { + awful.button({}, 1, function(t) t:view_only() end), + awful.button({}, 4, function(t) + awful.tag.viewprev(t.screen) + end), + awful.button({}, 5, function(t) + awful.tag.viewnext(t.screen) + end) + }, + widget_template = { + { + { + markup = '', + shape = helpers.rrect(3), + widget = wibox.widget.textbox, + }, + valign = 'center', + id = 'background_role', + shape = helpers.rrect(1), + widget = wibox.container.background, + forced_width = 40, + forced_height = 14, + }, + widget = wibox.container.place, + create_callback = function(self, tag) + self.taganim = animation:new({ + duration = 0.25, + easing = animation.easing.linear, + update = function(_, pos) + self:get_children_by_id('background_role')[1].forced_width = pos + end, + }) + self.update = function() + if tag.selected then + self.taganim:set(60) + elseif #tag:clients() > 0 then + self.taganim:set(40) + else + self.taganim:set(20) + end + end + + self.update() + end, + update_callback = function(self) + self.update() + end, + } + } + return taglist +end diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/task.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/task.lua new file mode 100644 index 0000000..9b198ec --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/task.lua @@ -0,0 +1,397 @@ +local awful = require("awful") +local dpi = require("beautiful").xresources.apply_dpi +local wibox = require("wibox") +local gears = require("gears") +local Gio = require("lgi").Gio +local helpers = require("helpers") +local beautiful = require("beautiful") +local getIcon = require("mods.getIcon") + +local layout = wibox.layout.fixed.horizontal +local flexlayout = wibox.layout.flex.horizontal + +local inspect = require("mods.inspect") +local M = { + metadata = { + { + count = 0, + pinned = true, + icon = getIcon(nil, "firefox", "firefox"), + id = 1, + clients = {}, + class = "firefox", + exec = "firefox", + name = "firefox", + }, + { + count = 0, + pinned = true, + icon = getIcon(nil, "org.wezfurlong.wezterm", "org.wezfurlong.wezterm"), + id = 2, + clients = {}, + class = "org.wezfurlong.wezterm", + exec = "wezterm", + name = "wezterm", + }, + { + count = 0, + pinned = true, + icon = getIcon(nil, "discord", "discord"), + id = 3, + clients = {}, + class = "discord", + exec = "discord", + name = "discord", + }, + { + count = 0, + pinned = true, + icon = getIcon(nil, "spotify", "spotify"), + id = 4, + clients = {}, + class = "spotify", + exec = "spotify", + name = "spotify", + }, + { + count = 0, + pinned = true, + icon = getIcon(nil, "steam", "steam"), + id = 4, + clients = {}, + class = "steam", + exec = "steam", + name = "steam", + }, + }, + entries = {}, + classes = { "firefox", "org.wezfurlong.wezterm", "discord", "spotify", "steam" } +} + +M.widget = wibox.widget { + layout = layout, + spacing = 10, +} + +M.popupWidget = wibox.widget { + layout = wibox.layout.fixed.vertical, + spacing = 10, +} + +M.popup = awful.popup { + minimum_width = 240, + widget = wibox.container.background, + visible = false, + shape = helpers.rrect(5), + ontop = true, + bg = beautiful.bg +} + +M.popup:setup { + widget = wibox.container.margin, + margins = 10, + M.popupWidget, +} + +local removeDup = function(arr) + local hash = {} + local res = {} + + for _, v in ipairs(arr) do + if (not hash[v]) then + res[#res + 1] = v -- you could print here instead of saving to result table if you wanted + hash[v] = true + end + end + + return res +end + + +function M:getExecutable(class) + local class_1 = class:gsub("[%-]", "") + local class_2 = class:gsub("[%-]", ".") + + local class_3 = class:match("(.-)-") or class + class_3 = class_3:match("(.-)%.") or class_3 + class_3 = class_3:match("(.-)%s+") or class_3 + local apps = Gio.AppInfo.get_all() + local possible_icon_names = { class, class_3, class_2, class_1 } + for _, app in ipairs(apps) do + local id = app:get_id():lower() + for _, possible_icon_name in ipairs(possible_icon_names) do + if id and id:find(possible_icon_name, 1, true) then + return app:get_executable() + end + end + end + return class:lower() +end + +function M:showMenu(data) + local clients = data.clients + self.popup.x = mouse.coords().x - 80 + self.popup.y = 1080 - 70 - (50 * (#clients + 2)) + self.popupWidget:reset() + for i, j in ipairs(clients) do + local widget = wibox.widget { + { + { + { + { + markup = j.name, + font = beautiful.font .. " 12", + height = 16, + widget = wibox.widget.textbox, + }, + widget = wibox.container.constraint, + width = 180, + height = 16, + }, + nil, + { + markup = helpers.colorizeText("󰅖", beautiful.red), + font = beautiful.icon .. " 16", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + j:kill() + self.popup.visible = false + end) + }, + }, + layout = wibox.layout.align.horizontal + }, + widget = wibox.container.margin, + margins = 7, + }, + buttons = { + awful.button({}, 1, function() + if j.minimized then + j.minimized = false + client.focus = j + else + j.minimized = true + end + self.popup.visible = false + end) + }, + widget = wibox.container.background, + shape = helpers.rrect(4), + bg = j.minimized and beautiful.fg .. '22' or beautiful.mbg + } + M.popupWidget:connect_signal("mouse::leave", function() + self.popup.visible = false + end) + self.popupWidget:add(widget) + end + local addNew = wibox.widget { + { + { + { + { + markup = "Open New Window", + font = beautiful.font .. " 12", + widget = wibox.widget.textbox, + }, + widget = wibox.container.constraint, + width = 180, + }, + nil, + nil, + layout = wibox.layout.align.horizontal + }, + widget = wibox.container.margin, + margins = 7, + }, + buttons = { + awful.button({}, 1, function() + awful.spawn.with_shell(data.exec) + end) + }, + widget = wibox.container.background, + shape = helpers.rrect(4), + bg = beautiful.mbg + } + local closeAll = wibox.widget { + { + { + { + { + markup = "Close All", + font = beautiful.font .. " 12", + widget = wibox.widget.textbox, + }, + widget = wibox.container.constraint, + width = 180, + }, + nil, + nil, + layout = wibox.layout.align.horizontal + }, + widget = wibox.container.margin, + margins = 7, + }, + buttons = { + awful.button({}, 1, function() + for i, j in ipairs(clients) do + j:kill() + end + end) + }, + widget = wibox.container.background, + shape = helpers.rrect(4), + bg = beautiful.mbg + } + self.popupWidget:add(addNew) + self.popupWidget:add(closeAll) + self.popup.visible = true +end + +function M:genMetadata() + local clients = mouse.screen.selected_tag and mouse.screen.selected_tag:clients() or {} + + for _, j in pairs(self.metadata) do + j.count = 0 + j.clients = {} + end + for _, c in ipairs(clients) do + local icon = getIcon(c, c.class, c.class) + local class = string.lower(c.class or "default") + local exe = self:getExecutable(c.class) + if helpers.inTable(self.classes, class) then + for _, j in pairs(self.metadata) do + if j.class:lower() == class:lower() then + table.insert(j.clients, c) + j.count = j.count + 1 + end + end + else + table.insert(self.classes, class) + local toInsert = { + count = 1, + pinned = false, + icon = icon, + id = #self.classes + 1, + clients = { c }, + class = class, + exec = exe, + name = c.name, + } + table.insert(self.metadata, toInsert) + end + for _, j in pairs(self.metadata) do + j.clients = removeDup(j.clients) + end + end + table.sort(self.metadata, function(a, b) return a.id < b.id end) +end + +local function getMinimized(clients) + local a = 0 + for i, j in ipairs(clients) do + if j.minimized then + a = a + 1 + end + end + return a +end + +function M:genIcons() + self:genMetadata() + self.widget:reset() + print(inspect(self.metadata)) + for i, j in ipairs(self.metadata) do + if j.pinned == true or j.count > 0 then + local minimized = getMinimized(j.clients) + local bg = beautiful.bg + if client.focus then + if client.focus.class:lower() == j.class then + bg = beautiful.fg .. "22" + elseif j.count > 0 then + bg = beautiful.fg .. "33" + end + elseif minimized > 0 then + bg = beautiful.fg .. "33" + end + local widget = wibox.widget { + { + { + widget = wibox.widget.imagebox, + image = j.icon, + forced_height = 35, + forced_width = 35, + clip_shape = helpers.rrect(100), + resize = true, + }, + widget = wibox.container.margin, + margins = 3, + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = bg, + + } + widget:buttons(gears.table.join( + awful.button({}, 1, function() + if j.count == 0 then + awful.spawn.with_shell(j.exec) + elseif j.count == 1 then + if j.clients[j.count].minimized then + j.clients[j.count].minimized = false + client.focus = j.clients[j.count] + else + j.clients[j.count].minimized = true + end + else + self:showMenu(j) + end + end), + awful.button({}, 3, function() + self:showMenu(j) + end) + )) + self.widget:add(widget) + end + end +end + +client.connect_signal( + "focus", + function() + M:genIcons() + end +) +client.connect_signal( + "property::minimized", + function() + M:genIcons() + end +) +client.connect_signal( + "property::maximized", + function() + M:genIcons() + end +) +client.connect_signal( + "manage", + function() + M:genIcons() + M.popup.visible = false + end +) +client.connect_signal( + "unmanage", + function() + M:genIcons() + M.popup.visible = false + end +) +tag.connect_signal("property::selected", function() + M:genIcons() + M.popup.visible = false +end) +M:genIcons() + +return M diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/time.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/time.lua new file mode 100644 index 0000000..857d112 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/time.lua @@ -0,0 +1,47 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local helpers = require("helpers") +local hourminutes = wibox.widget { + { + { + { + { + font = beautiful.sans .. " 15", + format = "%I : %M", + align = "center", + valign = "center", + widget = wibox.widget.textclock + }, + widget = wibox.container.place, + valign = "center" + }, + { + { + font = beautiful.sans .. " 12", + format = "%d %B", + align = "center", + valign = "center", + widget = wibox.widget.textclock + }, + widget = wibox.container.place, + valign = "center" + }, + layout = wibox.layout.fixed.horizontal, + spacing = 20 + }, + margins = { left = dpi(10), right = dpi(10) }, + widget = wibox.container.margin + }, + bg = beautiful.mbg, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::moment') + end) + }, + widget = wibox.container.background, + shape = helpers.rrect(2), +} + +return hourminutes diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/wifi.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/wifi.lua new file mode 100644 index 0000000..11b0774 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/bar/mods/wifi.lua @@ -0,0 +1,23 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local helpers = require("helpers") + +local wifi = wibox.widget { + font = beautiful.icon .. " 16", + markup = helpers.colorizeText("󰤨", beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "center" +} + +awesome.connect_signal("signal::network", function(value) + if value then + wifi.markup = "󰤨" + else + wifi.markup = helpers.colorizeText("󰤮", beautiful.fg2 .. "99") + end +end) + +return wifi diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/init.lua new file mode 100644 index 0000000..ec7fe77 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/init.lua @@ -0,0 +1,117 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = beautiful.xresources.apply_dpi +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") + +local buttons = require("ui.control.mods.buttons") +local moosic = require("ui.control.mods.music") +local sliders = require("ui.control.mods.slider") +local footer = require("ui.control.mods.footer") + +awful.screen.connect_for_each_screen(function(s) + local control = wibox({ + shape = helpers.rrect(8), + screen = s, + width = 520, + height = 760, + bg = beautiful.bg .. "00", + ontop = true, + visible = false, + }) + + control:setup { + { + { + moosic, + forced_height = 270, + widget = wibox.container.background, + bg = beautiful.bg, + shape = helpers.rrect(12), + }, + widget = wibox.container.margin, + bottom = 20, + }, + { + { + { + { + + { + layout = wibox.layout.align.horizontal, + { + { + widget = wibox.widget.imagebox, + image = beautiful.pfp, + forced_height = 50, + opacity = 0.7, + forced_width = 50, + clip_shape = helpers.rrect(8), + resize = true, + }, + { + { + { + footer, + widget = wibox.container.place, + valign = "center", + }, + widget = wibox.container.margin, + left = 10, + right = 10, + }, + widget = wibox.container.background, + shape = helpers.rrect(5), + bg = beautiful.mbg + }, + layout = wibox.layout.fixed.horizontal, + spacing = 20, + }, + nil, + { + { + { + font = beautiful.icon .. " 14", + markup = helpers.colorizeText("󰐱", beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "center" + }, + widget = wibox.container.margin, + margins = 15 + }, + widget = wibox.container.background, + shape = helpers.rrect(6), + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::setup') + end) + }, + bg = beautiful.mbg + }, + }, + widget = wibox.container.margin, + top = 18, + }, + sliders, + buttons, + layout = wibox.layout.fixed.vertical, + spacing = 25, + }, + widget = wibox.container.margin, + left = 20, + right = 20, + }, + widget = wibox.container.background, + bg = beautiful.bg, + shape = helpers.rrect(12), + }, + nil, + layout = wibox.layout.align.vertical, + } + awful.placement.bottom_right(control, { honor_workarea = true, margins = 20 }) + awesome.connect_signal("toggle::control", function() + control.visible = not control.visible + end) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/buttons.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/buttons.lua new file mode 100644 index 0000000..26e6528 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/buttons.lua @@ -0,0 +1,106 @@ +local awful = require("awful") +local wibox = require("wibox") +local helpers = require("helpers") +local beautiful = require("beautiful") + +local createButton = function(cmd, icon, name, labelConnected, labelDisconnected, signal) + local widget = wibox.widget { + { + { + { + { + markup = icon, + id = "icon", + font = beautiful.icon .. " 18", + widget = wibox.widget.textbox, + }, + { + { + markup = name, + id = "name", + font = beautiful.sans .. " 11", + widget = wibox.widget.textbox, + }, + { + markup = labelConnected, + id = "label", + font = beautiful.sans .. " 10", + widget = wibox.widget.textbox, + }, + layout = wibox.layout.fixed.vertical, + spacing = 0 + }, + layout = wibox.layout.fixed.horizontal, + spacing = 10 + }, + nil, + { + markup = "󰅂", + font = beautiful.icon .. " 20", + id = "arr", + widget = wibox.widget.textbox, + }, + layout = wibox.layout.align.horizontal, + }, + widget = wibox.container.margin, + top = 15, + bottom = 15, + left = 18, + right = 18 + }, + widget = wibox.container.background, + id = "back", + shape = helpers.rrect(8), + bg = beautiful.mbg, + buttons = { awful.button({}, 1, function() + awful.spawn.with_shell(cmd) + end) } + } + awesome.connect_signal('signal::' .. signal, function(status) + if status then + widget:get_children_by_id("back")[1].bg = beautiful.blue + widget:get_children_by_id("arr")[1].markup = helpers.colorizeText("󰅂", beautiful.bg) + widget:get_children_by_id("name")[1].markup = helpers.colorizeText(name, beautiful.bg) + widget:get_children_by_id("icon")[1].markup = helpers.colorizeText(icon, beautiful.bg) + widget:get_children_by_id("label")[1].markup = helpers.colorizeText(labelConnected, beautiful.bg) + else + widget:get_children_by_id("back")[1].bg = beautiful.mbg .. 'aa' + widget:get_children_by_id("arr")[1].markup = helpers.colorizeText("󰅂", beautiful.fg .. 'cc') + widget:get_children_by_id("name")[1].markup = helpers.colorizeText(name, beautiful.fg .. 'cc') + widget:get_children_by_id("icon")[1].markup = helpers.colorizeText(icon, beautiful.fg .. 'cc') + widget:get_children_by_id("label")[1].markup = helpers.colorizeText(labelDisconnected, beautiful.fg .. 'cc') + end + end) + return widget +end + +local widget = wibox.widget { + { + createButton("~/.config/awesome/misc/scripts/wifi --toggle", "󰤨", "Network", "Connected", "Disconnected", + "network"), + createButton("~/.config/awesome/misc/scripts/bluetooth --toggle", "󰂯", "Bluetooth", "Connected", "Disconnected", + "bluetooth"), + spacing = 20, + layout = wibox.layout.flex.horizontal + }, + { + createButton("~/.config/awesome/misc/scripts/airplanemode --toggle", "󰀝", "Airplane Mode", "Now In Flight Mode", + "Turned Off", "airplane"), + createButton('awesome-client \'naughty = require("naughty") naughty.toggle()\'', "󰍶", "Do Not Disturb", + "Turned On", "Turned Off", "dnd"), + spacing = 20, + layout = wibox.layout.flex.horizontal + }, + { + createButton("~/.config/awesome/misc/scripts/redshift --toggle", "󰛨", "Redshift", "Your Eyes Are Safe", + "Night Light Is Off", "redshift"), + createButton('pamixer --source 1 -t', "󰍬", "Microphone", + "Its Muted", "It is turned on", "mic"), + spacing = 20, + layout = wibox.layout.flex.horizontal + }, + layout = wibox.layout.fixed.vertical, + spacing = 20 +} + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/footer.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/footer.lua new file mode 100644 index 0000000..2fbd78c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/footer.lua @@ -0,0 +1,62 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local beautiful = require("beautiful") +local awful = require("awful") + +local widget = wibox.widget { + { + { + max_value = 100, + value = 69, + id = "prog", + forced_height = 20, + forced_width = 40, + paddings = 3, + border_color = beautiful.fg .. "99", + background_color = beautiful.mbg, + bar_shape = helpers.rrect(2), + color = beautiful.blue, + border_width = 1.25, + shape = helpers.rrect(5), + widget = wibox.widget.progressbar + }, + { + { + bg = beautiful.fg .. "99", + forced_height = 10, + forced_width = 2, + shape = helpers.rrect(10), + widget = wibox.container.background, + }, + widget = wibox.container.place, + valign = "center", + }, + spacing = 3, + layout = wibox.layout.fixed.horizontal + + }, + { + font = beautiful.sans .. " 12", + markup = helpers.colorizeText("25%", beautiful.fg), + valign = "center", + id = "batvalue", + widget = wibox.widget.textbox, + }, + layout = wibox.layout.fixed.horizontal, + spacing = 10 +} +awesome.connect_signal("signal::battery", function(value) + local b = widget:get_children_by_id("prog")[1] + local v = widget:get_children_by_id("batvalue")[1] + v.markup = helpers.colorizeText(value .. "%", beautiful.fg) + b.value = value + if value > 80 then + b.color = beautiful.green + elseif value > 20 then + b.color = beautiful.blue + else + b.color = beautiful.red + end +end) + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/music.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/music.lua new file mode 100644 index 0000000..be47b82 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/music.lua @@ -0,0 +1,148 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local pctl = require("mods.playerctl") +local helpers = require("helpers") +local playerctl = pctl.lib() +local art = wibox.widget { + image = helpers.cropSurface(1.71, gears.surface.load_uncached(beautiful.songdefpicture)), + opacity = 0.3, + resize = true, + clip_shape = helpers.rrect(12), + widget = wibox.widget.imagebox +} +local next = wibox.widget { + align = 'center', + font = beautiful.icon .. " 22", + text = '󰒭', + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:next() + end) + }, +} + +local prev = wibox.widget { + align = 'center', + font = beautiful.icon .. " 22", + text = '󰒮', + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:previous() + end) + }, +} +local play = wibox.widget { + align = 'center', + font = beautiful.icon .. " 22", + markup = helpers.colorizeText('󰐍', beautiful.fg), + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + playerctl:play_pause() + end) + }, +} +playerctl:connect_signal("playback_status", function(_, playing, player_name) + play.markup = playing and helpers.colorizeText("󰏦", beautiful.fg) or helpers.colorizeText("󰐍", beautiful.fg) +end) +local finalwidget = wibox.widget { + + { + nil, + { + art, + { + { + widget = wibox.widget.textbox, + }, + bg = { + type = "linear", + from = { 0, 0 }, + to = { 250, 0 }, + stops = { { 0, beautiful.bg .. "ff" }, { 1, beautiful.mbg .. '55' } } + }, + shape = helpers.rrect(12), + widget = wibox.container.background, + }, + { + { + { + { + id = "songname", + font = beautiful.sans .. " 14", + markup = helpers.colorizeText('Song Name', beautiful.fg), + widget = wibox.widget.textbox, + }, + { + id = "artist", + font = beautiful.sans .. " 12", + markup = helpers.colorizeText('Artist Name', beautiful.fg), + widget = wibox.widget.textbox, + }, + spacing = 8, + layout = wibox.layout.fixed.vertical, + }, + nil, + { + id = "player", + font = beautiful.sans .. " 12", + markup = helpers.colorizeText('Playing Via Spotify', beautiful.fg), + widget = wibox.widget.textbox, + }, + layout = wibox.layout.align.vertical + }, + widget = wibox.container.margin, + margins = 20 + }, + layout = wibox.layout.stack, + }, + { + { + { + { + prev, + play, + next, + layout = wibox.layout.align.vertical, + }, + widget = wibox.container.margin, + top = 25, + bottom = 25, + left = 20, + right = 20, + }, + shape = helpers.rrect(12), + widget = wibox.container.background, + bg = beautiful.mbg, + }, + widget = wibox.container.margin, + left = 20, + }, + layout = wibox.layout.align.horizontal, + }, + widget = wibox.container.margin, + margins = 20, +} + +playerctl:connect_signal("metadata", function(_, title, artist, album_path, album, new, player_name) + if album_path == "" then + album_path = beautiful.songdefpicture + end + if string.len(title) > 30 then + title = string.sub(title, 0, 30) .. "..." + end + if string.len(artist) > 22 then + artist = string.sub(artist, 0, 22) .. "..." + end + art.image = helpers.cropSurface(1.71, gears.surface.load_uncached(album_path)) + helpers.gc(finalwidget, "songname"):set_markup_silently(helpers.colorizeText(title or "NO", beautiful.fg)) + helpers.gc(finalwidget, "artist"):set_markup_silently(helpers.colorizeText(artist or "HM", beautiful.fg)) + helpers.gc(finalwidget, "player"):set_markup_silently(helpers.colorizeText("Playing Via: " .. player_name or "", + beautiful.fg)) +end) +return finalwidget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/slider.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/slider.lua new file mode 100644 index 0000000..da6fb76 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/control/mods/slider.lua @@ -0,0 +1,106 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local helpers = require("helpers") + +local createHandle = function() + return function(cr) + gears.shape.rounded_rect(cr, 20, 20, 15) + end +end + +local createSlider = function(icon, signal, command) + local slidSlider = wibox.widget { + bar_shape = helpers.rrect(15), + bar_height = 3, + handle_color = beautiful.bg, + bar_color = beautiful.bg .. '00', + bar_active_color = beautiful.fg, + handle_shape = createHandle(), + handle_border_width = 2, + handle_width = dpi(20), + handle_margins = { top = 5.9 }, + handle_border_color = beautiful.fg, + value = 25, + forced_height = 35, + maximum = 100, + widget = wibox.widget.slider, + } + + local slidLabel = wibox.widget { + + font = beautiful.sans .. " Bold 12", + markup = "86" .. "%", + valign = "center", + widget = wibox.widget.textbox, + } + + + local slidLabelBox = wibox.widget { + slidLabel, + widget = wibox.container.margin, + margins = { + left = dpi(16), + } + } + + local slidIcon = wibox.widget { + { + font = beautiful.icon .. " 15", + markup = helpers.colorizeText(icon, beautiful.fg), + valign = "center", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + } + + local slidScale = wibox.widget { + nil, + { + { + slidIcon, + widget = wibox.container.place, + valign = "center", + halign = "left" + }, + { + { + { + widget = wibox.container.background, + forced_height = 2, + shape = helpers.rrect(10), + bg = beautiful.mbg + }, + widget = wibox.container.place, + content_fill_horizontal = true, + valign = "center", + }, + slidSlider, + layout = wibox.layout.stack, + }, + layout = wibox.layout.fixed.horizontal, + spacing = 20 + }, + nil, + layout = wibox.layout.align.horizontal, + } + + awesome.connect_signal('signal::' .. signal, function(value) + slidSlider.value = value + end) + slidSlider:connect_signal("property::value", function(_, new_value) + awful.spawn.with_shell(string.format(command, new_value)) + end) + return slidScale +end + +local widget = wibox.widget { + createSlider("󰃟", "brightness", "brightnessctl s %d%%"), + createSlider("󰓃", "volume", "pamixer --set-volume %d"), + layout = wibox.layout.fixed.vertical, + spacing = 25, +} + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/init.lua new file mode 100644 index 0000000..4a87303 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/init.lua @@ -0,0 +1,61 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = beautiful.xresources.apply_dpi +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") + +local profile = require("ui.dash.mods.profile") +local pomo = require("ui.dash.mods.pomo") +local quote = require("ui.dash.mods.quote") + +local song = require("ui.dash.mods.song") +local todo = require("ui.dash.mods.todo") + +local time = require("ui.dash.mods.time") +local nf = require("ui.dash.mods.nf") +local weather = require("ui.dash.mods.weather") + +awful.screen.connect_for_each_screen(function(s) + local dash = wibox({ + shape = helpers.rrect(12), + screen = s, + width = 1350, + height = 790, + bg = beautiful.bg, + ontop = true, + visible = false, + }) + + dash:setup { + { + { + profile, + pomo, + quote, + layout = wibox.layout.align.vertical, + }, + { + nil, + todo, + song, + layout = wibox.layout.align.vertical, + }, + { + time, + nf, + weather, + spacing = 20, + layout = wibox.layout.fixed.vertical, + }, + spacing = 20, + layout = wibox.layout.flex.horizontal, + }, + widget = wibox.container.margin, + margins = 20, + } + awful.placement.centered(dash, { honor_workarea = true, margins = 20 }) + awesome.connect_signal("toggle::dash", function() + dash.visible = not dash.visible + end) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/nf.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/nf.lua new file mode 100644 index 0000000..c1d78e8 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/nf.lua @@ -0,0 +1,141 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local helpers = require("helpers") + + +local widget = wibox.widget { + { + { + { + { + { + { + { + font = beautiful.mono .. " 14", + markup = helpers.colorizeText('>', beautiful.bg), + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + top = 5, + bottom = 5, + left = 10, + right = 10, + }, + widget = wibox.container.background, + bg = beautiful.blue + }, + { + { + font = beautiful.mono .. " 14", + markup = helpers.colorizeText('fetch.sh', beautiful.fg), + widget = wibox.widget.textbox, + }, + widget = wibox.container.place, + valign = "center", + }, + spacing = 15, + layout = wibox.layout.fixed.horizontal, + }, + nil, + nil, + layout = wibox.layout.align.horizontal, + }, + { + { + widget = wibox.widget.imagebox, + image = beautiful.nixos, + forced_height = 140, + forced_width = 140, + resize = true, + }, + { + { + font = beautiful.mono .. " 14", + markup = helpers.colorizeText('OS : NixOS 24.05', beautiful.fg), + widget = wibox.widget.textbox, + }, + { + font = beautiful.mono .. " 14", + markup = helpers.colorizeText('WM : Awesome', beautiful.fg), + widget = wibox.widget.textbox, + }, + { + font = beautiful.mono .. " 14", + markup = helpers.colorizeText('USER: ' .. beautiful.user, beautiful.fg), + widget = wibox.widget.textbox, + }, + { + font = beautiful.mono .. " 14", + markup = helpers.colorizeText('SH : ZSH', beautiful.fg), + widget = wibox.widget.textbox, + }, + spacing = 8, + layout = wibox.layout.fixed.vertical, + }, + spacing = 20, + layout = wibox.layout.fixed.horizontal, + }, + { + { + { + widget = wibox.container.background, + bg = beautiful.bg3, + forced_height = 20, + shape = helpers.rrect(5), + forced_width = 20, + }, + { + widget = wibox.container.background, + bg = beautiful.red, + forced_height = 20, + shape = helpers.rrect(5), + forced_width = 20, + }, + { + widget = wibox.container.background, + bg = beautiful.green, + forced_height = 20, + shape = helpers.rrect(5), + forced_width = 20, + }, + { + widget = wibox.container.background, + bg = beautiful.yellow, + forced_height = 20, + shape = helpers.rrect(5), + forced_width = 20, + }, + { + widget = wibox.container.background, + bg = beautiful.blue, + forced_height = 20, + shape = helpers.rrect(5), + forced_width = 20, + }, + { + widget = wibox.container.background, + bg = beautiful.magenta, + forced_height = 20, + shape = helpers.rrect(5), + forced_width = 20, + }, + spacing = 12, + layout = wibox.layout.fixed.horizontal, + }, + widget = wibox.container.place, + halign = "center" + }, + spacing = 20, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.margin, + margins = 40 + }, + widget = wibox.container.background, + bg = beautiful.mbg, + shape = helpers.rrect(20) +} + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/pomo.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/pomo.lua new file mode 100644 index 0000000..2a64197 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/pomo.lua @@ -0,0 +1,252 @@ +local gears = require("gears") +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local helpers = require("helpers") + +local timer = { defaultTime = 25 * 60 } + + +function timer:stop() + self.clock:stop() +end + +function timer:pause() + self.paused = true + self.pausedTime = os.time() +end + +function timer:resume() + self.paused = false + self.clock:again() + if self.pausedTime then + self.pausedTime = nil + end +end + +function timer:new() + self.timeRemaining = self.defaultTime + self.paused = true + self.pausedTime = nil + + self.widget = wibox.widget { + { + id = "image", + image = helpers.cropSurface(1.42, gears.surface.load_uncached(gears.filesystem.get_configuration_dir() .. "/theme/assets/pomo.jpg")), + widget = wibox.widget.imagebox, + clip_shape = helpers.rrect(20), + opacity = 0.9, + resize = true, + horizontal_fit_policy = "fit" + }, + { + { + widget = wibox.widget.textbox, + }, + bg = { + type = "linear", + from = { 0, 0 }, + to = { 200, 0 }, + stops = { { 0, beautiful.mbg .. "aa" }, { 1, beautiful.bg .. 'dd' } } + }, + shape = helpers.rrect(20), + widget = wibox.container.background, + }, + { + { + { + { + { + { + id = "timer", + font = beautiful.sans .. " 48", + markup = "00:00", + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + widget = wibox.container.place, + halign = 'center' + }, + { + { + { + { + { + id = "reset", + font = beautiful.icon .. " 20", + markup = helpers.colorizeText("󰍴", beautiful.fg), + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 12, + }, + widget = wibox.container.background, + shape = helpers.rrect(50), + buttons = { + awful.button({}, 1, function() + if self.defaultTime > 5 * 60 then + self.paused = true + self.defaultTime = self.defaultTime - 5 * 60 + self.timeRemaining = self.defaultTime + self.timeRemaining = self.defaultTime + self.pausedTime = self.defaultTime + self.clock:stop() + self:update() + end + end) + }, + }, + { + { + { + id = "resume", + font = beautiful.icon .. " 20", + markup = helpers.colorizeText("󰐎", beautiful.blue), + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 12, + }, + widget = wibox.container.background, + shape = helpers.rrect(10), + buttons = { + awful.button({}, 1, function() + if self.paused == false then + self:pause() + else + self:resume() + end + end) + }, + bg = beautiful.blue .. '11' + }, + { + { + { + id = "reset", + font = beautiful.icon .. " 20", + markup = helpers.colorizeText("󰦛", beautiful.red), + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 12, + }, + widget = wibox.container.background, + shape = helpers.rrect(10), + buttons = { + awful.button({}, 1, function() + self.paused = true + self.timeRemaining = self.defaultTime + self.pausedTime = self.defaultTime + self.clock:stop() + self:update() + end) + }, + bg = beautiful.red .. '11' + }, + { + { + { + id = "increasetime", + font = beautiful.icon .. " 20", + markup = helpers.colorizeText("󰐕", beautiful.fg), + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 12, + }, + widget = wibox.container.background, + shape = helpers.rrect(50), + buttons = { + awful.button({}, 1, function() + self.paused = true + self.defaultTime = self.defaultTime + 5 * 60 + self.timeRemaining = self.defaultTime + self.timeRemaining = self.defaultTime + self.pausedTime = self.defaultTime + self.clock:stop() + self:update() + end) + }, + }, + layout = wibox.layout.fixed.horizontal, + spacing = 20, + }, + widget = wibox.container.place, + halign = 'center', + }, + layout = wibox.layout.fixed.vertical, + spacing = 40, + }, + widget = wibox.container.margin, + margins = 25, + }, + widget = wibox.container.place, + valign = 'center', + }, + shape = helpers.rrect(20), + widget = wibox.container.background, + }, + { + { + nil, + { + id = "prog", + max_value = 100, + value = 0, + forced_height = 20, + bar_shape = helpers.prect(false, false, true, true, 20), + shape = helpers.prect(false, false, true, true, 20), + color = beautiful.green, + background_color = beautiful.green .. '11', + paddings = 1, + border_width = 1, + widget = wibox.widget.progressbar, + }, + nil, + layout = wibox.layout.align.vertical, + }, + widget = wibox.container.place, + valign = "bottom" + }, + layout = wibox.layout.stack, + } + + function self:update() + local percent = math.floor((self.timeRemaining / self.defaultTime) * 100) + self.widget:get_children_by_id("timer")[1].markup = string.format("%02d:%02d", self.timeRemaining / 60, + self.timeRemaining % 60) + self.widget:get_children_by_id('prog')[1].value = percent + if self.timeRemaining == 0 then + awful.spawn.with_shell("notify-send 'Time is up!' 'Get some rest'") + end + end + + local tick = function() + if not self.paused then + self.timeRemaining = self.timeRemaining - 1 + self:update() + end + end + self.clock = gears.timer({ + timeout = 1, + call_now = true, + autostart = false, + callback = tick + }) + + + self:update() + return self.widget +end + +return timer:new() diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/profile.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/profile.lua new file mode 100644 index 0000000..856c8ae --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/profile.lua @@ -0,0 +1,54 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") + +local widget = wibox.widget { + { + { + { + { + { + widget = wibox.widget.imagebox, + image = beautiful.pfp, + forced_height = 140, + forced_width = 140, + clip_shape = helpers.rrect(100), + resize = true, + }, + widget = wibox.container.place, + halign = "center" + }, + { + markup = helpers.colorizeText("Welcome, " .. beautiful.user .. "!", beautiful.fg), + align = 'center', + font = beautiful.sans .. " 18", + widget = wibox.widget.textbox + }, + { + id = "uptime", + markup = helpers.colorizeText("Running since ", beautiful.fg), + align = 'center', + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + }, + spacing = 10, + layout = wibox.layout.fixed.vertical + }, + widget = wibox.container.margin, + margins = 30, + }, + shape = helpers.rrect(20), + widget = wibox.container.background, + bg = beautiful.mbg, + }, + widget = wibox.container.margin, + bottom = 20 +} +awesome.connect_signal("signal::uptime", function(v) + helpers.gc(widget, "uptime").markup = helpers.colorizeText(v, beautiful.fg2 .. "99") +end) + + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/quote.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/quote.lua new file mode 100644 index 0000000..c2ae656 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/quote.lua @@ -0,0 +1,41 @@ +local helpers = require("helpers") +local beautiful = require("beautiful") +local gears = require("gears") +local dpi = beautiful.xresources.apply_dpi +local awful = require("awful") +local wibox = require("wibox") + +local widget = wibox.widget { + { + { + { + { + font = beautiful.sans .. " 16", + markup = helpers.colorizeText("All our dreams can come true if we have the courage to pursue them", beautiful.fg), + widget = wibox.widget.textbox, + valign = "start", + align = "center" + }, + { + + font = beautiful.sans .. " Bold 12", + markup = helpers.colorizeText("Walt Disney", beautiful.magenta), + widget = wibox.widget.textbox, + valign = "start", + align = "center" + }, + spacing = 20, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.margin, + margins = 30 + }, + widget = wibox.container.background, + bg = beautiful.mbg, + shape = helpers.rrect(20), + }, + widget = wibox.container.margin, + top = 20 +} + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/song.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/song.lua new file mode 100644 index 0000000..28fea37 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/song.lua @@ -0,0 +1,85 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local pctl = require("mods.playerctl") +local helpers = require("helpers") +local playerctl = pctl.lib() + +local art = wibox.widget { + image = helpers.cropSurface(1.71, gears.surface.load_uncached(beautiful.songdefpicture)), + opacity = 0.3, + resize = true, + height = 300, + clip_shape = helpers.rrect(20), + widget = wibox.widget.imagebox +} + +local widget = wibox.widget { + { + art, + { + { + widget = wibox.widget.textbox, + }, + bg = { + type = "linear", + from = { 0, 0 }, + to = { 200, 0 }, + stops = { { 0, beautiful.mbg .. "88" }, { 1, beautiful.bg .. '33' } } + }, + shape = helpers.rrect(20), + widget = wibox.container.background, + }, + { + { + { + { + font = beautiful.sans .. " 12", + markup = helpers.colorizeText('Now Playing', beautiful.fg), + widget = wibox.widget.textbox, + }, + { + id = "songname", + font = beautiful.sans .. " SemiBold 16", + markup = helpers.colorizeText('Song Name', beautiful.fg), + widget = wibox.widget.textbox, + }, + { + id = "artist", + font = beautiful.sans .. " 14", + markup = helpers.colorizeText('Artist Name', beautiful.fg), + widget = wibox.widget.textbox, + }, + spacing = 8, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.place, + halign = "left", + valign = "top" + }, + widget = wibox.container.margin, + margins = 20, + }, + layout = wibox.layout.stack, + }, + widget = wibox.container.margin, + top = 20, +} + +playerctl:connect_signal("metadata", function(_, title, artist, album_path, album, new, player_name) + if album_path == "" then + album_path = beautiful.songdefpicture + end + if string.len(title) > 30 then + title = string.sub(title, 0, 30) .. "..." + end + if string.len(artist) > 22 then + artist = string.sub(artist, 0, 22) .. "..." + end + art.image = helpers.cropSurface(1.71, gears.surface.load_uncached(album_path)) + helpers.gc(widget, "songname"):set_markup_silently(helpers.colorizeText(title or "NO", beautiful.fg)) + helpers.gc(widget, "artist"):set_markup_silently(helpers.colorizeText(artist or "HM", beautiful.fg)) +end) +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/time.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/time.lua new file mode 100644 index 0000000..c5a8ad7 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/time.lua @@ -0,0 +1,42 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = beautiful.xresources.apply_dpi +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") + +local widget = wibox.widget { + { + { + { + { + font = beautiful.sans .. " SemiBold 42", + format = helpers.colorizeText("%I : %M", beautiful.fg), + align = "center", + valign = "center", + widget = wibox.widget.textclock + }, + { + font = beautiful.sans .. " 16", + format = helpers.colorizeText("%A, %d %B", beautiful.fg2 .. '99'), + align = "center", + valign = "center", + widget = wibox.widget.textclock + }, + spacing = 8, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.place, + halign = "center", + valign = "center" + }, + widget = wibox.container.margin, + margin = 30, + }, + shape = helpers.rrect(20), + forced_height = 200, + widget = wibox.container.background, + bg = beautiful.mbg +} + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/todo.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/todo.lua new file mode 100644 index 0000000..a3f5187 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/todo.lua @@ -0,0 +1,322 @@ +local gears = require("gears") +local json = require "mods.json" +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local helpers = require("helpers") + +local DATA = gears.filesystem.get_cache_dir() .. 'json/todos.json' + +local elems = wibox.widget { + layout = require("mods.overflow").vertical, + scrollbar_enabled = false, + forced_height = 300, +} + +local check_exits = function(path) + local file = io.open(path, "rb") + if file then file:close() end + return file ~= nil +end + +local getData = function() + if check_exits(DATA) then + local f = assert(io.open(DATA, "rb")) + local lines = f:read("*all") + f:close() + local data = json.decode(lines) + return data + else + return {} + end +end + +local writeData = function(d) + os.execute('truncate -s 0 ' .. DATA) + local f = assert(io.open(DATA, "wb")) + local write = json.encode(d) + f:write(write) + f:flush() + f:close() +end + +local grabber = {} +function grabber:init(finalWidget, fn, cl) + local exclude = { + "Shift_R", + "Shift_L", + "Tab", + "Alt_R", + "Alt_L", + "Ctrl_L", + "Ctrl_R", + "CapsLock", + "Home" + } + + local function has_value(tab, val) + for _, value in ipairs(tab) do + if value == val then + return true + end + end + + return false + end + grabber.main = awful.keygrabber({ + auto_start = true, + stop_event = "release", + keypressed_callback = function(_, _, key, _) + local addition = '' + if key == "Escape" or key == "Super_L" then + grabber:stop() + cl() + elseif key == "BackSpace" then + finalWidget:get_children_by_id('input')[1].markup = finalWidget:get_children_by_id('input')[1].markup:sub(1, -2) + elseif key == "Return" then + if string.len(finalWidget:get_children_by_id('input')[1].markup) > 0 then + fn(finalWidget:get_children_by_id('input')[1].markup) + finalWidget:get_children_by_id('input')[1].markup = '' + grabber:stop() + end + elseif has_value(exclude, key) then + addition = '' + else + addition = key + end + finalWidget:get_children_by_id('input')[1].markup = finalWidget:get_children_by_id('input')[1].markup .. addition + end, + }) +end + +function grabber:start() + grabber.main:start() +end + +function grabber:stop() + grabber.main:stop() +end + +local function getPop(tit) + local pop = wibox({ + type = "dock", + height = 90, + width = 400, + ontop = true, + visible = true, + bg = beautiful.bg + }) + awful.placement.centered(pop) + local widget = wibox.widget { + { + font = beautiful.sans .. " 12", + markup = tit, + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + { + { + { + id = "input", + font = beautiful.sans .. " 12", + markup = "", + forced_height = 18, + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 10 + }, + widget = wibox.container.background, + bg = beautiful.mbg + }, + spacing = 10, + layout = wibox.layout.fixed.vertical + } + pop:setup { + widget, + widget = wibox.container.margin, + margins = 10 + } + return widget, pop +end + +local function makeElement(i, n) + awful.screen.connect_for_each_screen(function(s) + local widget = wibox.widget { + { + { + { + id = "input", + font = beautiful.sans .. " 14", + markup = i.completed and "" .. i.name .. "" or i.name, + valign = "center", + align = "center", + widget = wibox.widget.textbox, + }, + widget = wibox.container.constraint, + width = 300, + }, + nil, + { + { + font = beautiful.icon .. " 16", + markup = helpers.colorizeText("󰸞", beautiful.green), + valign = "center", + align = "center", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + local new = { + completed = not i.completed, + name = i.name + } + local data = getData() + table.remove(data, n) + table.insert(data, n, new) + writeData(data) + elems:reset() + for k, l in ipairs(data) do + makeElement(l, k) + end + end), + }, + }, + { + font = beautiful.icon .. " 16", + markup = helpers.colorizeText("󰩹", beautiful.red), + valign = "center", + align = "center", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + local data = getData() + table.remove(data, n) + writeData(data) + elems:reset() + for k, l in ipairs(data) do + makeElement(l, k) + end + end), + }, + }, + spacing = 18, + layout = wibox.layout.fixed.horizontal + }, + layout = wibox.layout.align.horizontal + }, + widget = wibox.container.background, + forced_height = 45, + forced_width = 400, + data = i + } + widget:get_children_by_id('input')[1]:add_button(awful.button({}, 1, function() + local w, pop = getPop('Enter New Name') + grabber:init(w, function(string) + pop.visible = false + local new = { + completed = i.completed, + name = string + } + local data = getData() + table.remove(data, n) + table.insert(data, n, new) + writeData(data) + elems:reset() + for k, l in ipairs(data) do + makeElement(l, k) + end + end, function() + pop.visible = false + end) + grabber:start() + end)) + elems:add(widget) + end) +end + +local makeData = function(d) + local data = getData() + table.insert(data, d) + writeData(data) +end + +local function refresh() + elems:reset() + local data = getData() + for i, j in ipairs(data) do + makeElement(j, i) + end +end + +local empV + +local finalwidget = wibox.widget { + { + { + { + { + font = beautiful.sans .. " 14", + markup = "To-Dos", + valign = "center", + align = "center", + widget = wibox.widget.textbox, + }, + nil, + { + { + font = beautiful.icon .. " 20", + markup = helpers.colorizeText("󰐕", beautiful.blue), + valign = "center", + align = "center", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + local data = { + completed = false, + name = "New Todo! Click to change name" + } + makeData(data) + refresh() + end), + }, + }, + { + font = beautiful.icon .. " 20", + markup = helpers.colorizeText("󰅖", beautiful.red), + valign = "center", + align = "center", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + os.execute("rm " .. DATA) + refresh() + end), + }, + }, + spacing = 20, + layout = wibox.layout.fixed.horizontal + }, + layout = wibox.layout.align.horizontal + }, + { + elems, + widget = wibox.container.place, + valign = 'top' + }, + spacing = 18, + layout = wibox.layout.fixed.vertical + }, + widget = wibox.container.margin, + margins = 18 + }, + forced_width = 460, + shape = helpers.rrect(8), + widget = wibox.container.background, + bg = beautiful.mbg +} + +refresh() +return finalwidget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/weather.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/weather.lua new file mode 100644 index 0000000..7d0ea1c --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/dash/mods/weather.lua @@ -0,0 +1,59 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require "beautiful" +local gears = require("gears") +local helpers = require "helpers" + +local widget = wibox.widget { + { + { + { + { + id = "icon", + image = gears.filesystem.get_configuration_dir() .. "theme/assets/weather/icons/weather-fog.svg", + opacity = 0.9, + clip_shape = helpers.rrect(4), + forced_height = 100, + forced_width = 100, + valign = "center", + widget = wibox.widget.imagebox + }, + { + { + id = "temp", + font = beautiful.sans .. " 36", + markup = "31 C", + valign = "center", + widget = wibox.widget.textbox, + }, + { + id = "desc", + font = beautiful.sans .. " 14", + markup = "Scattered Clouds", + valign = "center", + widget = wibox.widget.textbox, + }, + spacing = 8, + layout = wibox.layout.fixed.vertical, + }, + spacing = 120, + layout = wibox.layout.fixed.horizontal, + }, + widget = wibox.container.place, + valign = "center", + }, + widget = wibox.container.margin, + margins = 25, + }, + widget = wibox.container.background, + bg = beautiful.mbg, + shape = helpers.rrect(20), + forced_height = 195, +} + +awesome.connect_signal("signal::weather", function(out) + helpers.gc(widget, "icon").image = out.image + helpers.gc(widget, "temp").markup = out.temp .. "°C" + helpers.gc(widget, "desc").markup = out.desc +end) +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/desktop/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/desktop/init.lua new file mode 100644 index 0000000..8eec10d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/desktop/init.lua @@ -0,0 +1,455 @@ +local awful = require("awful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local popup = require("ui.desktop.popup") +local json = require("mods.json") +local beautiful = require("beautiful") + + +local data = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/settings.json") +local inspect = require("mods.inspect") +local dpi = beautiful.xresources.apply_dpi +local appicons = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/settings.json").iconTheme .. "/" +local foldericons = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/settings.json").iconTheme .."/places/" + +local grid = wibox.widget { + forced_num_rows = 14, + forced_num_cols = 19, + orientation = "horizontal", + layout = wibox.layout.grid +} + +local manual = wibox.layout { + layout = wibox.layout.manual +} + +local icons = { + ["lua"] = "lua", + ["py"] = "python", + ["rs"] = "rust", + ["html"] = "html", + ["c"] = "c", + ["c++"] = "c++", + ["js"] = "javascript", + ["hs"] = "haskell", + ['go'] = "go", + ["php"] = "php", + ["rb"] = "ruby", + ["md"] = "markdown", + ["ts"] = "typescript", + ["scss"] = "sass", + ["sass"] = "sass", + ["java"] = "java", +} + +local desktopdisplay = wibox { + visible = data.showDesktopIcons, + ontop = false, + bg = beautiful.bg .. '00', + type = "desktop", + screen = s, + widget = wibox.widget { + { + grid, + margins = dpi(20), + widget = wibox.container.margin + }, + manual, + layout = wibox.layout.stack + } +} + +awful.placement.maximize(desktopdisplay) + +local function gen() + local shortcuts = {} + local folders = {} + local files = {} + local entries = {} + + table.insert(entries, + { icon = appicons .. "places/trashcan_empty.svg", label = "Trash", exec = "nemo trash:/", type = "general" }) + -- table.insert(entries, + -- { + -- icon = gears.filesystem.get_configuration_dir() .. "theme/assets/tsukkisaidmetoaddthis.png", + -- label = beautiful.user:lower(), + -- exec = "nemo /home/" .. beautiful.user:lower(), + -- type = "general" + -- }) + for entry in io.popen([[ls ~/Desktop | sed '']]):lines() do + local label = entry + local exec = nil + local icon = appicons .. "mimetypes/text-x-generic.svg" + local ext = label:match("^.+(%..+)$") + + if ext == ".desktop" then + for line in io.popen("cat ~/Desktop/'" .. entry .. "'"):lines() do + if line:match("Name=") and label == entry then + label = line:gsub("Name=", "") + end + if line:match("Exec=") and exec == nil then + local cmd = line:gsub("Exec=", "") + exec = cmd + end + if line:match("CustomIcon=") then + icon = line:gsub("CustomIcon=", "") + elseif line:match("Icon=") then + icon = appicons .. "apps/" .. line:gsub("Icon=", "") .. ".svg" + end + end + table.insert(entries, { icon = icon, label = label, exec = exec, type = "shortcut" }) + elseif os.execute("cd ~/Desktop/'" .. entry .. "'") then + icon = foldericons .. "/folder.svg" + exec = "nemo" .. " Desktop/'" .. entry .. "'" + table.insert(entries, { icon = icon, label = label, exec = exec, type = "folder" }) + elseif os.execute("wc -c < ~/Desktop/'" .. entry .. "'") then + icon = appicons .. "mimetypes/application-x-zerosize.svg" + exec = "wezterm -e nvim" .. " ~/Desktop/'" .. entry .. "'" + if string.match(entry, "%.") then + local extenstion = helpers.split(entry, ".") + extenstion = extenstion[#extenstion] + if extenstion == "jpg" or extenstion == "jpeg" or extenstion == "tiff" or extenstion == "png" or extenstion == "webp" or extenstion == "svg" then + if extenstion == "jpg" then + icon = appicons .. "mimetypes/jpg.svg" + else + icon = appicons .. "mimetypes/image-" .. extenstion .. ".svg" + end + exec = "feh '~/Desktop/" .. entry .. "'" + elseif extenstion == "mp4" or extenstion == "avif" or extenstion == "webm" or extenstion == "mkv" or extenstion == "mov" then + icon = appicons .. "mimetypes/media-video.svg" + elseif extenstion == "mp3" or extenstion == "wav" or extenstion == "flac" or extenstion == "aiff" then + icon = appicons .. "mimetypes/media-audio.svg" + elseif icons[extenstion] ~= nil then + icon = appicons .. "mimetypes/text-x-" .. icons[extenstion] .. ".svg" + end + end + table.insert(entries, { icon = icon, label = label, exec = exec, type = 'file' }) + else + exec = "xdg-open " .. os.getenv("HOME") .. "/Desktop/'" .. label .. "'" + table.insert(entries, { icon = icon, label = label, exec = exec, type = 'file' }) + end + end + return entries +end + +local function save() + layout = {} + + for i, widget in ipairs(grid.children) do + local pos = grid:get_widget_position(widget) + + layout[i] = { + row = pos.row, + col = pos.col, + widget = { + icon = widget.icon, + label = widget.label, + exec = widget.exec, + type = widget.type, + } + } + end + + local w = assert(io.open(".cache/awesome/json/desktop.json", "w")) + w:write(json.encode(layout, nil, { pretty = true, indent = " ", align_keys = false, array_newline = true })) + w:close() +end + +local function gridindexat(y, x) + local margin = dpi(30) + local cellwidth, cellheight = dpi(115), dpi(105) + + local row = math.ceil((y - margin) / cellheight) + row = math.min(row, 8) + row = math.max(row, 1) + + local col = math.ceil((x - margin) / cellwidth) + col = math.min(col, 16) + col = math.max(col, 1) + + return row, col +end + +local function createicon(icon, label, exec, ty) + local widget = wibox.widget { + { + { + { + image = icon, + halign = "center", + widget = wibox.widget.imagebox + }, + strategy = "exact", + width = dpi(50), + height = dpi(40), + widget = wibox.container.constraint + }, + { + { + { + markup = helpers.colorizeText(label, beautiful.fg), + valign = "top", + font = beautiful.sans .. " 11", + align = "center", + widget = wibox.widget.textbox + }, + margins = dpi(5), + widget = wibox.container.margin + }, + strategy = "max", + width = dpi(100), + height = dpi(50), + widget = wibox.container.constraint + }, + spacing = dpi(5), + layout = wibox.layout.fixed.vertical + }, + icon = icon, + label = label, + exec = exec, + type = ty, + forced_width = dpi(115), + forced_height = dpi(105), + margins = dpi(10), + widget = wibox.container.margin + } + + local iconmenu = awful.menu({ + items = { + { "Open", exec }, + { "Delete", function() + awful.spawn.with_shell("rm -rf " .. os.getenv("HOME") .. "/Desktop/'" .. label .. "'") + end }, + } + }) + + awesome.connect_signal("iconmenu::hide", function() + iconmenu:hide() + end) + + widget:connect_signal("button::press", function(_, _, _, button) + if not mousegrabber.isrunning() then + local heldwidget = wibox.widget { + { + { + image = icon, + opacity = 0.5, + halign = "center", + widget = wibox.widget.imagebox + }, + strategy = "exact", + width = dpi(50), + height = dpi(50), + widget = wibox.container.constraint + }, + { + { + { + text = label, + opacity = 0.5, + valign = "top", + align = "center", + widget = wibox.widget.textbox + }, + margins = dpi(5), + widget = wibox.container.margin + }, + strategy = "max", + width = dpi(100), + height = dpi(50), + widget = wibox.container.constraint + }, + forced_height = dpi(105), + forced_width = dpi(100), + spacing = dpi(5), + visible = false, + layout = wibox.layout.fixed.vertical + } + + local startpos = mouse.coords() + heldwidget.point = { x = startpos.x, y = startpos.y } + local oldpos = grid:get_widget_position(widget) + manual:add(heldwidget) + + mousegrabber.run(function(mouse) + if (math.abs(mouse.x - startpos.x) > 10 or + math.abs(mouse.y - startpos.y) > 10) and + mouse.buttons[1] then + grid:remove(widget) + heldwidget.visible = true + + manual:move_widget(heldwidget, { + x = mouse.x - dpi(50), + y = mouse.y - dpi(50) + }) + end + + if not mouse.buttons[1] then + if button == 1 then + if heldwidget.visible then + heldwidget.visible = false + + local newrow, newcol = gridindexat( + mouse.y, + mouse.x + ) + if not grid:get_widgets_at(newrow, newcol) then + grid:add_widget_at(widget, newrow, newcol) + save() + else + local d = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/desktop.json") + local elem + for _, j in ipairs(d) do + if j.row == newrow and j.col == newcol then + elem = j + break + end + end + if elem.widget.exec:find("nemo Desktop") then + if exec ~= "Trash" then + os.execute("mv ~/Desktop/'" .. label .. "' ~/Desktop/'" .. elem.widget.label .. "'/'" .. label .. "'") + end + elseif elem.widget.exec:find("nemo trash:/") then + if exec ~= "Trash" then + os.execute("trash ~/Desktop/'" .. label .. "'") + end + else + grid:add_widget_at(widget, oldpos.row, oldpos.col) + end + end + else + awful.spawn.with_shell(exec) + manual:reset() + end + mousegrabber.stop() + elseif button == 3 then + awesome.emit_signal("iconmenu::hide") + iconmenu:toggle() + mousegrabber.stop() + end + end + return mouse.buttons[1] + end, "hand2") + end + end) + + return widget +end + +local function load() + local layoutfile = gears.filesystem.get_cache_dir() .. 'json/desktop.json' + if not gears.filesystem.file_readable(layoutfile) then + local entries = gen() + for _, entry in ipairs(entries) do + grid:add(createicon(entry.icon, entry.label, entry.exec, entry.type)) + end + save() + return + end + + local awmmenu = { + { "Restart", awesome.restart } + } + + local createmenu = { + { "File", function() + local filename = "New File" + local filepath = os.getenv("HOME") .. "/Desktop/" .. filename + local i = 1 + while gears.filesystem.file_readable(filepath) do + filename = "New File " .. "(" .. i .. ")" + filepath = os.getenv("HOME") .. "/Desktop/" .. filename + i = i + 1 + end + awful.spawn.with_shell("touch '" .. filepath .. "'") + end }, + { "Folder", function() + local foldername = "New Folder" + local folderpath = os.getenv("HOME") .. "/Desktop/" .. foldername + local i = 1 + while gears.filesystem.dir_readable(folderpath) do + foldername = "New Folder " .. "(" .. i .. ")" + folderpath = os.getenv("HOME") .. "/Desktop/" .. foldername + i = i + 1 + end + gears.filesystem.make_directories(folderpath) + end } + } + + + manual:buttons { + awful.button({}, 1, function() + awesome.emit_signal("iconmenu::hide") + awesome.emit_signal("close::menu") + end), + awful.button({}, 3, function() + if mouse.current_widgets[4] == manual then + awesome.emit_signal("iconmenu::hide") + awesome.emit_signal("toggle::menu") + end + end) + } + + local r = assert(io.open(".cache/awesome/json/desktop.json", "rb")) + local t = r:read("*all") + r:close() + local layout = json.decode(t) + + for _, entry in ipairs(layout) do + grid:add_widget_at(createicon(entry.widget.icon, entry.widget.label, entry.widget.exec, entry.type), entry.row, + entry.col) + end +end + +load() + +awesome.connect_signal("signal::desktop", function(type) + local entries = gen() + local check = false + + if type == add then + for _, entry in ipairs(entries) do + for _, widget in ipairs(grid.children) do + if entry.label == widget.label then + check = true + end + end + if check == false then + grid:add(createicon(entry.icon, entry.label, entry.exec, entry.type)) + end + check = false + end + end + + if type == remove then + for _, widget in ipairs(grid.children) do + for _, entry in ipairs(entries) do + if entry.label == widget.label then + check = true + end + end + if check == false then + grid:remove(widget) + end + check = false + end + end + + save() +end) + +local subscribe = [[ + bash -c " + while (inotifywait -m -e close_write -e delete -e create -e moved_from $HOME/Desktop/ -q) do echo; done +"]] + +awful.spawn.easy_async_with_shell( + "ps x | grep \"inotifywait -m -e close_write -e delete -e create -e moved_from $HOME/Desktop/ -q\" | awk '{print $1}' | xargs kill", + function() + awful.spawn.with_line_callback(subscribe, { + stdout = function(l) + awesome.emit_signal("signal::desktop") + end + }) + end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/desktop/popup.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/desktop/popup.lua new file mode 100644 index 0000000..fd7e2ee --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/desktop/popup.lua @@ -0,0 +1,222 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local inspect = require('mods.inspect') +local helpers = require("helpers") + +local popup = {} + +popup.widget = wibox({ + visible = false, + ontop = true, + height = 180, + width = 400, + shape = helpers.rrect(5), + widget = wibox.container.background +}) + +popup.label = "Rename A File" + + +popup.prompt = wibox.widget { + { + { + { + { + markup = "", + forced_height = 24, + id = "txt", + font = "Rubik 14", + widget = wibox.widget.textbox, + }, + { + markup = "Type Here...", + forced_height = 15, + id = "placeholder", + font = "Rubik 14", + widget = wibox.widget.textbox, + }, + layout = wibox.layout.stack + }, + widget = wibox.container.margin, + margins = 20, + }, + widget = wibox.container.background, + bg = beautiful.mbg + }, + forced_width = 470, + widget = wibox.container.margin, +} + +popup.name = wibox.widget { + markup = popup.label, + forced_height = 15, + id = "okay", + font = "Rubik 14", + widget = wibox.widget.textbox, +} + +popup.widget:setup({ + { + { + { + { + { + { + { + { + widget = wibox.container.background, + forced_width = 17, + forced_height = 17, + bg = beautiful.red, + shape = helpers.rrect(50), + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('quit::popupgrabber') + awesome.emit_signal('quit::popup') + end) + }, + }, + layout = wibox.layout.fixed.horizontal + }, + widget = wibox.container.place, + valign = "center" + }, + nil, + nil, + layout = wibox.layout.align.horizontal + }, + widget = wibox.container.margin, + margins = 15 + }, + widget = wibox.container.background, + bg = beautiful.mbg + }, + { + { + popup.name, + popup.prompt, + spacing = 20, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.margin, + margins = 20 + }, + nil, + layout = wibox.layout.align.vertical + }, + widget = wibox.container.place, + valign = "center" + }, + widget = wibox.container.background, + bg = beautiful.bg +}) + +local exclude = { + "Shift_R", + "Shift_L", + "Super_R", + "Super_L", + "Tab", + "Alt_R", + "Alt_L", + "Ctrl_L", + "Ctrl_R", + "CapsLock", + "Home", + "Down", + "Up", + "Left", + "Right" +} +local function has_value(tab, val) + for _, value in ipairs(tab) do + if value == val then + return true + end + end + + return false +end + +popup.grabber = awful.keygrabber({ + auto_start = true, + stop_event = "release", + keypressed_callback = function(self, mod, key, command) + local addition = '' + if key == "Escape" then + awesome.emit_signal("quit::popup") + awesome.emit_signal("quit::popupgrabber") + elseif key == "BackSpace" then + popup.prompt:get_children_by_id('txt')[1].markup = popup.prompt:get_children_by_id('txt')[1].markup:sub(1, -2) + elseif key == "Return" then + popup.func(popup.prompt:get_children_by_id('txt')[1].markup) + awesome.emit_signal("quit::popup") + awesome.emit_signal("quit::popupgrabber") + awesome.emit_signal("signal::desktop") + elseif has_value(exclude, key) then + addition = '' + else + addition = key + end + popup.prompt:get_children_by_id('txt')[1].markup = popup.prompt:get_children_by_id('txt')[1].markup .. addition + if string.len(popup.prompt:get_children_by_id('txt')[1].markup) > 0 then + popup.prompt:get_children_by_id('placeholder')[1].markup = '' + else + popup.prompt:get_children_by_id('placeholder')[1].markup = 'Type Here...' + end + end, +}) + +popup.start = function(fn) + if fn == "create" then + popup.label = "Create A File" + popup.name.markup = popup.label + popup.func = function(name) + awful.spawn.with_shell("touch ~/Desktop/'" .. name .. "'") + end + elseif fn == "folder" then + popup.label = "Create A Folder" + popup.name.markup = popup.label + popup.func = function(name) + awful.spawn.with_shell("mkdir ~/Desktop/'" .. name .. "'") + end + else + awesome.emit_signal("close::filemenu") + popup.label = "Rename File" + popup.name.markup = popup.label + popup.func = function(name) + local n = helpers.split(fn, "`")[2] + awful.spawn.with_shell("mv ~/Desktop/'" .. n .. "' ~/Desktop/'" .. name .. "'") + end + end +end + +awesome.connect_signal("toggle::popupgrabber", function() + popup.grabber:start() +end) + +awesome.connect_signal("quit::popupgrabber", function() + popup.grabber:stop() + popup.prompt:get_children_by_id('txt')[1].markup = "" +end) + +awesome.connect_signal("quit::popup", function() + popup.widget.visible = false +end) + +awesome.connect_signal("toggle::popup", function(fn) + popup.start(fn) + if popup.widget.visible then + awesome.emit_signal("quit::popupgrabber") + else + awesome.emit_signal("toggle::popupgrabber") + end + popup.widget.visible = not popup.widget.visible + awful.placement.centered( + popup.widget, + { honor_workarea = true } + ) +end) + +return popup diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/init.lua new file mode 100644 index 0000000..974a8ba --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/init.lua @@ -0,0 +1,178 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = beautiful.xresources.apply_dpi +local gears = require("gears") + +local music = require("ui.exit.mods.music") +local bat = require("ui.exit.mods.bat") +local weather = require("ui.exit.mods.weather") +local top = require("ui.exit.mods.topbar") + +awful.screen.connect_for_each_screen(function(s) + local exit = wibox({ + screen = s, + width = 1920, + height = 1080, + bg = beautiful.bg .. "00", + ontop = true, + visible = false, + }) + + + local back = wibox.widget { + id = "bg", + image = beautiful.wallpaper, + widget = wibox.widget.imagebox, + forced_height = 1080, + horizontal_fit_policy = "fit", + vertical_fit_policy = "fit", + forced_width = 1920, + } + + local big = wibox.widget { + { + { + id = "text", + markup = helpers.colorizeText("HELLO", beautiful.fg .. '33'), + font = beautiful.sans .. " Bold 250", + align = "center", + widget = wibox.widget.textbox, + }, + widget = wibox.container.background, + halign = "center", + valign = "center" + }, + widget = wibox.container.margin, + top = 0, + } + + local overlay = wibox.widget { + widget = wibox.container.background, + forced_height = 1080, + forced_width = 1920, + bg = beautiful.bg .. "d1" + } + local makeImage = function() + local cmd = 'convert ' .. + beautiful.wallpaper .. ' -filter Gaussian -blur 0x6 ~/.cache/awesome/exit.jpg' + awful.spawn.easy_async_with_shell(cmd, function() + local blurwall = gears.filesystem.get_cache_dir() .. "exit.jpg" + back.image = blurwall + end) + end + + makeImage() + + local createButton = function(icon, name, cmd, color) + local widget = wibox.widget { + { + { + { + id = "icon", + markup = helpers.colorizeText(icon, color), + font = beautiful.icon .. " 40", + align = "center", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 40, + }, + shape = helpers.rrect(15), + widget = wibox.container.background, + bg = beautiful.bg, + id = "bg", + shape_border_color = color, + shape_border_width = 2, + }, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal("toggle::exit") + awful.spawn.with_shell(cmd) + end) + }, + spacing = 15, + layout = wibox.layout.fixed.vertical, + } + widget:connect_signal("mouse::enter", function() + helpers.gc(widget, "bg").bg = beautiful.mbg + end) + widget:connect_signal("mouse::leave", function() + helpers.gc(widget, "bg").bg = beautiful.bg + end) + return widget + end + + + local time = wibox.widget { + { + { + markup = helpers.colorizeText("󰀠", beautiful.blue), + font = beautiful.icon .. " 28", + align = "center", + valign = "center", + widget = wibox.widget.textbox, + }, + { + font = beautiful.sans .. " 16", + format = "%H:%M", + align = "center", + valign = "center", + widget = wibox.widget.textclock + }, + spacing = 10, + layout = wibox.layout.fixed.horizontal + }, + widget = wibox.container.place, + valign = "center" + } + + local down = wibox.widget { + { + { + music, + time, + bat, + weather, + layout = wibox.layout.fixed.horizontal, + spacing = 20, + }, + widget = wibox.container.place, + valign = "bottom", + halign = "center" + }, + widget = wibox.container.margin, + bottom = 40, + } + + local buttons = wibox.widget { + + { + createButton("󰐥", "Power", "poweroff", beautiful.red), + createButton("󰦛", "Reboot", "reboot", beautiful.green), + createButton("󰌾", "Lock", "lock", beautiful.blue), + createButton("󰖔", "Sleep", "systemctl suspend", beautiful.yellow), + createButton("󰈆", "Log Out", "loginctl kill-user $USER", beautiful.magenta), + layout = wibox.layout.fixed.horizontal, + spacing = 20, + }, + widget = wibox.container.place, + halign = "center", + valign = "center" + } + + exit:setup { + back, + + overlay, + top, + buttons, + down, + widget = wibox.layout.stack + } + awful.placement.centered(exit) + awesome.connect_signal("toggle::exit", function() + exit.visible = not exit.visible + end) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/bat.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/bat.lua new file mode 100644 index 0000000..a0fcdbc --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/bat.lua @@ -0,0 +1,44 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local beautiful = require("beautiful") +local widget = wibox.widget { + { + max_value = 100, + value = 69, + id = "prog", + forced_height = 35, + forced_width = 80, + paddings = 3, + border_color = beautiful.fg .. "99", + background_color = beautiful.mbg, + bar_shape = helpers.rrect(40), + color = beautiful.blue, + border_width = 0, + shape = helpers.rrect(30), + widget = wibox.widget.progressbar + }, + layout = wibox.layout.fixed.horizontal, + spacing = 10, + { + font = beautiful.sans .. " 16", + markup = helpers.colorizeText("25%", beautiful.fg), + valign = "center", + id = "batvalue", + widget = wibox.widget.textbox, + }, +} + +awesome.connect_signal("signal::battery", function(value) + local b = widget:get_children_by_id("prog")[1] + local v = widget:get_children_by_id("batvalue")[1] + v.markup = helpers.colorizeText(value .. "%", beautiful.fg) + b.value = value + if value > 80 then + b.color = beautiful.green + elseif value > 20 then + b.color = beautiful.blue + else + b.color = beautiful.red + end +end) +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/music.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/music.lua new file mode 100644 index 0000000..0f80c6b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/music.lua @@ -0,0 +1,47 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local pctl = require("mods.playerctl") +local helpers = require("helpers") +local playerctl = pctl.lib() + +local art = wibox.widget { + image = helpers.cropSurface(1, gears.surface.load_uncached(beautiful.songdefpicture)), + forced_height = dpi(40), + clip_shape = helpers.rrect(100), + forced_width = dpi(40), + widget = wibox.widget.imagebox +} + +local songname = wibox.widget { + markup = helpers.colorizeText('Nothing Playing', beautiful.fg), + align = 'left', + valign = 'center', + font = beautiful.sans .. " 16", + widget = wibox.widget.textbox +} + +local widget = wibox.widget { + art, + songname, + layout = wibox.layout.fixed.horizontal, + spacing = 10, +} + +playerctl:connect_signal("metadata", function(_, title, artist, album_path, album, new, player_name) + if album_path == "" then + album_path = beautiful.songdefpicture + end + if string.len(title) > 30 then + title = string.sub(title, 0, 30) .. "..." + end + if string.len(artist) > 22 then + artist = string.sub(artist, 0, 22) .. "..." + end + songname:set_markup_silently(helpers.colorizeText(title or "NO", beautiful.fg)) + art:set_image(helpers.cropSurface(1, gears.surface.load_uncached(album_path))) +end) + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/topbar.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/topbar.lua new file mode 100644 index 0000000..a2aa12f --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/topbar.lua @@ -0,0 +1,95 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local beautiful = require("beautiful") +local awful = require("awful") + +local widget = wibox.widget { + { + { + { + widget = wibox.widget.imagebox, + image = beautiful.pfp, + forced_height = 50, + forced_width = 50, + align = "center", + valign = "center", + clip_shape = helpers.rrect(40), + resize = true, + }, + nil, + { + { + { + { + font = beautiful.sans .. " 14", + format = "%a, %d %B", + align = "center", + valign = "center", + widget = wibox.widget.textclock + }, + widget = wibox.container.margin, + left = 25, + right = 25, + }, + shape = helpers.rrect(50), + bg = beautiful.mbg, + widget = wibox.container.background, + }, + { + { + { + font = beautiful.sans .. " 14", + id = "uptime", + markup = helpers.colorizeText("", beautiful.fg), + valign = "center", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + left = 25, + right = 25, + }, + shape = helpers.rrect(50), + bg = beautiful.mbg, + widget = wibox.container.background, + }, + { + { + { + font = beautiful.icon .. " 16", + markup = helpers.colorizeText("󰅖", beautiful.red), + valign = "center", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 20, + }, + buttons = { + awful.button({}, 1, function() + awesome.emit_signal("toggle::exit") + end) + }, + shape = helpers.rrect(50), + bg = beautiful.mbg, + widget = wibox.container.background, + }, + spacing = 20, + layout = wibox.layout.fixed.horizontal, + }, + layout = wibox.layout.align.horizontal, + }, + widget = wibox.container.place, + content_fill_horizontal = true, + halign = "center", + valign = "top", + }, + widget = wibox.container.margin, + top = 40, + left = 40, + right = 40, +} + +awesome.connect_signal("signal::uptime", function(v) + helpers.gc(widget, "uptime").markup = v +end) + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/weather.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/weather.lua new file mode 100644 index 0000000..9c29dde --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/exit/mods/weather.lua @@ -0,0 +1,35 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local awful = require("awful") +local beautiful = require("beautiful") +local gears = require("gears") + +local widget = wibox.widget { + { + id = "image", + image = gears.filesystem.get_configuration_dir() .. "theme/assets/weather/icons/weather-fog.svg", + opacity = 0.9, + clip_shape = helpers.rrect(4), + forced_height = 30, + forced_width = 30, + valign = "center", + widget = wibox.widget.imagebox + }, + { + id = "desc", + font = beautiful.sans .. " 16", + markup = "Scattered Clouds", + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + layout = wibox.layout.fixed.horizontal, + spacing = 15, +} + +awesome.connect_signal("signal::weather", function(out) + helpers.gc(widget, "desc").markup = out.desc + helpers.gc(widget, "image").image = out.image +end) + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/init.lua new file mode 100644 index 0000000..940eeac --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/init.lua @@ -0,0 +1,11 @@ +require "ui.desktop" +require "ui.bar" +require "ui.menu" +require "ui.control" +require "ui.moment" +require "ui.dash" +require "ui.notify" +require "ui.setup" +require "ui.lock" +require "ui.exit" +require "ui.popups" diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/lock/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/lock/init.lua new file mode 100644 index 0000000..b2e3d2e --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/lock/init.lua @@ -0,0 +1,249 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = beautiful.xresources.apply_dpi +local pam = require("liblua_pam") +local gears = require("gears") +local auth = function(password) + return pam.auth_current_user(password) +end + +local header = wibox.widget { + { + { + image = beautiful.pfp, + clip_shape = helpers.rrect(100), + forced_height = 180, + opacity = 1, + forced_width = 180, + halign = 'center', + widget = wibox.widget.imagebox + }, + id = "arc", + widget = wibox.container.arcchart, + max_value = 100, + min_value = 0, + value = 0, + rounded_edge = false, + thickness = dpi(8), + start_angle = 4.71238898, + bg = beautiful.fg, + colors = { beautiful.fg }, + forced_width = dpi(180), + forced_height = dpi(180) + }, + widget = wibox.container.place, + halign = 'center', +} +local label = wibox.widget { + markup = "Type The Password", + valign = "center", + halign = "center", + id = "name", + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox, +} + + + +local check_caps = function() + awful.spawn.easy_async_with_shell( + 'xset q | grep Caps | cut -d: -f3 | cut -d0 -f1 | tr -d \' \'', + function(stdout) + if stdout:match('off') then + label.markup = "Type The Password Here" + else + label.markup = "HINT: Caps Lock Is ON" + end + end + ) +end + + +local promptbox = wibox { + width = dpi(900), + height = dpi(800), + bg = beautiful.mbg .. "00", + ontop = true, + shape = helpers.rrect(0), + visible = false +} + +local background = wibox({ + width = dpi(1920), + height = dpi(1080), + visible = false, + ontop = true, + type = "splash" +}) + + + +awful.placement.centered(background) + +local visible = function(v) + background.visible = v + promptbox.visible = v +end + +local reset = function(f) + header:get_children_by_id('arc')[1].value = not f and 100 or 0 + header:get_children_by_id('arc')[1].colors = { not f and beautiful.red or beautiful.fg } +end + +local getRandom = function() + local r = math.random(0, 628) + r = r / 100 + return r +end + +local input = "" +local function grab() + local grabber = awful.keygrabber { + auto_start = true, + stop_event = 'release', + mask_event_callback = true, + keybindings = { + awful.key { + modifiers = { 'Mod1', 'Mod4', 'Shift', 'Control' }, + key = 'Return', + on_press = function(_) + input = input + end + } + }, + keypressed_callback = function(_, _, key, _) + if key == 'Escape' then + input = "" + return + end + -- Accept only the single charactered key + -- Ignore 'Shift', 'Control', 'Return', 'F1', 'F2', etc., etc. + if #key == 1 then + header:get_children_by_id('arc')[1].colors = { beautiful.blue } + header:get_children_by_id('arc')[1].value = 20 + header:get_children_by_id('arc')[1].start_angle = getRandom() + if input == nil then + input = key + return + end + input = input .. key + elseif key == "BackSpace" then + header:get_children_by_id('arc')[1].colors = { beautiful.blue } + header:get_children_by_id('arc')[1].value = 20 + header:get_children_by_id('arc')[1].start_angle = getRandom() + input = input:sub(1, -2) + if #input == 0 then + header:get_children_by_id('arc')[1].colors = { beautiful.magenta } + header:get_children_by_id('arc')[1].value = 100 + end + end + end, + keyreleased_callback = function(self, _, key, _) + -- Validation + if key == 'Return' then + if auth(input) then + self:stop() + reset(true) + visible(false) + input = "" + else + header:get_children_by_id('arc')[1].colors = { beautiful.red } + reset(false) + grab() + input = "" + end + elseif key == 'Caps_Lock' then + check_caps() + end + end + } + grabber:start() +end + + +awesome.connect_signal("toggle::lock", function() + visible(true) + grab() +end) + +local back = wibox.widget { + id = "bg", + image = beautiful.wallpaper, + widget = wibox.widget.imagebox, + forced_height = 1080, + horizontal_fit_policy = "fit", + vertical_fit_policy = "fit", + forced_width = 1920, +} + +local makeImage = function() + local cmd = 'convert ' .. + beautiful.wallpaper .. ' -filter Gaussian -blur 0x6 ~/.cache/awesome/lock.jpg' + awful.spawn.easy_async_with_shell(cmd, function() + local blurwall = gears.filesystem.get_cache_dir() .. "lock.jpg" + back.image = blurwall + end) +end + +makeImage() + +local overlay = wibox.widget { + widget = wibox.container.background, + forced_height = 1080, + forced_width = 1920, + bg = beautiful.bg .. "c1" +} +background:setup { + back, + overlay, + layout = wibox.layout.stack +} + + +promptbox:setup { + { + { + { + { + { + font = beautiful.sans .. " Medium 110", + format = "%H:%M", + halign = "center", + valign = "center", + widget = wibox.widget.textclock + }, + { + font = beautiful.sans .. " Light 28", + format = "%a, %d %B", + halign = "center", + valign = "center", + widget = wibox.widget.textclock + }, + { + label, + widget = wibox.container.margin, + top = 50 + }, + spacing = 10, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.place, + valign = "center", + }, + nil, + header, + layout = wibox.layout.align.vertical + }, + margins = dpi(30), + widget = wibox.container.margin + }, + widget = wibox.container.background, + shape = helpers.rrect(20) +} +awful.placement.centered( + promptbox +) + +check_caps() diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/menu/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/menu/init.lua new file mode 100644 index 0000000..56c6c64 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/menu/init.lua @@ -0,0 +1,379 @@ +local wibox = require("wibox") +local awful = require("awful") +local gears = require("gears") +local Gio = require("lgi").Gio +local iconTheme = require("lgi").require("Gtk", "3.0").IconTheme.get_default() +local beautiful = require("beautiful") +local helpers = require("helpers") +local animation = require("mods.animation") +local dpi = beautiful.xresources.apply_dpi + + +awful.screen.connect_for_each_screen(function(s) + local launcherdisplay = wibox { + width = dpi(565), + shape = helpers.rrect(12), + height = dpi(620), + bg = beautiful.bg, + ontop = true, + visible = false + } + local prompt = wibox.widget { + { + image = helpers.cropSurface(3.42, gears.surface.load_uncached(beautiful.wallpaper)), + opacity = 0.9, + forced_height = dpi(140), + clip_shape = helpers.rrect(10), + forced_width = dpi(480), + widget = wibox.widget.imagebox + }, + { + { + { + { + { + markup = "", + forced_height = 15, + id = "txt", + font = "Rubik 14", + widget = wibox.widget.textbox, + }, + { + markup = "Search...", + forced_height = 15, + id = "placeholder", + font = "Rubik 14", + widget = wibox.widget.textbox, + }, + layout = wibox.layout.stack + }, + widget = wibox.container.margin, + margins = 20, + }, + forced_width = 300, + shape = helpers.rrect(8), + widget = wibox.container.background, + bg = beautiful.mbg + }, + widget = wibox.container.place, + halign = "center", + valgn = "center", + }, + layout = wibox.layout.stack + } + + local entries = wibox.widget { + homogeneous = false, + expand = false, + forced_num_cols = 1, + spacing = 4, + layout = wibox.layout.grid + } + local createPowerButton = function(icon, color, command) + return wibox.widget { + { + { + { + markup = helpers.colorizeText(icon, color), + align = "center", + font = beautiful.icon .. " 20", + widget = wibox.widget.textbox, + }, + margins = 14, + widget = wibox.container.margin + }, + widget = wibox.container.background, + bg = color .. '11', + shape = helpers.rrect(4) + }, + widget = wibox.container.place, + halign = "center", + buttons = { + awful.button({}, 1, function() + awesome.emit_signal("quit::search") + awesome.emit_signal("quit::launcher") + awful.spawn.with_shell(command) + end) + }, + } + end + launcherdisplay:setup { + { + { + { + { + { + widget = wibox.widget.imagebox, + image = beautiful.nixos, + forced_height = 40, + forced_width = 40, + resize = true, + }, + widget = wibox.container.place, + halign = "center" + }, + widget = wibox.container.margin, + top = 15 + }, + nil, + { + { + createPowerButton("󰐥", beautiful.red, "poweroff"), + createPowerButton("󰌾", beautiful.blue, "lock"), + createPowerButton("󰦛", beautiful.green, "reboot"), + spacing = 10, + layout = wibox.layout.fixed.vertical + }, + widget = wibox.container.margin, + margins = 10, + + }, + layout = wibox.layout.align.vertical + }, + widget = wibox.container.background, + bg = beautiful.mbg + }, + { + { + prompt, + spacing = 10, + entries, + layout = wibox.layout.fixed.vertical + }, + left = 10, + right = 10, + bottom = 10, + top = 10, + widget = wibox.container.margin + }, + nil, + spacing = 0, + layout = wibox.layout.align.horizontal + } + -- Functions + + local function next(entries) + if index_entry ~= #filtered then + index_entry = index_entry + 1 + if index_entry > index_start + 5 then + index_start = index_start + 1 + end + end + end + + local function back(entries) + if index_entry ~= 1 then + index_entry = index_entry - 1 + if index_entry < index_start then + index_start = index_start - 1 + end + end + end + + local function gen() + local entries = {} + for _, entry in ipairs(Gio.AppInfo.get_all()) do + if entry:should_show() then + local name = entry:get_name():gsub("&", "&"):gsub("<", "<"):gsub("'", "'") + local icon = entry:get_icon() + local path + if icon then + path = icon:to_string() + if not path:find("/") then + local icon_info = iconTheme:lookup_icon(path, dpi(48), 0) + local p = icon_info and icon_info:get_filename() + path = p + end + end + table.insert( + entries, + { name = name, appinfo = entry, icon = path or '' } + ) + end + end + return entries + end + + local function filter(cmd) + filtered = {} + regfiltered = {} + + -- Filter entries + + for _, entry in ipairs(unfiltered) do + if entry.name:lower():sub(1, cmd:len()) == cmd:lower() then + table.insert(filtered, entry) + elseif entry.name:lower():match(cmd:lower()) then + table.insert(regfiltered, entry) + end + end + + -- Sort entries + + table.sort(filtered, function(a, b) return a.name:lower() < b.name:lower() end) + table.sort(regfiltered, function(a, b) return a.name:lower() < b.name:lower() end) + + -- Merge entries + + for i = 1, #regfiltered do + filtered[#filtered + 1] = regfiltered[i] + end + + -- Clear entries + + entries:reset() + + -- Add filtered entries + + for i, entry in ipairs(filtered) do + local widget = wibox.widget { + { + { + { + image = entry.icon, + clip_shape = helpers.rrect(10), + forced_height = dpi(32), + forced_width = dpi(32), + valign = 'center', + widget = wibox.widget.imagebox + }, + { + markup = entry.name, + id = "name", + font = beautiful.sans .. " 12", + widget = wibox.widget.textbox + }, + spacing = 20, + layout = wibox.layout.fixed.horizontal, + }, + margins = dpi(15), + widget = wibox.container.margin + }, + forced_width = 470, + forced_height = 72, + widget = wibox.container.background + } + + if index_start <= i and i <= index_start + 5 then + entries:add(widget) + end + + if i == index_entry then + widget.bg = beautiful.blue .. "09" + widget:get_children_by_id("name")[1].markup = helpers.colorizeText(entry.name, beautiful.blue) + end + end + + -- Fix position + + if index_entry > #filtered then + index_entry, index_start = 1, 1 + elseif index_entry < 1 then + index_entry = 1 + end + + collectgarbage("collect") + end + + local exclude = { + "Shift_R", + "Shift_L", + "Super_R", + "Super_L", + "Tab", + "Alt_R", + "Alt_L", + "Ctrl_L", + "Ctrl_R", + "CapsLock", + "Home", + "Down", + "Up", + "Left", + "Right" + } + local function has_value(tab, val) + for _, value in ipairs(tab) do + if value == val then + return true + end + end + + return false + end + local prompt_grabber = awful.keygrabber({ + auto_start = true, + stop_event = "release", + keypressed_callback = function(self, mod, key, command) + local addition = '' + if key == "Escape" then + awesome.emit_signal("quit::search") + awesome.emit_signal("quit::launcher") + elseif key == "BackSpace" then + prompt:get_children_by_id('txt')[1].markup = prompt:get_children_by_id('txt')[1].markup:sub(1, -2) + filter(prompt:get_children_by_id('txt')[1].markup) + elseif key == "Return" then + local entry = filtered[index_entry] + if entry then + entry.appinfo:launch() + else + awful.spawn.with_shell(prompt:get_children_by_id('txt')[1].markup) + end + awesome.emit_signal("quit::search") + awesome.emit_signal("quit::launcher") + elseif key == "Up" then + back(entries) + elseif key == "Down" then + next(entries) + elseif has_value(exclude, key) then + addition = '' + else + addition = key + end + prompt:get_children_by_id('txt')[1].markup = prompt:get_children_by_id('txt')[1].markup .. addition + filter(prompt:get_children_by_id('txt')[1].markup) + if string.len(prompt:get_children_by_id('txt')[1].markup) > 0 then + prompt:get_children_by_id('placeholder')[1].markup = '' + else + prompt:get_children_by_id('placeholder')[1].markup = 'Search...' + end + end, + }) + awesome.connect_signal("toggle::search", function() + prompt_grabber:start() + end) + + awesome.connect_signal("quit::search", function() + prompt_grabber:stop() + prompt:get_children_by_id('txt')[1].markup = "" + end) + local function open() + -- Reset index and page + + index_start, index_entry = 1, 1 + + -- Get entries + + unfiltered = gen() + filter("") + + -- Prompt + awesome.emit_signal("toggle::search") + end + + + awesome.connect_signal("quit::launcher", function() + launcherdisplay.visible = false + end) + awesome.connect_signal("toggle::launcher", function() + open() + if launcherdisplay.visible then + awesome.emit_signal("quit::search") + end + launcherdisplay.visible = not launcherdisplay.visible + awful.placement.bottom_left( + launcherdisplay, + { honor_workarea = true, margins = { bottom = 20, left = 20 } } + ) + end) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/init.lua new file mode 100644 index 0000000..17f612d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/init.lua @@ -0,0 +1,66 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = beautiful.xresources.apply_dpi +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") + +local calendar = require("ui.moment.mods.calendar") +local weather = require("ui.moment.mods.weather") +local clock = require("ui.moment.mods.clock") + +awful.screen.connect_for_each_screen(function(s) + local moment = wibox({ + shape = helpers.rrect(12), + screen = s, + width = 500, + height = 1080 - 40 - 60, + bg = beautiful.bg, + ontop = true, + visible = false, + }) + + moment:setup { + { + { + { + { + { + markup = helpers.colorizeText("Time And Weather", beautiful.fg), + halign = 'center', + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + }, + nil, + nil, + widget = wibox.layout.align.horizontal, + }, + widget = wibox.container.margin, + margins = 20, + }, + widget = wibox.container.background, + bg = beautiful.mbg + }, + { + { + clock, + calendar(), + weather, + layout = wibox.layout.fixed.vertical, + spacing = 20, + }, + widget = wibox.container.margin, + margins = 20, + }, + nil, + layout = wibox.layout.align.vertical, + spacing = 20, + }, + widget = wibox.container.margin, + margins = 0, + } + awful.placement.bottom_right(moment, { honor_workarea = true, margins = 20 }) + awesome.connect_signal("toggle::moment", function() + moment.visible = not moment.visible + end) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/calendar.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/calendar.lua new file mode 100644 index 0000000..4362673 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/calendar.lua @@ -0,0 +1,177 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require "beautiful" +local gears = require("gears") +local helpers = require "helpers" +local dpi = beautiful.xresources.apply_dpi + +local datewidget = function(date, weekend, notIn) + weekend = weekend or false + if notIn then + return wibox.widget { + markup = helpers.colorizeText(date, beautiful.fg3), + halign = 'center', + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + } + else + return wibox.widget { + markup = weekend and helpers.colorizeText(date, beautiful.fg) or date, + halign = 'center', + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + } + end +end + +local daywidget = function(day, weekend, notIn) + weekend = weekend or false + return wibox.widget { + markup = weekend and helpers.colorizeText(day, beautiful.red) or day, + halign = 'center', + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + } +end +local currwidget = function(day) + return wibox.widget { + markup = helpers.colorizeText(day, beautiful.blue), + halign = 'center', + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + } +end + +local title = wibox.widget { + font = beautiful.sans .. " Bold 14", + widget = wibox.widget.textbox, + halign = 'center' +} + +local theGrid = wibox.widget { + forced_num_rows = 7, + forced_num_cols = 7, + vertical_spacing = dpi(10), + horizontal_spacing = dpi(10), + min_cols_size = dpi(30), + min_rows_size = dpi(30), + homogenous = true, + layout = wibox.layout.grid, +} + +local curr + +local updateCalendar = function(date) + title.text = os.date("%B %Y", os.time(date)) + theGrid:reset() + for _, w in ipairs { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } do + if w == "Sun" or w == "Sat" then + theGrid:add(daywidget(w, true, false)) + else + theGrid:add(daywidget(w, false, false)) + end + end + local firstDate = os.date("*t", os.time({ day = 1, month = date.month, year = date.year })) + local lastDate = os.date("*t", os.time({ day = 0, month = date.month + 1, year = date.year })) + local days_to_add_at_month_start = firstDate.wday - 1 + local days_to_add_at_month_end = 42 - lastDate.day - days_to_add_at_month_start + + local previous_month_last_day = os.date("*t", os.time({ year = date.year, month = date.month, day = 0 })).day + local row = 2 + local col = firstDate.wday + + for day = previous_month_last_day - days_to_add_at_month_start, previous_month_last_day - 1, 1 do + theGrid:add(datewidget(day, false, true)) + end + + for day = 1, lastDate.day do + if day == date.day then + theGrid:add_widget_at(currwidget(day), row, col) + elseif col == 1 or col == 7 then + theGrid:add_widget_at(datewidget(day, true, false), row, col) + else + theGrid:add_widget_at(datewidget(day, false, false), row, col) + end + + if col == 7 then + col = 1 + row = row + 1 + else + col = col + 1 + end + end + + for day = 1, days_to_add_at_month_end do + theGrid:add(datewidget(day, false, true)) + end +end + +return function() + curr = os.date("*t") + updateCalendar(curr) + gears.timer { + timeout = 60, + call_now = true, + autostart = true, + callback = function() + curr = os.date("*t") + updateCalendar(curr) + end + } + return wibox.widget { + { + { + { + { + { + text = "󰁍", + font = beautiful.icofont, + widget = wibox.widget.textbox, + buttons = awful.button({}, 1, function() + curr = os.date("*t", os.time({ + day = curr.day, + month = curr.month - 1, + year = curr.year + })) + updateCalendar(curr) + end) + }, + widget = wibox.container.margin, + left = 38, + }, + title, + { + { + text = "󰁔", + font = beautiful.icofont, + widget = wibox.widget.textbox, + buttons = awful.button({}, 1, function() + curr = os.date("*t", os.time({ + day = curr.day, + month = curr.month + 1, + year = curr.year + })) + updateCalendar(curr) + end) + }, + widget = wibox.container.margin, + right = 38, + }, + layout = wibox.layout.align.horizontal + }, + { + theGrid, + widget = wibox.container.place, + halign = 'center', + }, + spacing = 17, + layout = wibox.layout.fixed.vertical + }, + widget = wibox.container.margin, + margins = 50 + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = beautiful.mbg + } +end diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/clock.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/clock.lua new file mode 100644 index 0000000..17c96ee --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/clock.lua @@ -0,0 +1,90 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") + +local widget = wibox.widget { + { + { + { + { + id = "hour", + widget = wibox.container.arcchart, + max_value = 24, + min_value = 0, + padding = 0, + value = 45, + rounded_edge = false, + thickness = 15, + start_angle = math.random(250, 870) * math.pi / 180, + colors = { beautiful.scheme == "oxo" and beautiful.red or beautiful.magenta }, + bg = beautiful.mbg .. '11', + forced_width = 85, + forced_height = 85 + }, + id = "minutes", + widget = wibox.container.arcchart, + max_value = 60, + min_value = 0, + padding = 0, + value = 12, + rounded_edge = false, + thickness = 15, + start_angle = math.random(250, 870) * math.pi / 180, + colors = { beautiful.blue }, + bg = beautiful.mbg .. '11', + forced_width = 100, + forced_height = 100 + }, + nil, + { + { + { + font = beautiful.sans .. " 36", + format = "%I : %M", + align = "center", + valign = "center", + widget = wibox.widget.textclock + }, + { + id = "uptime", + align = 'center', + font = beautiful.sans .. " 12", + text = '', + widget = wibox.widget.textbox, + }, + spacing = 10, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.place, + valign = "center" + }, + layout = wibox.layout.align.horizontal, + }, + widget = wibox.container.margin, + margins = 20, + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = beautiful.mbg, +} + +local updateTime = function() + local time = os.date("*t") + helpers.gc(widget, "hour").value = time.hour + helpers.gc(widget, "minutes").value = time.min +end +awesome.connect_signal("signal::uptime", function(v) + helpers.gc(widget, "uptime").markup = v +end) + +gears.timer { + timeout = 60, + call_now = true, + autostart = true, + callback = function() + updateTime() + end +} +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/weather.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/weather.lua new file mode 100644 index 0000000..1022399 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/moment/mods/weather.lua @@ -0,0 +1,226 @@ +local wibox = require("wibox") +local awful = require("awful") +local beautiful = require "beautiful" +local gears = require("gears") +local helpers = require "helpers" + +local filesystem = gears.filesystem +local icon_dir = filesystem.get_configuration_dir() .. "theme/assets/weather/icons/" + + +local icon_map = { + ["01d"] = "weather-clear-sky", + ["02d"] = "weather-few-clouds", + ["03d"] = "weather-clouds", + ["04d"] = "weather-few-clouds", + ["09d"] = "weather-showers-scattered", + ["10d"] = "weather-showers", + ["11d"] = "weather-strom", + ["13d"] = "weather-snow", + ["50d"] = "weather-fog", + ["01n"] = "weather-clear-night", + ["02n"] = "weather-few-clouds-night", + ["03n"] = "weather-clouds-night", + ["04n"] = "weather-clouds-night", + ["09n"] = "weather-showers-scattered", + ["10n"] = "weather-showers", + ["11n"] = "weather-strom", + ["13n"] = "weather-snow", + ["50n"] = "weather-fog", +} + +local dayWeather = function() + local widget = wibox.widget { + { + id = "day", + halign = 'center', + widget = wibox.widget.textbox, + font = beautiful.sans .. " 10", + }, + { + id = "icon", + resize = true, + opacity = 0.6, + halign = 'center', + forced_height = 40, + forced_width = 40, + widget = wibox.widget.imagebox, + }, + { + { + { + { + id = "max", + halign = 'center', + widget = wibox.widget.textbox, + font = beautiful.sans .. " 10", + }, + { + halign = 'center', + markup = helpers.colorizeText("/", beautiful.blue), + widget = wibox.widget.textbox, + font = beautiful.sans .. " 10", + }, + { + id = "min", + halign = 'center', + widget = wibox.widget.textbox, + font = beautiful.sans .. " 10", + }, + spacing = 8, + layout = wibox.layout.fixed.horizontal, + }, + widget = wibox.container.place, + halign = 'center', + }, + widget = wibox.container.margin, + bottom = 20, + }, + spacing = 10, + forced_width = 80, + layout = wibox.layout.fixed.vertical, + } + + widget.update = function(out, i) + local day = out.daily[i] + widget:get_children_by_id('icon')[1].image = icon_dir .. icon_map[day.weather[1].icon] .. ".svg" + widget:get_children_by_id('day')[1].text = os.date("%a", tonumber(day.dt)) + local getTemp = function(temp) + local sp = helpers.split(temp, '.')[1] + return sp + end + widget:get_children_by_id('min')[1].text = getTemp(day.temp.night) + widget:get_children_by_id('max')[1].text = getTemp(day.temp.day) + end + return widget +end + +local day1 = dayWeather() +local day2 = dayWeather() +local day3 = dayWeather() +local day5 = dayWeather() +local day6 = dayWeather() +local day4 = dayWeather() + +local daylist = { day1, day2, day3, day4, day5, day6 } + + +local widget = wibox.widget { + { + id = "image", + forced_height = 300, + forced_width = 460, + image = helpers.cropSurface(1.53, gears.surface.load_uncached(beautiful.songdefpicture)), + widget = wibox.widget.imagebox, + clip_shape = helpers.rrect(12), + opacity = 0.9, + resize = true, + horizontal_fit_policy = "fit" + }, + { + { + widget = wibox.widget.textbox, + }, + bg = { + type = "linear", + from = { 0, 0 }, + to = { 250, 0 }, + stops = { { 0, beautiful.bg .. "66" }, { 1, beautiful.bg .. 'dd' } } + }, + shape = helpers.rrect(12), + widget = wibox.container.background, + }, + { + { + { + { + { + id = "icon", + image = gears.filesystem.get_configuration_dir() .. "theme/assets/weather/icons/weather-fog.svg", + opacity = 0.9, + clip_shape = helpers.rrect(4), + forced_height = 80, + forced_width = 80, + valign = "center", + widget = wibox.widget.imagebox + }, + { + id = "desc", + font = beautiful.sans .. " 12", + markup = "Scattered Clouds", + valign = "center", + widget = wibox.widget.textbox, + }, + spacing = 10, + layout = wibox.layout.fixed.vertical, + }, + nil, + { + { + id = "temp", + font = beautiful.sans .. " 32", + markup = "31 C", + valign = "center", + widget = wibox.widget.textbox, + }, + { + id = "fl", + font = beautiful.sans .. " 12", + markup = "Feels Like 30 C", + valign = "center", + widget = wibox.widget.textbox, + }, + { + id = "humid", + font = beautiful.sans .. " 12", + markup = "Humidity: 30%", + valign = "center", + widget = wibox.widget.textbox, + }, + spacing = 10, + layout = wibox.layout.fixed.vertical, + }, + layout = wibox.layout.align.horizontal, + }, + nil, + { + { + day1, + day2, + day3, + day4, + day5, + day6, + spacing = 25, + layout = require("mods.overflow").horizontal, + scrollbar_width = 0, + }, + widget = wibox.container.margin, + top = 15, + }, + layout = wibox.layout.align.vertical, + }, + widget = wibox.container.margin, + margins = { + left = 30, + right = 30, + top = 20, + bottom = 20, + }, + }, + layout = wibox.layout.stack, +} + +awesome.connect_signal("signal::weather", function(out) + helpers.gc(widget, "image").image = helpers.cropSurface(1.53, gears.surface.load_uncached(out.thumb)) + helpers.gc(widget, "icon").image = out.image + helpers.gc(widget, "temp").markup = out.temp .. "°C" + helpers.gc(widget, "desc").markup = out.desc + helpers.gc(widget, "humid").markup = "Humidity: " .. out.humidity .. "%" + helpers.gc(widget, "fl").markup = "Feels Like " .. out.temp .. "°C" + for i, j in ipairs(daylist) do + j.update(out, i) + end +end) + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/init.lua new file mode 100644 index 0000000..0a7911b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/init.lua @@ -0,0 +1,112 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local naughty = require("naughty") +local dpi = beautiful.xresources.apply_dpi +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local empty = require("ui.notify.mods.empty") +local make = require("ui.notify.mods.make") +local progs = require("ui.notify.mods.progs") + +awful.screen.connect_for_each_screen(function(s) + local notify = wibox({ + shape = helpers.rrect(12), + screen = s, + width = 500, + height = 1080 - 40 - 60, + bg = beautiful.bg, + ontop = true, + visible = false, + }) + + + local finalcontent = wibox.widget { + layout = require('mods.overflow').vertical, + scrollbar_enabled = false, + spacing = 20, + } + finalcontent:insert(1, empty) + + local remove_notifs_empty = true + + notif_center_reset_notifs_container = function() + finalcontent:reset(finalcontent) + finalcontent:insert(1, empty) + remove_notifs_empty = true + end + + notif_center_remove_notif = function(box) + finalcontent:remove_widgets(box) + if #finalcontent.children == 0 then + finalcontent:insert(1, empty) + remove_notifs_empty = true + end + end + + + local clearButton = wibox.widget { + font = beautiful.icon .. " 26", + markup = helpers.colorizeText("󰎟", beautiful.red), + widget = wibox.widget.textbox, + valign = "center", + align = "center", + buttons = { + awful.button({}, 1, function() + notif_center_reset_notifs_container() + end) + } + } + naughty.connect_signal("request::display", function(n) + if #finalcontent.children == 1 and remove_notifs_empty then + finalcontent:reset(finalcontent) + remove_notifs_empty = false + end + + local appicon = n.icon or n.app_icon + if not appicon then + appicon = gears.filesystem.get_configuration_dir() .. "theme/assets/awesome.svg" + end + finalcontent:insert(1, make(appicon, n)) + end) + notify:setup { + { + { + { + { + { + markup = helpers.colorizeText("Notifications", beautiful.fg), + halign = 'center', + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + }, + nil, + clearButton, + widget = wibox.layout.align.horizontal, + }, + widget = wibox.container.margin, + margins = 20, + }, + widget = wibox.container.background, + bg = beautiful.mbg + }, + { + { + finalcontent, + widget = wibox.container.margin, + margins = 20, + }, + widget = wibox.container.background, + }, + progs, + layout = wibox.layout.align.vertical, + spacing = 20, + }, + widget = wibox.container.margin, + margins = 0, + } + awful.placement.bottom_right(notify, { honor_workarea = true, margins = 20 }) + awesome.connect_signal("toggle::notify", function() + notify.visible = not notify.visible + end) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/empty.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/empty.lua new file mode 100644 index 0000000..c4b99d7 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/empty.lua @@ -0,0 +1,34 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local dpi = beautiful.xresources.apply_dpi +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") + +return wibox.widget { + { + { + { + widget = wibox.widget.textbox, + markup = helpers.colorizeText("No Notifications", beautiful.fg), + font = beautiful.sans .. " 14", + valign = "center", + align = "center" + }, + { + image = gears.filesystem.get_configuration_dir() .. "/theme/assets/wedding-bells.png", + resize = true, + forced_height = 250, + halign = "center", + valign = "center", + widget = wibox.widget.imagebox, + }, + spacing = 20, + layout = wibox.layout.fixed.vertical + }, + widget = wibox.container.place, + valign = 'center' + }, + widget = wibox.container.background, + forced_height = 600, +} diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/make.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/make.lua new file mode 100644 index 0000000..f330b2d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/make.lua @@ -0,0 +1,95 @@ +-- the notification themselves +local helpers = require("helpers") +local beautiful = require("beautiful") +local gears = require("gears") +local dpi = beautiful.xresources.apply_dpi +local awful = require("awful") +local wibox = require("wibox") +local naughty = require("naughty") +return function(icon, n) + local time = os.date "%H:%M:%S" + + local icon_widget = wibox.widget { + widget = wibox.container.constraint, + { + widget = wibox.container.margin, + margins = 20, + { + widget = wibox.widget.imagebox, + image = helpers.cropSurface(1, gears.surface.load_uncached(icon)), + resize = true, + clip_shape = gears.shape.circle, + halign = "center", + valign = "center", + }, + }, + } + + local title_widget = wibox.widget { + widget = wibox.container.scroll.horizontal, + step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, + speed = 50, + forced_width = 200, + { + widget = wibox.widget.textbox, + text = n.title, + align = "left", + forced_width = 200, + }, + } + + local time_widget = wibox.widget { + widget = wibox.container.margin, + margins = { right = 4 }, + { + widget = wibox.widget.textbox, + text = time, + align = "right", + valign = "bottom", + }, + } + + local text_notif = wibox.widget { + markup = n.message, + align = "left", + forced_width = 165, + widget = wibox.widget.textbox, + } + + + local box = wibox.widget { + widget = wibox.container.background, + forced_height = 120, + bg = beautiful.mbg, + { + layout = wibox.layout.align.horizontal, + icon_widget, + { + widget = wibox.container.margin, + margins = 10, + { + layout = wibox.layout.align.vertical, + { + layout = wibox.layout.fixed.vertical, + expand = "none", + spacing = 10, + { + layout = wibox.layout.align.horizontal, + title_widget, + nil, + time_widget, + }, + text_notif, + } + } + } + } + } + + + box:buttons(gears.table.join(awful.button({}, 1, function() + _G.notif_center_remove_notif(box) + end))) + + return box +end diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/progs.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/progs.lua new file mode 100644 index 0000000..5231f1d --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/notify/mods/progs.lua @@ -0,0 +1,66 @@ +local helpers = require("helpers") +local beautiful = require("beautiful") +local gears = require("gears") +local dpi = beautiful.xresources.apply_dpi +local awful = require("awful") +local wibox = require("wibox") + +local createProgress = function(col, label, signal) + local widget = wibox.widget { + { + { + { + font = beautiful.sans .. " Light 11", + markup = helpers.colorizeText(label, beautiful.fg), + widget = wibox.widget.textbox, + valign = "start", + align = "center" + }, + widget = wibox.container.background, + forced_width = 50, + }, + widget = wibox.container.margin, + right = 30, + }, + { + id = "pro", + max_value = 100, + value = 0, + forced_height = 20, + forced_width = 300, + bar_shape = helpers.rrect(5), + shape = helpers.rrect(5), + color = col, + background_color = col .. '11', + paddings = 1, + border_width = 1, + widget = wibox.widget.progressbar, + }, + nil, + layout = wibox.layout.align.horizontal, + } + + awesome.connect_signal('signal::' .. signal, function(val) + helpers.gc(widget, "pro").value = val + end) + + return widget +end + +local widget = { + { + { + createProgress(beautiful.red, "CPU", "cpu"), + createProgress(beautiful.blue, "MEM", "memory"), + createProgress(beautiful.magenta, "DIS", "disk"), + spacing = 30, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.margin, + margins = 30 + }, + widget = wibox.container.background, + bg = beautiful.mbg +} + +return widget diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/brightness.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/brightness.lua new file mode 100644 index 0000000..d3a4a99 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/brightness.lua @@ -0,0 +1,105 @@ +local gears = require("gears") +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local animation = require("mods.animation") + +-- osd -- + +local info = wibox.widget { + widget = wibox.container.margin, + margins = 20, + { + layout = wibox.layout.fixed.horizontal, + fill_space = true, + spacing = 8, + { + widget = wibox.widget.textbox, + id = "icon", + font = beautiful.icon .. " 14", + }, + { + widget = wibox.container.background, + forced_width = 36, + { + widget = wibox.widget.textbox, + id = "text", + halign = "center" + }, + }, + { + widget = wibox.widget.progressbar, + id = "progressbar", + max_value = 100, + forced_width = 380, + forced_height = 10, + background_color = beautiful.mbg, + color = beautiful.blue, + }, + } +} + +local osd = awful.popup { + visible = false, + ontop = true, + minimum_height = 60, + maximum_height = 60, + minimum_width = 290, + maximum_width = 290, + placement = function(d) + awful.placement.bottom(d, { margins = 20, honor_workarea = true, }) + end, + widget = info, +} + +local anim = animation:new { + duration = 0.3, + easing = animation.easing.linear, + update = function(self, pos) + info:get_children_by_id("progressbar")[1].value = pos + end, +} + +-- volume -- + + +-- bright -- + +awesome.connect_signal("signal::brightness", function(value) + anim:set(value) + info:get_children_by_id("text")[1].text = value + if value > 90 then + info:get_children_by_id("icon")[1].text = "󰃠" + elseif value > 60 then + info:get_children_by_id("icon")[1].text = "󰃟" + elseif value > 30 then + info:get_children_by_id("icon")[1].text = "󰃝" + elseif value > 10 then + info:get_children_by_id("icon")[1].text = "󰃞" + end +end) + +-- function -- + +local function osd_hide() + osd.visible = false + osd_timer:stop() +end + +local osd_timer = gears.timer { + timeout = 4, + callback = osd_hide +} + +local function osd_toggle() + if not osd.visible then + osd.visible = true + osd_timer:start() + else + osd_timer:again() + end +end + +awesome.connect_signal("open::osdb", function() + osd_toggle() +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/init.lua new file mode 100644 index 0000000..0b3cda4 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/init.lua @@ -0,0 +1,3 @@ +require "ui.popups.scrotter" +require "ui.popups.brightness" +require "ui.popups.volume" diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/scrotter.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/scrotter.lua new file mode 100644 index 0000000..d109220 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/scrotter.lua @@ -0,0 +1,164 @@ +local wibox = require("wibox") +local helpers = require("helpers") +local awful = require("awful") +local beautiful = require("beautiful") +local gears = require("gears") +local lgi = require('lgi') +local Gtk = lgi.require('Gtk', '3.0') +local Gdk = lgi.require('Gdk', '3.0') +local GdkPixbuf = lgi.GdkPixbuf +local dpi = beautiful.xresources.apply_dpi + +local delay = tostring(1) .. " " + +local clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) + + +local getName = function() + local string = "~/Pictures/Screenshots/" .. os.date("%d-%m-%Y-%H:%M:%S") .. ".jpg" + string = string:gsub("~", os.getenv("HOME")) + return string +end + +local defCommand = "maim " .. "-d " .. delay + +local copyScrot = function(path) + local image = GdkPixbuf.Pixbuf.new_from_file(path) + clipboard:set_image(image) + clipboard:store() +end + +local createButton = function(icon, name, fn, col) + return wibox.widget { + { + { + { + { + font = beautiful.icon .. " 38", + markup = helpers.colorizeText(icon, col), + valign = "center", + align = "center", + widget = wibox.widget.textbox, + }, + widget = wibox.container.margin, + margins = 23, + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = beautiful.mbg, + }, + { + font = beautiful.sans .. " 10", + markup = name, + valign = "center", + align = "center", + widget = wibox.widget.textbox, + }, + spacing = 10, + layout = wibox.layout.fixed.vertical, + }, + layout = wibox.layout.fixed.vertical, + buttons = awful.button({}, 1, function() + fn() + end), + } +end + + +awful.screen.connect_for_each_screen(function(s) + local scrotter = wibox { + width = dpi(410), + height = dpi(210), + shape = helpers.rrect(8), + bg = beautiful.bg, + ontop = true, + visible = false + } + + local close = function() + scrotter.visible = not scrotter.visible + end + + local fullscreen = createButton('󰍹', 'Fullscreen', function() + close() + local name = getName() + local cmd = defCommand .. name + awful.spawn.easy_async_with_shell(cmd, function() + copyScrot(name) + end) + end, beautiful.green) + + local selection = createButton('󰩭', 'Selection', function() + close() + local name = getName() + local cmd = "maim" .. " -s " .. name + awful.spawn.easy_async_with_shell(cmd, function() + copyScrot(name) + end) + end, beautiful.blue) + + local window = createButton('󰘔', 'Window', function() + close() + local name = getName() + local cmd = "maim" .. " -i " .. client.focus.window .. " " .. name + awful.spawn.with_shell(cmd) + awful.spawn.easy_async_with_shell(cmd, function() + copyScrot(name) + end) + end, beautiful.red) + + scrotter:setup { + { + { + { + { + { + font = beautiful.font .. " 14", + markup = "Screenshotter", + valign = "center", + align = "start", + widget = wibox.widget.textbox, + }, + nil, + { + font = beautiful.icon .. " 18", + markup = helpers.colorizeText("󰅖", beautiful.red), + valign = "center", + align = "start", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + close() + end) + }, + }, + widget = wibox.layout.align.horizontal + }, + widget = wibox.container.margin, + margins = 10 + }, + widget = wibox.container.background, + }, + { + { + fullscreen, + selection, + window, + spacing = 25, + layout = wibox.layout.fixed.horizontal + }, + widget = wibox.container.place, + halign = "center" + }, + spacing = 10, + layout = wibox.layout.fixed.vertical, + }, + widget = wibox.container.margin, + margins = 10, + } + + awesome.connect_signal("toggle::scrotter", function() + scrotter.visible = not scrotter.visible + awful.placement.centered(scrotter) + end) +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/volume.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/volume.lua new file mode 100644 index 0000000..f9efb6b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/popups/volume.lua @@ -0,0 +1,100 @@ +local gears = require("gears") +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local animation = require("mods.animation") + +-- osd -- + +local info = wibox.widget { + widget = wibox.container.margin, + margins = 20, + { + layout = wibox.layout.fixed.horizontal, + fill_space = true, + spacing = 8, + { + widget = wibox.widget.textbox, + id = "icon", + font = beautiful.icon .. " 14", + }, + { + widget = wibox.container.background, + forced_width = 36, + { + widget = wibox.widget.textbox, + id = "text", + halign = "center" + }, + }, + { + widget = wibox.widget.progressbar, + id = "progressbar", + max_value = 100, + forced_width = 380, + forced_height = 10, + background_color = beautiful.mbg, + color = beautiful.blue, + }, + } +} + +local osd = awful.popup { + visible = false, + ontop = true, + minimum_height = 60, + maximum_height = 60, + minimum_width = 290, + maximum_width = 290, + placement = function(d) + awful.placement.bottom(d, { margins = 20, honor_workarea = true, }) + end, + widget = info, +} + +local anim = animation:new { + duration = 0.3, + easing = animation.easing.linear, + update = function(self, pos) + info:get_children_by_id("progressbar")[1].value = pos + end, +} + +-- volume -- + +awesome.connect_signal("signal::volume", function(value) + anim:set(value) + info:get_children_by_id("text")[1].text = value + if value > 80 then + info:get_children_by_id("icon")[1].text = "󰕾" + elseif value > 50 then + info:get_children_by_id("icon")[1].text = "󰖀" + elseif value > 10 then + info:get_children_by_id("icon")[1].text = "󰕿" + end +end) + +-- function -- + +local function osd_hide() + osd.visible = false + osd_timer:stop() +end + +local osd_timer = gears.timer { + timeout = 4, + callback = osd_hide +} + +local function osd_toggle() + if not osd.visible then + osd.visible = true + osd_timer:start() + else + osd_timer:again() + end +end + +awesome.connect_signal("open::osd", function() + osd_toggle() +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/rightclick.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/rightclick.lua new file mode 100644 index 0000000..9dfd35a --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/rightclick.lua @@ -0,0 +1,169 @@ +local awful = require("awful") +local menu = require("mods.menu") +local hotkeys_popup = require("awful.hotkeys_popup") +local focused = awful.screen.focused() + +local function awesome_menu() + return menu({ + menu.button({ + icon = { icon = "", font = "Material Design Icons " }, + text = "Show Help", + on_press = function() + hotkeys_popup.show_help(nil, awful.screen.focused()) + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "", font = "Material Design Icons" }, + text = "Docs", + on_press = function() + awful.spawn.with_shell("firefox https://awesomewm.org/apidoc/documentation/07-my-first-awesome.md.html#") + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󰣕", font = "Material Design Icons" }, + text = "Edit Config", + on_press = function() + awful.spawn.with_shell("cd ~/.config/awesome && wezterm -e nvim" .. " " .. awesome.conffile) + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󰦛", font = "Material Design Icons" }, + text = "Restart", + on_press = function() + awesome.emit_signal("close::menu") + awesome.restart() + end, + }), + menu.button({ + icon = { icon = "󰈆", font = "Material Design Icons" }, + text = "Quit", + on_press = function() + awesome.quit() + awesome.emit_signal("close::menu") + end, + }), + }) +end + +local function desktopMenu() + return menu({ + menu.button({ + icon = { icon = "󱪞", font = "Material Design Icons " }, + text = "New File", + on_press = function() + awesome.emit_signal("toggle::popup", "create") + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󰮝", font = "Material Design Icons" }, + text = "New Folder", + on_press = function() + awesome.emit_signal("close::menu") + awesome.emit_signal("toggle::popup", "folder") + end, + }), + menu.button({ + icon = { icon = "󰦛", font = "Material Design Icons" }, + text = "Refresh Icons", + on_press = function() + awesome.emit_signal("signal::desktop") + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󰈈", font = "Material Design Icons" }, + text = "Toggle Icons", + on_press = function() + awesome.emit_signal("close::menu") + end, + }), + }) +end + +local function widget() + return menu({ + menu.button({ + icon = { icon = "󰍉", font = "Material Design Icons " }, + text = "Applications", + on_press = function() + awesome.emit_signal("toggle::launcher") + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󱃸", font = "Material Design Icons " }, + text = "Terminal", + on_press = function() + awful.spawn("wezterm", false) + end, + }), + menu.button({ + icon = { icon = "󰈹", font = "Material Design Icons " }, + text = "Web Browser", + on_press = function() + awful.spawn("firefox", false) + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󰉋", font = "Material Design Icons " }, + text = "File Manager", + on_press = function() + awful.spawn("nemo", false) + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󱇨", font = "Material Design Icons " }, + text = "Text Editor", + on_press = function() + awful.spawn("wezterm -e nvim", false) + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "", font = "Material Design Icons " }, + text = "Music Player", + on_press = function() + awesome.emit_signal("toggle::ncmpcpppad") + awesome.emit_signal("close::menu") + end, + }), + menu.button({ + icon = { icon = "󰐱", font = "Material Design Icons" }, + text = "Configure", + on_press = function() + awesome.emit_signal("close::menu") + awesome.emit_signal("toggle::setup") + end, + }), + menu.separator(), + menu.sub_menu_button({ + icon = { icon = "󰖟", font = "Material Design Icons " }, + text = "AwesomeWM", + sub_menu = awesome_menu(), + }), + menu.sub_menu_button({ + icon = { icon = "󰟀", font = "Material Design Icons " }, + text = "Desktop", + sub_menu = desktopMenu(), + }), + }) +end + + +local themenu = widget() + + +awesome.connect_signal("close::menu", function() + themenu:hide(true) +end) +awesome.connect_signal("toggle::menu", function() + themenu:toggle() +end) + +return { desktop = themenu } diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/init.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/init.lua new file mode 100644 index 0000000..676923e --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/init.lua @@ -0,0 +1,154 @@ +local awful = require("awful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local json = require("mods.json") +local beautiful = require("beautiful") + +local inspect = require("mods.inspect") +local input = require("ui.setup.mods.input") +local pass = require("ui.setup.mods.pass") +local check = require("ui.setup.mods.check") +local intin = require("ui.setup.mods.intin") +local themer = require("ui.setup.mods.themer") + +local data = helpers.readJson(gears.filesystem.get_cache_dir() .. "json/settings.json") +local a1 = input("Profile Picture", true, data.pfp) +local a2 = input("Icon Theme Path", true, data.iconTheme) +local a3 = pass("OpenWeather API Key", data.openWeatherApi) + +local a4 = check("Image Wallpaper", "colorful", "plain", data.wallpaper) +local a5 = check("Desktop Icons", true, false, data.showDesktopIcons) +local a6 = intin("Gaps", tostring(data.gaps)) + +local function writeData() + local data = { + pfp = a1.value, + iconTheme = a2.value, + openWeatherApi = a3.value, + wallpaper = a4.value, + showDesktopIcons = a5.value, + gaps = tonumber(a6.value), + colorscheme = themer.current + } + local w = assert(io.open(gears.filesystem.get_cache_dir() .. "json/settings.json", "w")) + w:write(json.encode(data, nil, { pretty = true, indent = " ", align_keys = false, array_newline = true })) + w:close() + awesome.restart() +end + +awful.screen.connect_for_each_screen(function(s) + local setup = wibox({ + shape = helpers.rrect(12), + screen = s, + width = 560, + height = 670, + bg = beautiful.bg, + ontop = true, + visible = false, + }) + + awful.placement.centered(setup, { honor_workarea = true }) + awesome.connect_signal("toggle::setup", function() + setup.visible = not setup.visible + end) + + setup:setup { + { + { + { + font = beautiful.sans .. " 14", + markup = helpers.colorizeText("Configure", beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "center" + }, + nil, + { + { + { + { + font = beautiful.sans .. " 10", + markup = helpers.colorizeText("Apply In Nix", beautiful.blue), + widget = wibox.widget.textbox, + valign = "center", + align = "center" + }, + widget = wibox.container.margin, + margins = 10 + }, + widget = wibox.container.background, + shape = helpers.rrect(6), + buttons = { + awful.button({}, 1, function() + awful.spawn.with_shell("setTheme " .. themer.current) + awesome.emit_signal('toggle::setup') + end) + }, + bg = beautiful.blue .. '11' + }, + { + { + { + font = beautiful.icon .. " 12", + markup = helpers.colorizeText("󰄬", beautiful.green), + widget = wibox.widget.textbox, + valign = "center", + align = "center" + }, + widget = wibox.container.margin, + margins = 10 + }, + widget = wibox.container.background, + shape = helpers.rrect(6), + buttons = { + awful.button({}, 1, function() + writeData() + awesome.emit_signal('toggle::setup') + end) + }, + bg = beautiful.green .. '11' + }, + { + { + { + font = beautiful.icon .. " 12", + markup = helpers.colorizeText("󰅖", beautiful.red), + widget = wibox.widget.textbox, + valign = "center", + align = "center" + }, + widget = wibox.container.margin, + margins = 10 + }, + widget = wibox.container.background, + shape = helpers.rrect(6), + buttons = { + awful.button({}, 1, function() + awesome.emit_signal('toggle::setup') + end) + }, + bg = beautiful.red .. '11' + }, + spacing = 20, + layout = wibox.layout.fixed.horizontal + }, + layout = wibox.layout.align.horizontal + }, + a1.widget, + a2.widget, + a3.widget, + { + a4.widget, + a5.widget, + a6.widget, + layout = wibox.layout.flex.horizontal + }, + themer.widget, + spacing = 25, + layout = wibox.layout.fixed.vertical + }, + widget = wibox.container.margin, + margins = 20, + } +end) diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/check.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/check.lua new file mode 100644 index 0000000..693f55b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/check.lua @@ -0,0 +1,78 @@ +local awful = require("awful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local json = require("mods.json") +local beautiful = require("beautiful") + +local O = function(label, tv, fv, var) + local M = { label = label, value = var, def = var } + + M.box = wibox.widget { + bg = var == tv and beautiful.fg or beautiful.bg, + + shape = helpers.rrect(100), + widget = wibox.container.background, + forced_height = 12, + forced_width = 12, + } + + function M:refresh() + self.box.bg = self.value == tv and beautiful.fg or beautiful.bg + end + + function M:toggle() + if M.value == tv then + M.value = fv + else + M.value = tv + end + self:refresh() + end + + M.widget = wibox.widget { + { + { + { + { + bg = beautiful.bg, + shape = helpers.rrect(100), + shape_border_width = 2, + shape_border_color = beautiful.fg, + widget = wibox.container.background, + forced_height = 24, + forced_width = 24, + }, + widget = wibox.container.place, + valign = "center" + }, + { + M.box, + widget = wibox.container.place, + valign = "center" + }, + buttons = { + awful.button(nil, 1, function() + M:toggle() + end) + }, + widget = wibox.layout.stack + }, + widget = wibox.container.place, + valign = "center" + }, + { + font = beautiful.sans .. " Light 11", + markup = helpers.colorizeText(M.label, beautiful.fg), + widget = wibox.widget.textbox, + valign = "start", + align = "start" + }, + spacing = 12, + layout = wibox.layout.fixed.horizontal + } + + return M +end + +return O diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/input.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/input.lua new file mode 100644 index 0000000..62ff71b --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/input.lua @@ -0,0 +1,77 @@ +local awful = require("awful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local json = require("mods.json") +local beautiful = require("beautiful") + +local O = function(label, isPath, var) + local M = { label = label, isPath = isPath, value = var, def = var } + + M.textbox = wibox.widget { + font = beautiful.sans .. " 12", + markup = helpers.colorizeText(M.value, beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "start" + } + + function M:getInput() + awful.prompt.run({ + textbox = M.textbox, + text = M.value, + bg_cursor = beautiful.fg .. '22', + exe_callback = function(input) + -- If no input is present, display old contents. + if not input or #input == 0 then + M.textbox.markup = helpers.colorizeText(M.def, beautiful.fg) + M.textbox.font = beautiful.sans .. " 12" + return + end + -- else update textbox and variable. + if input:match("~/") and self.isPath then + M.value = input:gsub("~/", "/home/" .. beautiful.user:lower() .. "/") + M.textbox.markup = helpers.colorizeText(input:gsub("~/", "/home/" .. beautiful.user:lower() .. "/"), beautiful + .fg) + else + M.value = input + M.textbox.markup = helpers.colorizeText(input, beautiful.fg) + end + end + }) + end + + M.widget = wibox.widget { + { + font = beautiful.sans .. " Light 11", + markup = helpers.colorizeText(M.label, beautiful.fg), + widget = wibox.widget.textbox, + valign = "start", + align = "start" + }, + { + { + M.textbox, + widget = wibox.container.margin, + top = 15, + bottom = 15, + left = 10, + right = 10, + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = beautiful.mbg, + buttons = { + awful.button(nil, 1, function() + M:getInput() + end) + } + }, + spacing = 2, + layout = wibox.layout.fixed.vertical + } + + return M +end + +return O diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/intin.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/intin.lua new file mode 100644 index 0000000..812e0e5 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/intin.lua @@ -0,0 +1,76 @@ +local awful = require("awful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local json = require("mods.json") +local beautiful = require("beautiful") + +local O = function(label, var) + local M = { label = label, value = var, def = var } + + M.textbox = wibox.widget { + font = beautiful.sans .. " 12", + markup = helpers.colorizeText(M.value, beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "start", + forced_width = 75, + } + + function M:getInput() + awful.prompt.run({ + textbox = M.textbox, + text = M.value, + bg_cursor = beautiful.fg .. '22', + exe_callback = function(input) + -- If no input is present, display old contents. + if not input or #input == 0 then + M.textbox.markup = helpers.colorizeText(M.def, beautiful.fg) + return + end + -- else update textbox and variable. + if string.match(input, "[^%d%.]") ~= nil then + M.textbox.markup = helpers.colorizeText(M.def, beautiful.fg) + M.value = M.def + else + M.value = input + M.textbox.markup = helpers.colorizeText(input, beautiful.fg) + end + end + }) + end + + M.widget = wibox.widget { + { + { + M.textbox, + widget = wibox.container.margin, + top = 10, + bottom = 10, + left = 10, + right = 10, + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = beautiful.mbg, + buttons = { + awful.button(nil, 1, function() + M:getInput() + end) + } + }, + { + font = beautiful.sans .. " Light 11", + markup = helpers.colorizeText(M.label, beautiful.fg), + widget = wibox.widget.textbox, + valign = "start", + align = "start" + }, + spacing = 12, + layout = wibox.layout.fixed.horizontal + } + + return M +end + +return O diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/pass.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/pass.lua new file mode 100644 index 0000000..4260946 --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/pass.lua @@ -0,0 +1,110 @@ +local awful = require("awful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local json = require("mods.json") +local beautiful = require("beautiful") + +local O = function(label, var) + local M = { label = label, hidden = true, value = var, def = var } + + M.textbox = wibox.widget { + font = beautiful.sans .. " 12", + markup = helpers.colorizeText(M.hidden and string.rep("*", #M.value) or M.value, beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "start" + } + + function M:getInput() + awful.prompt.run({ + textbox = M.textbox, + text = M.value, + bg_cursor = beautiful.fg .. '22', + exe_callback = function(input) + -- If no input is present, display old contents. + if not input or #input == 0 then + M.textbox.markup = helpers.colorizeText(M.def, beautiful.fg) + M.textbox.font = beautiful.sans .. " 12" + return + end + -- else update textbox and variable. + M.value = input + if self.hidden then + M.textbox.markup = helpers.colorizeText(string.rep("*", #M.value), beautiful.fg) + else + M.textbox.markup = helpers.colorizeText(input, beautiful.fg) + end + end + }) + end + + M.widget = wibox.widget { + { + font = beautiful.sans .. " Light 11", + markup = helpers.colorizeText(M.label, beautiful.fg), + widget = wibox.widget.textbox, + valign = "start", + align = "start" + }, + { + nil, + { + { + M.textbox, + widget = wibox.container.margin, + top = 15, + bottom = 15, + left = 10, + right = 10, + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = beautiful.mbg, + buttons = { + awful.button(nil, 1, function() + M:getInput() + end) + } + }, + { + { + { + { + font = beautiful.icon .. " 14", + markup = helpers.colorizeText("󰈈", beautiful.fg), + widget = wibox.widget.textbox, + valign = "center", + align = "start" + }, + left = 15, + right = 15, + widget = wibox.container.margin, + }, + shape = helpers.rrect(10), + widget = wibox.container.background, + buttons = { + awful.button(nil, 1, function() + M.hidden = not M.hidden + if M.hidden then + M.textbox.markup = helpers.colorizeText(string.rep("*", #M.value), beautiful.fg) + else + M.textbox.markup = helpers.colorizeText(M.value, beautiful.fg) + end + end) + }, + bg = beautiful.mbg, + }, + left = 10, + widget = wibox.container.margin, + }, + layout = wibox.layout.align.horizontal, + }, + spacing = 2, + layout = wibox.layout.fixed.vertical + } + + return M +end + +return O diff --git a/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/themer.lua b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/themer.lua new file mode 100644 index 0000000..5b1b7cb --- /dev/null +++ b/modules/home-manager/ricing/awesomewm/dotfiles/ui/setup/mods/themer.lua @@ -0,0 +1,166 @@ +local awful = require("awful") +local helpers = require("helpers") +local wibox = require("wibox") +local gears = require("gears") +local json = require("mods.json") +local beautiful = require("beautiful") + +local themes = { "biscuit", "cat", "decay", "everblush", "forest", "fovere", "fullerene", "kizu", "nirvana", "oxo", "rose","solarized", + "stardewnight", "swamp", + "sweetpastel", "verdant", "vixima" } + +local index = helpers.indexOf(themes, beautiful.scheme) + +local M = { + current = beautiful.scheme, + colors = { + red = beautiful.red, + green = beautiful.green, + yellow = beautiful.yellow, + blue = beautiful.blue, + magenta = beautiful.magenta, + bg = beautiful.bg, + fg = beautiful.fg + } +} + +function M:previous() + index = index - 1 + if index < 1 then + index = #themes + end + M:getColors(themes[index]) + M:setColors() +end + +function M:next() + index = index + 1 + if index > #themes then + index = 1 + end + M:getColors(themes[index]) + M:setColors() +end + +function M:getColors(scheme) + scheme = scheme or self.current + local colors = require("theme.colors." .. scheme) + self.colors = colors + self.current = scheme +end + +function M:setColors() + helpers.gc(self.widget, "red").bg = self.colors.err + helpers.gc(self.widget, "blue").bg = self.colors.pri + helpers.gc(self.widget, "green").bg = self.colors.ok + helpers.gc(self.widget, "yellow").bg = self.colors.warn + helpers.gc(self.widget, "magenta").bg = self.colors.dis + helpers.gc(self.widget, "fg").bg = self.colors.fg + helpers.gc(self.widget, "bg").bg = self.colors.mbg + helpers.gc(self.widget, "name").markup = self.current:gsub("^%l", string.upper) +end + +M.widget = wibox.widget { + { + { + { + { + id = "name", + markup = M.current, + font = beautiful.sans .. " 14", + widget = wibox.widget.textbox + }, + nil, + { + { + markup = "󰅁", + font = beautiful.icon .. " 18", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + M:previous() + end) + }, + }, + { + markup = "󰅂", + font = beautiful.icon .. " 18", + widget = wibox.widget.textbox, + buttons = { + awful.button({}, 1, function() + M:next() + end) + }, + }, + layout = wibox.layout.fixed.horizontal + }, + layout = wibox.layout.align.horizontal + }, + { + { + { + id = "red", + widget = wibox.container.background, + forced_height = 60, + forced_width = 60, + bg = M.colors.red + }, + { + id = "green", + widget = wibox.container.background, + forced_height = 60, + forced_width = 60, + bg = M.colors.green + }, + { + id = "yellow", + widget = wibox.container.background, + forced_height = 60, + forced_width = 60, + bg = M.colors.yellow + }, + { + id = "blue", + widget = wibox.container.background, + forced_height = 60, + forced_width = 60, + bg = M.colors.blue + }, + { + id = "magenta", + widget = wibox.container.background, + forced_height = 60, + forced_width = 60, + bg = M.colors.magenta + }, + { + id = "fg", + widget = wibox.container.background, + forced_height = 60, + forced_width = 60, + bg = M.colors.fg + }, + spacing = 20, + layout = wibox.layout.fixed.horizontal, + }, + valign = "center", + halign = "center", + widget = wibox.container.place, + }, + nil, + layout = wibox.layout.align.vertical, + }, + widget = wibox.container.margin, + margins = 12 + }, + id = "bg", + forced_height = 200, + shape = helpers.rrect(10), + widget = wibox.container.background, + bg = M.colors.bg +} + +M:getColors(beautiful.scheme) +M:setColors() + +return M diff --git a/modules/home-manager/ricing/default.nix b/modules/home-manager/ricing/default.nix index 0571e57..f7d0f2f 100644 --- a/modules/home-manager/ricing/default.nix +++ b/modules/home-manager/ricing/default.nix @@ -2,6 +2,7 @@ { imports = [ + ./awesomewm ]; # GTK theming diff --git a/modules/home-manager/ricing/hyprland/default.nix b/modules/home-manager/ricing/hyprland/default.nix new file mode 100644 index 0000000..35b8ce4 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/default.nix @@ -0,0 +1,243 @@ +{ + inputs, + pkgs, + ... +}: let + hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland; + # plugins = inputs.hyprland-plugins.packages.${pkgs.system}; + + yt = pkgs.writeShellScript "yt" '' + notify-send "Opening video" "$(wl-paste)" + mpv "$(wl-paste)" + ''; + + playerctl = "${pkgs.playerctl}/bin/playerctl"; + brightnessctl = "${pkgs.brightnessctl}/bin/brightnessctl"; + pactl = "${pkgs.pulseaudio}/bin/pactl"; +in { + + imports = [ + ./eww + ]; + + xdg.desktopEntries."org.gnome.Settings" = { + name = "Settings"; + comment = "Gnome Control Center"; + icon = "org.gnome.Settings"; + exec = "env XDG_CURRENT_DESKTOP=gnome ${pkgs.gnome.gnome-control-center}/bin/gnome-control-center"; + categories = ["X-Preferences"]; + terminal = false; + }; + + wayland.windowManager.hyprland = { + enable = true; + package = hyprland; + systemd.enable = true; + xwayland.enable = true; + plugins = [ + # inputs.hyprland-hyprspace.packages.${pkgs.system}.default + # plugins.hyprexpo + # plugins.hyprbars + # plugins.borderspp + ]; + + settings = { + exec-once = [ + ]; + + monitor = [ + "eDP-1, preferred, auto-right, 1" + "HDMI-A-2, preferrred, auto-left, 1" + ]; + + general = { + layout = "dwindle"; + resize_on_border = true; + }; + + misc = { + disable_splash_rendering = true; + force_default_wallpaper = 1; + }; + + input = { + kb_layout = "us"; + follow_mouse = 1; + touchpad = { + natural_scroll = "yes"; + disable_while_typing = true; + drag_lock = true; + }; + sensitivity = 0; + float_switch_override_focus = 2; + }; + + binds = { + allow_workspace_cycles = true; + }; + + dwindle = { + pseudotile = "yes"; + preserve_split = "yes"; + # no_gaps_when_only = "yes"; + }; + + gestures = { + workspace_swipe = true; + workspace_swipe_use_r = true; + }; + + windowrule = let + f = regex: "float, ^(${regex})$"; + in [ + (f "org.gnome.Calculator") + (f "org.gnome.Nautilus") + (f "pavucontrol") + (f "nm-connection-editor") + (f "blueberry.py") + (f "org.gnome.Settings") + (f "org.gnome.design.Palette") + (f "Color Picker") + (f "xdg-desktop-portal") + (f "xdg-desktop-portal-gnome") + (f "de.haeckerfelix.Fragments") + (f "com.github.Aylur.ags") + "workspace 7, title:Spotify" + ]; + + bind = let + binding = mod: cmd: key: arg: "${mod}, ${key}, ${cmd}, ${arg}"; + mvfocus = binding "SUPER" "movefocus"; + ws = binding "SUPER" "workspace"; + resizeactive = binding "SUPER CTRL" "resizeactive"; + mvactive = binding "SUPER ALT" "moveactive"; + mvtows = binding "SUPER SHIFT" "movetoworkspace"; + e = "exec, ags -b hypr"; + arr = [1 2 3 4 5 6 7]; + in + [ + "CTRL SHIFT, R, ${e} quit; ags -b hypr" + "SUPER, R, ${e} -t launcher" + "SUPER, Tab, ${e} -t overview" + ",XF86PowerOff, ${e} -r 'powermenu.shutdown()'" + ",XF86Launch4, ${e} -r 'recorder.start()'" + ",Print, ${e} -r 'recorder.screenshot()'" + "SHIFT,Print, ${e} -r 'recorder.screenshot(true)'" + "SUPER, Return, exec, xterm" # xterm is a symlink, not actually xterm + "SUPER, W, exec, firefox" + "SUPER, E, exec, wezterm -e lf" + + # youtube + ", XF86Launch1, exec, ${yt}" + + "ALT, Tab, focuscurrentorlast" + "CTRL ALT, Delete, exit" + "ALT, Q, killactive" + "SUPER, F, togglefloating" + "SUPER, G, fullscreen" + "SUPER, O, fakefullscreen" + "SUPER, P, togglesplit" + + (mvfocus "k" "u") + (mvfocus "j" "d") + (mvfocus "l" "r") + (mvfocus "h" "l") + (ws "left" "e-1") + (ws "right" "e+1") + (mvtows "left" "e-1") + (mvtows "right" "e+1") + (resizeactive "k" "0 -20") + (resizeactive "j" "0 20") + (resizeactive "l" "20 0") + (resizeactive "h" "-20 0") + (mvactive "k" "0 -20") + (mvactive "j" "0 20") + (mvactive "l" "20 0") + (mvactive "h" "-20 0") + ] + ++ (map (i: ws (toString i) (toString i)) arr) + ++ (map (i: mvtows (toString i) (toString i)) arr); + + bindle = [ + ",XF86MonBrightnessUp, exec, ${brightnessctl} set +5%" + ",XF86MonBrightnessDown, exec, ${brightnessctl} set 5%-" + ",XF86KbdBrightnessUp, exec, ${brightnessctl} -d asus::kbd_backlight set +1" + ",XF86KbdBrightnessDown, exec, ${brightnessctl} -d asus::kbd_backlight set 1-" + ",XF86AudioRaiseVolume, exec, ${pactl} set-sink-volume @DEFAULT_SINK@ +5%" + ",XF86AudioLowerVolume, exec, ${pactl} set-sink-volume @DEFAULT_SINK@ -5%" + ]; + + bindl = [ + ",XF86AudioPlay, exec, ${playerctl} play-pause" + ",XF86AudioStop, exec, ${playerctl} pause" + ",XF86AudioPause, exec, ${playerctl} pause" + ",XF86AudioPrev, exec, ${playerctl} previous" + ",XF86AudioNext, exec, ${playerctl} next" + ",XF86AudioMicMute, exec, ${pactl} set-source-mute @DEFAULT_SOURCE@ toggle" + ]; + + bindm = [ + "SUPER, mouse:273, resizewindow" + "SUPER, mouse:272, movewindow" + ]; + + decoration = { + drop_shadow = "yes"; + shadow_range = 8; + shadow_render_power = 2; + "col.shadow" = "rgba(00000044)"; + + dim_inactive = false; + + blur = { + enabled = true; + size = 8; + passes = 3; + new_optimizations = "on"; + noise = 0.01; + contrast = 0.9; + brightness = 0.8; + popups = true; + }; + }; + + animations = { + enabled = "yes"; + bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; + animation = [ + "windows, 1, 5, myBezier" + "windowsOut, 1, 7, default, popin 80%" + "border, 1, 10, default" + "fade, 1, 7, default" + "workspaces, 1, 6, default" + ]; + }; + + plugin = { + overview = { + centerAligned = true; + hideTopLayers = true; + hideOverlayLayers = true; + showNewWorkspace = true; + exitOnClick = true; + exitOnSwitch = true; + drawActiveWorkspace = true; + reverseSwipe = true; + }; + hyprbars = { + bar_color = "rgb(2a2a2a)"; + bar_height = 28; + col_text = "rgba(ffffffdd)"; + bar_text_size = 11; + bar_text_font = "Ubuntu Nerd Font"; + + buttons = { + button_size = 0; + "col.maximize" = "rgba(ffffff11)"; + "col.close" = "rgba(ff111133)"; + }; + }; + }; + }; + }; +} \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/assets/empty-notification.png b/modules/home-manager/ricing/hyprland/eww/assets/empty-notification.png new file mode 100644 index 0000000..aedb537 Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/empty-notification.png differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/fullpfp.png b/modules/home-manager/ricing/hyprland/eww/assets/fullpfp.png new file mode 100644 index 0000000..9984e6c Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/fullpfp.png differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/pfp.png b/modules/home-manager/ricing/hyprland/eww/assets/pfp.png new file mode 100644 index 0000000..7e58ae9 Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/pfp.png differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/snoo.png b/modules/home-manager/ricing/hyprland/eww/assets/snoo.png new file mode 100644 index 0000000..361c11d Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/snoo.png differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clear-night.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clear-night.jpg new file mode 100644 index 0000000..a5a36c2 Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clear-night.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clear-sky.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clear-sky.jpg new file mode 100644 index 0000000..799b4dc Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clear-sky.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clouds-night.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clouds-night.jpg new file mode 100644 index 0000000..8d2c696 Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clouds-night.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clouds.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clouds.jpg new file mode 100644 index 0000000..441dabd Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-clouds.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-fog.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-fog.jpg new file mode 100644 index 0000000..925eb08 Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-fog.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-showers-scattered.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-showers-scattered.jpg new file mode 100644 index 0000000..41439b9 Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-showers-scattered.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-showers.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-showers.jpg new file mode 100644 index 0000000..e6f942e Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-showers.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-snow.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-snow.jpg new file mode 100644 index 0000000..a579d1c Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-snow.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-stroms.jpg b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-stroms.jpg new file mode 100644 index 0000000..83fb291 Binary files /dev/null and b/modules/home-manager/ricing/hyprland/eww/assets/weather/weather-stroms.jpg differ diff --git a/modules/home-manager/ricing/hyprland/eww/default.nix b/modules/home-manager/ricing/hyprland/eww/default.nix new file mode 100644 index 0000000..8cc2b2c --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/default.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + home.packages = [ + pkgs.eww + ]; +} \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/eww.scss b/modules/home-manager/ricing/hyprland/eww/eww.scss new file mode 100644 index 0000000..30c2281 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/eww.scss @@ -0,0 +1,19 @@ +@mixin rounding { + border-radius: 12px; + } + + + .themes { + margin-right: 1rem; + } + + @import "style/colors"; + @import "style/bar/init"; + @import "style/control/init"; + @import "style/dash/init"; + @import "style/moment/init"; + + * { + all: unset; + transition: 100ms ease; + } \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/eww.yuck b/modules/home-manager/ricing/hyprland/eww/eww.yuck new file mode 100644 index 0000000..5a29c22 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/eww.yuck @@ -0,0 +1,5 @@ +(include "./yuck/_vars.yuck") +(include "./yuck/bar/_init.yuck") +(include "./yuck/control/_init.yuck") +(include "./yuck/dash/_init.yuck") +(include "./yuck/moment/_init.yuck") \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/ap.sh b/modules/home-manager/ricing/hyprland/eww/scripts/ap.sh new file mode 100644 index 0000000..3533f65 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/ap.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +STATUS="$(rfkill list | sed -n 2p | awk '{print $3}')" + + +toggle() { + if [[ $STATUS == "no" ]]; then + rfkill block all + notify-send --urgency=normal "Airplane Mode" "Airplane mode has been turned on!" + else + rfkill unblock all + notify-send --urgency=normal "Airplane Mode" "Airplane mode has been turned off!" + fi +} + +class() { + if [[ $STATUS == "no" ]]; then + echo inactive + else + echo active + fi +} + +if [[ $1 == "--toggle" ]]; then + toggle +elif [[ $1 == "--class" ]]; then + class +fi \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/bat.sh b/modules/home-manager/ricing/hyprland/eww/scripts/bat.sh new file mode 100644 index 0000000..123d756 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/bat.sh @@ -0,0 +1,79 @@ +#!/bin/sh + +bat=/sys/class/power_supply/BAT0/ +per="$(cat "$bat/capacity")" + +icon() { + +if [ "$per" -gt "90" ]; then + icon="󰁹" +elif [ "$per" -gt "80" ]; then + icon="󰂁" +elif [ "$per" -gt "70" ]; then + icon="󰂀" +elif [ "$per" -gt "60" ]; then + icon="󰁿" +elif [ "$per" -gt "49" ]; then + icon="󰁾" +elif [ "$per" -gt "40" ]; then + icon="󰁽" +elif [ "$per" -gt "20" ]; then + icon="assets/battery_nearly-low.png" +elif [ "$per" -gt "10" ]; then + icon="assets/battery_low.png" + notify-send -u critical "Battery Low" "Connect Charger" +elif [ "$per" -gt "0" ]; then + icon="assets/battery_low.png" + notify-send -u critical "Battery Low" "Connect Charger" +else + echo  && exit +fi +echo "$icon" +} + +percent() { +echo $per +} + + +status(){ + if [[ -d /sys/class/power_supply/ACAD ]]; then + echo " " + elif [[ -d /sys/class/power_supply/BAT0 ]]; then + [[ $(cat /sys/class/power_supply/BAT0/status) == "Discharging" ]] && echo "" || echo "" + else + echo "" + fi +} + +class() { + if [ "$per" -gt "90" ]; then + class="color: #81c19b" + elif [ "$per" -gt "80" ]; then + class="color: #81c19b" + elif [ "$per" -gt "70" ]; then + class="color: #81c19b" + elif [ "$per" -gt "60" ]; then + class="color: #81c19b" + elif [ "$per" -gt "49" ]; then + class="color: #8FA7A9" + elif [ "$per" -gt "40" ]; then + class="color: #8FA7A9" + elif [ "$per" -gt "20" ]; then + class="color: #ecd28b" + elif [ "$per" -gt "10" ]; then + class="color: #df5b61" + elif [ "$per" -gt "0" ]; then + class="color: #df5b61" + else + echo "" && exit + fi + echo "$class" +} + +[ "$1" = "icon" ] && icon && exit +[ "$1" = "percent" ] && percent && exit +[ "$1" = "status" ] && status && exit +[ "$1" = "class" ] && class && exit + +exit \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/bl.sh b/modules/home-manager/ricing/hyprland/eww/scripts/bl.sh new file mode 100644 index 0000000..331ae80 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/bl.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +toggle() { + STATUS="$(bluetoothctl show | grep Powered | awk '{print $2}')" + if [ $STATUS == "yes" ]; then + bluetoothctl power off + notify-send --icon=bluetooth-offline --urgency=normal "Bluetooth" "Bluetooth has been turned off." + else + bluetoothctl power on + notify-send --icon=volume-level-high --urgency=normal "Bluetooth" "Bluetooth has been turned on." + fi +} + +class() { + # off + if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] + then + echo inactive + else + echo active + fi +} + +status() { + # not connected + if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]; then + echo "Off" + else + # on + if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ]; then + echo "On" + else + # get device alias + DEVICE=`echo info | bluetoothctl | grep 'Alias:' | awk -F: '{ print $2 }'` + echo "$DEVICE" + fi + fi +} + + +if [[ $1 == "--status" ]]; then + status +elif [[ $1 == "--icon" ]]; then + icon +elif [[ $1 == "--toggle" ]]; then + toggle +elif [[ $1 == "--class" ]]; then + class +elif [[ $1 == "--battery" ]]; then + battery +fi \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/cpu.sh b/modules/home-manager/ricing/hyprland/eww/scripts/cpu.sh new file mode 100644 index 0000000..4af8f68 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/cpu.sh @@ -0,0 +1,4 @@ +#!/bin/sh +CPU=$(cat /sys/class/thermal/thermal_zone*/temp) +TEMP=$((CPU / 1000)) +echo $TEMP \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/dnd.sh b/modules/home-manager/ricing/hyprland/eww/scripts/dnd.sh new file mode 100644 index 0000000..0063af9 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/dnd.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +STATUS=$(dunstctl is-paused) + +toggle() { + if [ $STATUS == "false" ]; then + dunstctl set-paused true + else + dunstctl set-paused false + fi +} + + +class() { + if [ $STATUS == "false" ]; then + echo inactive + else + echo active + fi +} + +if [[ $1 == "--toggle" ]]; then + toggle +elif [[ $1 == "--class" ]]; then + class +fi \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/ms.sh b/modules/home-manager/ricing/hyprland/eww/scripts/ms.sh new file mode 100644 index 0000000..20df83e --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/ms.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +# scripts by adi1090x + +## Get data +STATUS="$(mpc status)" +COVER="/tmp/.music_cover.png" +MUSIC_DIR="$HOME/Music" + +## Get status +get_status() { + if [[ $STATUS == *"[playing]"* ]]; then + echo "󰏤" + else + echo "󰐊" + fi +} + +## Get song +get_song() { + song=`mpc -f %title% current` + if [[ -z "$song" ]]; then + echo "Offline" + else + echo "$song" + fi +} + +## Get artist +get_artist() { + artist=`mpc -f %artist% current` + if [[ -z "$artist" ]]; then + echo "" + else + echo "$artist" + fi +} + +## Get time +get_time() { + time=`mpc status | grep "%)" | awk '{print $4}' | tr -d '(%)'` + if [[ -z "$time" ]]; then + echo "0" + else + echo "$time" + fi +} +get_ctime() { + ctime=`mpc status | grep "#" | awk '{print $3}' | sed 's|/.*||g'` + if [[ -z "$ctime" ]]; then + echo "0:00" + else + echo "$ctime" + fi +} +get_ttime() { + ttime=`mpc -f %time% current` + if [[ -z "$ttime" ]]; then + echo "0:00" + else + echo "$ttime" + fi +} + +## Get cover +get_cover() { + ffmpeg -i "${MUSIC_DIR}/$(mpc current -f %file%)" "${COVER}" -y &> /dev/null + STATUS=$? + + # Check if the file has a embbeded album art + if [ "$STATUS" -eq 0 ];then + echo "$COVER" + else + echo "images/music.png" + fi +} + +## Execute accordingly +if [[ "$1" == "--song" ]]; then + get_song +elif [[ "$1" == "--artist" ]]; then + get_artist +elif [[ "$1" == "--status" ]]; then + get_status +elif [[ "$1" == "--time" ]]; then + get_time +elif [[ "$1" == "--ctime" ]]; then + get_ctime +elif [[ "$1" == "--ttime" ]]; then + get_ttime +elif [[ "$1" == "--cover" ]]; then + get_cover +elif [[ "$1" == "--toggle" ]]; then + mpc -q toggle +elif [[ "$1" == "--next" ]]; then + { mpc -q next; get_cover; } +elif [[ "$1" == "--prev" ]]; then + { mpc -q prev; get_cover; } +fi \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/notification_logger.zsh b/modules/home-manager/ricing/hyprland/eww/scripts/notification_logger.zsh new file mode 100644 index 0000000..5514923 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/notification_logger.zsh @@ -0,0 +1,105 @@ +#!/usr/bin/env zsh +function _set_vars() { + typeset -gx DUNST_CACHE_DIR="$HOME/.cache/dunst" + typeset -gx DUNST_LOG="$DUNST_CACHE_DIR/notifications.txt" + typeset -gx DEFAULT_QUOTE="To fake it is to stand guard over emptiness. ── Arthur Herzog" + typeset -gx DUNST_QUOTES="$DUNST_CACHE_DIR/quotes.txt" +} + +function _unset_vars() { + unset DUNST_CACHE_DIR + unset DUNST_LOG + unset DUNST_QUOTES + unset DEFAULT_QUOTE +} +_set_vars + +mkdir "$DUNST_CACHE_DIR" 2>/dev/null +touch "$DUNST_LOG" 2>/dev/null + +function create_cache() { + local urgency + case "$DUNST_URGENCY" in + "LOW"|"NORMAL"|"CRITICAL") urgency="$DUNST_URGENCY";; + *) urgency="OTHER";; + esac + + local summary + local body + [ "$DUNST_SUMMARY" = "" ] && summary="Summary unavailable." || summary="$DUNST_SUMMARY" + [ "$DUNST_BODY" = "" ] && body="Body unavailable." || body="$(print "$DUNST_BODY" | recode html)" + + local glyph + case "$urgency" in + "LOW") glyph="󰋽";; + "NORMAL") glyph="󱝁 ";; + "CRITICAL") glyph="󰋽";; + *) glyph="󰓏";; + esac + case "$DUNST_APP_NAME" in + "Spotify") glyph="󰎄";; + "mpd") glyph="󰎄";; + "picom") glyph="󰽮";; + "sxhkd") glyph="󰌌";; + "changebrightness") glyph="󰃠";; + "nightmode") glyph="󰌵";; + "microphone") glyph="󰍰";; + "changevolume") glyph="󰕾";; + "screenshot") glyph="󰢨";; + "firefox") glyph="󰈹 ";; + esac + # pipe stdout -> pipe cat stdin (cat conCATs multiple files and sends to stdout) -> absorb stdout from cat + # concat: "one" + "two" + "three" -> notice how the order matters i.e. "one" will be prepended + print '(card :width 400 :class "control-center-card control-center-card-'$urgency' control-center-card-'$DUNST_APP_NAME'" :glyph_class "control-center-'$urgency' control-center-'$DUNST_APP_NAME'" :SL "'$DUNST_ID'" :L "dunstctl history-pop '$DUNST_ID'" :body "'$body'" :summary "'$summary'" :glyph "'$glyph'")' \ + | cat - "$DUNST_LOG" \ + | sponge "$DUNST_LOG" +} + +function compile_caches() { tr '\n' ' ' < "$DUNST_LOG" } + +function make_literal() { + local caches="$(compile_caches)" + [[ "$caches" == "" ]] \ + && print '(box :class "control-center-empty-box" :width 360 :height 350 :orientation "vertical" :space-evenly false (image :class "control-center-empty-banner" :valign "center" :vexpand true :path "assets/empty-notification.svg" :image-width 200 :image-height 200) )' \ + || print "(scroll :width 360 :height 350 :vscroll true (box :hexpand true :orientation 'vertical' :class 'control-center-scroll-box' :spacing 15 :space-evenly false $caches))" +} + +function clear_logs() { + killall dunst 2>/dev/null + dunst & disown + print > "$DUNST_LOG" +} + +function pop() { sed -i '1d' "$DUNST_LOG" } + +function drop() { sed -i '$d' "$DUNST_LOG" } + +function remove_line() { sed -i '/SL "'$1'"/d' "$DUNST_LOG" } + +function critical_count() { + local crits=$(cat $DUNST_LOG | grep CRITICAL | wc -l) + local total=$(cat $DUNST_LOG | wc -l) + print $(((crits*100)/total)) +} + +function subscribe() { + make_literal + local lines=$(cat $DUNST_LOG | wc -l) + while sleep 0.1; do + local new=$(cat $DUNST_LOG | wc -l) + [[ $lines -ne $new ]] && lines=$new && print + done | while read -r _ do; make_literal done +} + +case "$1" in + "pop") pop;; + "drop") drop;; + "clear") clear_logs;; + "subscribe") subscribe;; + "rm_id") remove_line $2;; + "crits") critical_count;; + *) create_cache;; +esac + +sed -i '/^$/d' "$DUNST_LOG" +_unset_vars \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/weathercopy.sh b/modules/home-manager/ricing/hyprland/eww/scripts/weathercopy.sh new file mode 100644 index 0000000..4aa78ea --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/weathercopy.sh @@ -0,0 +1,154 @@ +#!/bin/sh + +# Rename This To weather.sh and add your api key + +encode_to_url_format() { + echo "$1" | sed 's/ /%20/g' +} + +check_if_empty() { + [[ -z "$1" ]] && echo "0" || echo "$1" +} + +KEY="" +CITY="New Delhi" +CITY=$(encode_to_url_format "$CITY") +WEATHER=$(curl -sf "api.openweathermap.org/data/2.5/weather?q=$CITY&appid=$KEY&units=metric") + +WEATHER_DESC=$(echo $WEATHER | jq -r ".weather[0].main") +WEATHER_TEMP=$(echo $WEATHER | jq ".main.temp" | cut -d "." -f 1) +WEATHER_ICON_CODE=$(echo "$WEATHER" | jq -r ".weather[].icon" | head -1) +WEATHER_FEELS_LIKE=$(echo $WEATHER | jq ".main.feels_like" | cut -d "." -f 1) +WEATHER_HUMIDITY=$(echo $WEATHER | jq ".main.humidity" | cut -d "." -f 1) +WEATHER_ICON="" +WEATHER_IMAGE="" +WEATHER_HEX="" + +case $WEATHER_ICON_CODE in + "01d") + WEATHER_ICON=" " + WEATHER_IMAGE="clear-sky" + WEATHER_HEX="#ffd86b" + ;; + "01n") + WEATHER_ICON=" " + WEATHER_IMAGE="clear-night" + WEATHER_HEX="#fcdcf6" + ;; + "02d") + WEATHER_ICON=" " + WEATHER_IMAGE="clouds" + WEATHER_HEX="#adadff" + ;; + "02n") + WEATHER_ICON=" " + WEATHER_HEX="#adadff" + WEATHER_IMAGE="clouds-night" + ;; + "03d") + WEATHER_ICON=" " + WEATHER_IMAGE="clouds" + WEATHER_HEX="#adadff" + ;; + "03n") + WEATHER_ICON=" " + WEATHER_IMAGE="clouds-night" + WEATHER_HEX="#adadff" + ;; + "04d") + WEATHER_ICON=" " + WEATHER_IMAGE="clouds" + WEATHER_HEX="#adadff" + ;; + "04n") + WEATHER_ICON=" " + WEATHER_IMAGE="clouds-night" + WEATHER_HEX="#adadff" + ;; + "09d") + WEATHER_ICON="" + WEATHER_IMAGE="clouds-showers-scattered" + WEATHER_HEX="#6b95ff" + ;; + "09n") + WEATHER_ICON="" + WEATHER_IMAGE="clouds-showers-scattered" + WEATHER_HEX="#6b95ff" + ;; + "10d") + WEATHER_ICON="" + WEATHER_IMAGE="clouds-showers" + WEATHER_HEX="#6b95ff" + ;; + "10n") + WEATHER_ICON="" + WEATHER_IMAGE="clouds-showers" + WEATHER_HEX="#6b95ff" + ;; + "11d") + WEATHER_ICON="" + WEATHER_IMAGE="stroms" + WEATHER_HEX="#ffeb57" + ;; + "11n") + WEATHER_ICON="" + WEATHER_IMAGE="stroms" + WEATHER_HEX="#ffeb57" + ;; + "13d") + WEATHER_ICON=" " + WEATHER_IMAGE="snow" + WEATHER_HEX="#e3e6fc" + ;; + "13n") + WEATHER_ICON=" " + WEATHER_IMAGE="snow" + WEATHER_HEX="#e3e6fc" + ;; + "50d") + WEATHER_ICON=" " + WEATHER_IMAGE="fog" + WEATHER_HEX="#84afdb" + ;; + "50n") + WEATHER_IMAGE="fog" + WEATHER_ICON=" " + WEATHER_HEX="#84afdb" + ;; + *) + WEATHER_ICON=" " + WEATHER_IMAGE="clouds" + WEATHER_HEX="#adadff" + ;; +esac + +case $1 in + "current_temp") + check_if_empty $WEATHER_TEMP + ;; + "current_temp_fahrenheit") + WEATHER_TEMP=$((($WEATHER_TEMP * 9 / 5) + 32)) + check_if_empty $WEATHER_TEMP + ;; + "feels_like") + check_if_empty $WEATHER_FEELS_LIKE + ;; + "humidity") + check_if_empty $WEATHER_HUMIDITY + ;; + "weather_desc") + [[ -z $WEATHER_DESC ]] && echo "Not Available." || echo "$WEATHER_DESC" + ;; + "icon") + echo $WEATHER_ICON + ;; + "hex") + echo $WEATHER_HEX + ;; + "image") + echo $WEATHER_IMAGE + ;; + "full") + echo $WEATHER + ;; +esac \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/wifi.sh b/modules/home-manager/ricing/hyprland/eww/scripts/wifi.sh new file mode 100644 index 0000000..0ddc61e --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/wifi.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +STATUS=$(nmcli | grep wlo1 | awk 'FNR == 1 {print $2}') +SSID=$(iwgetid | awk -F '"' '{ print $2 }') +STRENGTH=$(awk 'NR==3 {printf("%.0f",$3*10/7)}' /proc/net/wireless) + +toggle() { + if [[ $STATUS == "connected" ]]; then + nmcli radio wifi off + notify-send --icon=window-close --urgency=normal "Wi-Fi" "Wi-Fi has been turned off!" + else + nmcli radio wifi on + notify-send --icon=checkmark --urgency=normal "Wi-Fi" "Wi-Fi has been turned on, you are back online!" + fi +} + + +class() { + if [[ $STATUS == "connected" ]]; then + echo active + else + echo inactive + fi +} + +ssid() { + if [[ $STATUS == "connected" ]]; then + echo $(iwgetid -r) + + else + echo "n/a" + fi +} +color() { + if [[ $STATUS == "connected" ]]; then + echo "green" + + else + echo "red" + fi +} +icon() { + if [[ $STATUS == "connected" ]]; then + echo "󰤨 " + + else + echo "󰤮 " + fi +} +speed() { + s1=$(awk 'NR==3 {print $3}''' /proc/net/wireless) + s2=${s1::-1} + echo $s2 +} + +if [[ $1 == "--toggle" ]]; then + toggle +elif [[ $1 == "--class" ]]; then + class +elif [[ $1 == "--ssid" ]]; then + ssid +elif [[ $1 == "--color" ]]; then + color +elif [[ $1 == "--icon" ]]; then + icon +elif [[ $1 == "--speed" ]]; then + speed +fi \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/scripts/ws.sh b/modules/home-manager/ricing/hyprland/eww/scripts/ws.sh new file mode 100644 index 0000000..a572921 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/scripts/ws.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env sh +# +ACTIVEWS=$(hyprctl -j monitors | jq ".[0].activeWorkspace.id") +export a"$ACTIVEWS"="active" + +function handle_event { + case ${1%>>*} in + workspace) + unset a"$ACTIVEWS" + ACTIVEWS=${1#*>>} + export a"$ACTIVEWS"="active" + create_taglist + ;; + focusedmon) + ACTIVEWS=${1#*,} + ;; + createworkspace) + local WORKSPACE=${1#*>>} + export o"$WORKSPACE"="occupied" + create_taglist + ;; + destroyworkspace) + local WORKSPACE=${1#*>>} + unset o"$WORKSPACE" + create_taglist + esac +} + +function create_taglist { + echo "[\"$o1 $a1\", \"$o2 $a2\", \"$o3 $a3\", \"$o4 $a4\", \"$o5 $a5\", \"$o6 $a6\", \"$o7 $a7\"]" +} + +for NUM in {0..8}; do + WORKSPACE=$(hyprctl -j workspaces | jq ".[$NUM].id") + if [[ $WORKSPACE != "null" ]]; then + export o"$WORKSPACE"="occupied" + fi +done + +create_taglist + +socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r event; do +handle_event "$event" +done \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/style/bar/_init.scss b/modules/home-manager/ricing/hyprland/eww/style/bar/_init.scss new file mode 100644 index 0000000..e69de29 diff --git a/modules/home-manager/ricing/hyprland/eww/style/control/_init.scss b/modules/home-manager/ricing/hyprland/eww/style/control/_init.scss new file mode 100644 index 0000000..5c8a3e3 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/style/control/_init.scss @@ -0,0 +1,124 @@ +.control { + @include rounding; + background: $background; + padding: 1rem; + } + + .sliders { + @include rounding; + background: $background-alt; + padding: 2rem; + } + + .volscale trough { + min-width: 8rem; + min-height: 16px; + background: rgba($comment, 0.4); + @include rounding; + } + + .volscale trough highlight { + @include rounding; + background: $green; + } + + .brightscale trough { + min-width: 8rem; + min-height: 16px; + background: rgba($comment, 0.4); + @include rounding; + } + + .brightscale trough highlight { + @include rounding; + background: $yellow; + } + + .profile { + padding: 0.5rem; + } + + .profiletime { + font-family: "Rubik"; + font-size: 16px; + } + + .music { + @include rounding; + min-height: 10rem; + background-size: cover; + background-position: center; + } + + .music-g { + background-image: linear-gradient(to right, rgba($background, 0.95) 30%, rgba($background, 0.5)); + } + + .musicbutton { + font-family: "Iosevka Nerd Font"; + padding: 1rem; + font-size: 30px; + } + + .musicbuttons { + background: $background-alt; + padding: 0.5rem 1rem; + @include rounding; + } + + .profileexit { + color: $red; + font-size: 28px; + border-radius: 10px; + padding: 1rem 2rem 1rem 1.6rem; + background: linear-gradient(to bottom right, rgba($red, 0.05), rgba($red, 0.03)); + } + + .music-scale trough { + min-width: 8rem; + min-height: 10px; + background: rgba($background-alt, 0); + } + + .music-scale trough highlight { + background: $magenta; + } + + .musicinfo { + font-family: "Rubik"; + font-size: 16px; + padding: 1rem; + } + + .musicname { + font-size: 18px; + } + + .setbtn { + font-family: Material Design Icons; + background: rgba($comment, 0.2); + @include rounding; + padding: 1.7rem; + font-size: 24px; + } + + .active { + background: $accent; + color: $background; + } + + .scaleicon { + font-family: Material Design Icons; + font-size: 18px; + } + + .mono { + font-size: 16px; + font-family: "Iosevka Nerd Font"; + } + + .buttons { + background: $background-alt; + padding: 16px; + @include rounding; + } \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/style/dash/_init.scss b/modules/home-manager/ricing/hyprland/eww/style/dash/_init.scss new file mode 100644 index 0000000..e23f031 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/style/dash/_init.scss @@ -0,0 +1,153 @@ +.dash { + background: $background; + padding: 2rem; + @include rounding; + } + + .notifcenter { + @include rounding; + padding: 1rem; + background: rgba($background-alt, 0.4); + } + + .eon { + font-family: Rubik; + font-size: 1.3rem; + margin-top: 1rem; + } + + .notification { + font-family: Rubik; + background: rgba($background-alt, 0.6); + @include rounding; + + &-close { + font-family: Material Design Icons; + color: $red; + font-size: 1.3rem; + } + } + + .notification-title { + padding: 1rem; + @include rounding; + background: $background-alt; + } + + .notification-body { + padding: 1rem; + } + + .dashpfp { + min-height: 200px; + @include rounding; + } + + .dashgradient { + background-image: linear-gradient(to right, rgba($background, 0.5) 30%, rgba($background, 0.7)); + } + + .dashtime { + font-family: Rubik; + background: $background-alt; + @include rounding; + padding: 1rem; + } + + .timelabel { + font-family: Iosevka Nerd Font; + font-size: 1rem; + } + + .timelabelu { + font-family: Rubik; + font-size: 1.1rem; + color: $blue; + } + + .stats { + padding: 1rem; + @include rounding; + background: rgba($background-alt, 0.4); + } + + .gridline { + background: $background-alt; + @include rounding; + } + + .statscale trough { + min-width: 1.5rem; + margin: .5rem 0; + min-height: 16px; + @include rounding; + } + + .magentascale trough highlight { + @include rounding; + background: $magenta; + } + + .greenscale trough highlight { + @include rounding; + background: $green; + } + + .bluescale trough highlight { + @include rounding; + background: $blue; + } + + .redscale trough highlight { + @include rounding; + background: $red; + } + + .yellowscale trough highlight { + @include rounding; + background: $yellow; + } + + .circgreen { + color: $green; + } + + .circred { + color: $red; + } + + .altstat { + @include rounding; + background: rgba($background-alt, 0.8); + padding: 1rem 2rem; + } + + .tt { + font-family: Material Design Icons; + padding: 1.5rem; + font-size: 1.7rem; + } + + .clabel { + font-family: Iosevka Nerd Font; + color: $comment; + } + + + .dashmusic { + @include rounding; + background: rgba($background-alt, 0.8); + padding: 1rem; + } + + .dashart { + @include rounding; + opacity: 0.6; + min-height: 100px; + min-width: 120px; + } + + .dmi { + margin-top: 1rem; + font-family: Rubik; + } \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/style/moment/_init.scss b/modules/home-manager/ricing/hyprland/eww/style/moment/_init.scss new file mode 100644 index 0000000..e83db82 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/style/moment/_init.scss @@ -0,0 +1,113 @@ +.moment { + background: $background; + padding: 1.2rem; + @include rounding; + font-family: "Rubik"; + } + + calendar { + font-family: "Rubik"; + + &:selected { + color: $accent; + } + + &:indeterminate { + color: rgba(205, 219, 249, 0.3); + } + } + + + .bgblue { + background: $blue; + } + + .bgred { + background: $red; + } + + .bgpink { + background: $magenta; + } + + .moment_calendar { + background-color: $background-alt; + @include rounding; + border-radius: 10px; + + .moment_cal-box { + padding: 0 1rem; + background-color: $background-alt; + @include rounding; + border-radius: inherit; + + margin: 0.4em; + + + .moment_day-names { + font-family: "Rubik"; + margin: 0.1em 0.5em 0.5em; + font-size: 16px; + color: $red; + } + + .moment_cal { + font-size: 17px; + padding: 1em .6em 0.3em; + } + } + } + + .m { + font-family: "Rubik"; + font-size: 1.3rem; + color: $blue; + } + + .moment_month-year { + font-family: "Rubik"; + font-size: 1.3rem; + color: $foreground; + margin: 1rem 0; + } + + .moment_up { + padding: 18px; + background: $background; + } + + .mo { + font-family: "Rubik"; + font-size: 4rem; + } + + .woverlay { + background: linear-gradient(to right, rgba($background, 0.94), rgba($background-alt, 0.86)); + + } + + .wicon { + font-size: 4.3rem; + color: $foreground; + } + + .wdesc { + font-family: "Rubik"; + font-size: 1.4rem; + color: $foreground; + } + + .weatherimage { + min-height: 150px; + min-width: 400px; + @include rounding; + background-position: bottom; + } + + .ok { + padding: 3rem; + } + + .wtemp { + font-size: 2.3em; + } \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/yuck/_vars.yuck b/modules/home-manager/ricing/hyprland/eww/yuck/_vars.yuck new file mode 100644 index 0000000..ca34236 --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/yuck/_vars.yuck @@ -0,0 +1,49 @@ +(defpoll hour :interval "1s" `date +%H`) +(defpoll minute :interval "1s" `date +%M`) +(defpoll day :interval "1s" `date "+%A"`) +(defpoll ampm :interval "1s" `date "+%p"`) +(defpoll date :interval "1s" `date "+%D"`) +(defpoll month_year :interval "24h" + "date '+%B %Y'") +(defpoll calendar_day :interval "10h" + "date '+%d'") +(defpoll calendar_year :interval "10h" + "date '+%Y'") +(defpoll thourtime :interval "40s" `date +"%a %I:%M %p"`) + +;; SYSTEM VARS +(defpoll volume :interval "1s" `pamixer --get-volume`) +(defpoll brightness :interval "1s" `brightnessctl -m -d amdgpu_bl0 | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%'`) + +(defvar pfp "/home/namish/.config/eww/assets/pfp.png") +(defvar fullpfp "/home/namish/.config/eww/assets/fullpfp.png") + +(defpoll cputemp :interval "1s" "~/.config/eww/scripts/cpu.sh") +(defpoll wifisped :interval "1s" "~/.config/eww/scripts/wifi.sh --speed") + +(defpoll battery :interval "1s" `~/.config/eww/scripts/bat.sh percent`) +(defpoll wifiConnected :interval "2s" `~/.config/eww/scripts/wifi.sh --icon`) + +(defpoll song :interval "2s" "~/.config/eww/scripts/ms.sh --song") +(defpoll song_artist :interval "2s" "~/.config/eww/scripts/ms.sh --artist") +(defpoll current_status :interval "1s" "~/.config/eww/scripts/ms.sh --time") +(defpoll song_status :interval "1s" "~/.config/eww/scripts/ms.sh --status") +(defpoll cover_art :interval "2s" "~/.config/eww/scripts/ms.sh --cover") + +(defpoll username :interval "48h" "whoami") +(defpoll hostname :interval "48h" "hostname") +(defpoll uptime :interval "1m" "uptime -p | sed -e 's/up //;s/ hours,/h/;s/ hour,/h/;s/ minutes/m/;s/ minute/m/'") + +(defpoll apactive :interval '1s' "~/.config/eww/scripts/ap.sh --class") +(defpoll dndactive :interval '1s' "~/.config/eww/scripts/dnd.sh --class") +(defpoll wifiactive :interval '1s' "~/.config/eww/scripts/wifi.sh --class") +(defpoll btactive :interval '1s' "~/.config/eww/scripts/bl.sh --class") +(defpoll wallpaper :interval "1h" "source ~/.local/bin/upw && echo $WALLPAPER") + +(defpoll weathericon :interval "2h" "~/.config/eww/scripts/weather.sh icon") +(defpoll weatherimage :interval "2h" "~/.config/eww/scripts/weather.sh image") +(defpoll current_temp :interval "2h" "~/.config/eww/scripts/weather.sh current_temp") +(defpoll current_desc :interval "2h" "~/.config/eww/scripts/weather.sh weather_desc") + +(defpoll dunsthistory :interval "250ms" "dunstctl history") +(defpoll dunstcount :interval "250ms" "dunstctl count history") \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/yuck/bar/_init.yuck b/modules/home-manager/ricing/hyprland/eww/yuck/bar/_init.yuck new file mode 100644 index 0000000..1b3d81e --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/yuck/bar/_init.yuck @@ -0,0 +1,88 @@ + +(defwidget profile[] + (box :orientation 'h' :space-evenly false :class "profile" :spacing 20 + (image :hexpand true :halign "start" :image-width 50 :path pfp) + (box :orientation 'v' :valign 'center' :space-evenly false :halign "end" :spacing 3 + (box :class "profiletime" :halign "end" "${username}@${hostname}") + (box :class "profiletime" :halign "end" "${uptime}") + ) + ) +) + +(defwidget music[] + (box :orientation "h" :space-evenly false :spacing 15 + (overlay :hexpand true + (box :orientation 'v' :space-evenly false :class "music" :style "background-image: url('${cover_art}');" + ) + (box :class "music-g") + (box :orientation 'v' :space-evenly false + (box :orientation 'v' :space-evenly false :vexpand true :class "musicinfo" + (box :orientation "v" :halign 'start' :space-evenly false :spacing 3 + (box :halign 'start' :class "musicname" song) + (box :halign 'start' :class "musicartist" song_artist) + ) + ) + (scale :onchange "mpc seek {}%" :class "scale music-scale" :value current_status ) + ) + ) + (box :orientation 'v' :class "musicbuttons" + (button :onclick "~/.config/eww/scripts/ms.sh --prev":valign 'center' :class "musicbutton" "󰒮") + (button :onclick "~/.config/eww/scripts/ms.sh --toggle" :valign 'center' :class "musicbutton" "${song_status}") + (button :onclick "~/.config/eww/scripts/ms.sh --next" :valign 'center' :class "musicbutton" "󰒭") + ) + ) +) + +(defwidget setbtn[?icon active func label] + (button :halign 'center' :class "${active == 'active' ? 'active' : ''} setbtn" :onclick "${func}" + (box :hexpand true :halign "start" "${icon}" ) + ) +) + +(defwidget slider[value icon function class] + (box :orientation "h" :hexpand true :space-evenly false :spacing 20 + (box :class "scaleicon" icon) + (box :class "${class}" :hexpand true + (scale :class "scale ${class}" + :min 0 + :max 100 + :orientation "h" + :value value + :onchange function + :active true + :valign 'center') + ) + ) +) + +(defwidget buttons[] + (box :orientation 'h' :class "buttons" :spacing 5 + (setbtn :icon "󰤨" :func "~/.config/eww/scripts/wifi.sh --toggle" :label "wifi" :active wifiactive) + (setbtn :icon "󰂯" :func "~/.config/eww/scripts/bl.sh --toggle" :label "bluetooth" :active btactive) + (setbtn :icon "󰍶" :func "~/.config/eww/scripts/dnd.sh --toggle" :label "silent" :active dndactive) + (setbtn :icon "󰀝" :func "~/.config/eww/scripts/ap.sh --toggle" :label "airplane" :active apactive) +)) + + +(defwidget control[] + (box :orientation "v" :class "control" :space-evenly false :spacing 15 + (profile) + (box :orientation "v" :class "sliders" :space-evenly false :spacing 25 + (slider :class "brightscale" :icon "󰃟" :value brightness :function "brightnessctl s {}%") + (slider :class "volscale" :icon "󰓃" :value volume :round-digits 0 :function "pamixer --set-volume {}") + ) + (music) + (buttons) + ) +) + +(defwindow control + :monitor 0 + :geometry (geometry :x "290px" + :y "20px" + :width "450px" + :height "580px" + :anchor "top right") + :stacking "fg" + :exclusive true + (control)) \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/yuck/control/_init.yuck b/modules/home-manager/ricing/hyprland/eww/yuck/control/_init.yuck new file mode 100644 index 0000000..1b3d81e --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/yuck/control/_init.yuck @@ -0,0 +1,88 @@ + +(defwidget profile[] + (box :orientation 'h' :space-evenly false :class "profile" :spacing 20 + (image :hexpand true :halign "start" :image-width 50 :path pfp) + (box :orientation 'v' :valign 'center' :space-evenly false :halign "end" :spacing 3 + (box :class "profiletime" :halign "end" "${username}@${hostname}") + (box :class "profiletime" :halign "end" "${uptime}") + ) + ) +) + +(defwidget music[] + (box :orientation "h" :space-evenly false :spacing 15 + (overlay :hexpand true + (box :orientation 'v' :space-evenly false :class "music" :style "background-image: url('${cover_art}');" + ) + (box :class "music-g") + (box :orientation 'v' :space-evenly false + (box :orientation 'v' :space-evenly false :vexpand true :class "musicinfo" + (box :orientation "v" :halign 'start' :space-evenly false :spacing 3 + (box :halign 'start' :class "musicname" song) + (box :halign 'start' :class "musicartist" song_artist) + ) + ) + (scale :onchange "mpc seek {}%" :class "scale music-scale" :value current_status ) + ) + ) + (box :orientation 'v' :class "musicbuttons" + (button :onclick "~/.config/eww/scripts/ms.sh --prev":valign 'center' :class "musicbutton" "󰒮") + (button :onclick "~/.config/eww/scripts/ms.sh --toggle" :valign 'center' :class "musicbutton" "${song_status}") + (button :onclick "~/.config/eww/scripts/ms.sh --next" :valign 'center' :class "musicbutton" "󰒭") + ) + ) +) + +(defwidget setbtn[?icon active func label] + (button :halign 'center' :class "${active == 'active' ? 'active' : ''} setbtn" :onclick "${func}" + (box :hexpand true :halign "start" "${icon}" ) + ) +) + +(defwidget slider[value icon function class] + (box :orientation "h" :hexpand true :space-evenly false :spacing 20 + (box :class "scaleicon" icon) + (box :class "${class}" :hexpand true + (scale :class "scale ${class}" + :min 0 + :max 100 + :orientation "h" + :value value + :onchange function + :active true + :valign 'center') + ) + ) +) + +(defwidget buttons[] + (box :orientation 'h' :class "buttons" :spacing 5 + (setbtn :icon "󰤨" :func "~/.config/eww/scripts/wifi.sh --toggle" :label "wifi" :active wifiactive) + (setbtn :icon "󰂯" :func "~/.config/eww/scripts/bl.sh --toggle" :label "bluetooth" :active btactive) + (setbtn :icon "󰍶" :func "~/.config/eww/scripts/dnd.sh --toggle" :label "silent" :active dndactive) + (setbtn :icon "󰀝" :func "~/.config/eww/scripts/ap.sh --toggle" :label "airplane" :active apactive) +)) + + +(defwidget control[] + (box :orientation "v" :class "control" :space-evenly false :spacing 15 + (profile) + (box :orientation "v" :class "sliders" :space-evenly false :spacing 25 + (slider :class "brightscale" :icon "󰃟" :value brightness :function "brightnessctl s {}%") + (slider :class "volscale" :icon "󰓃" :value volume :round-digits 0 :function "pamixer --set-volume {}") + ) + (music) + (buttons) + ) +) + +(defwindow control + :monitor 0 + :geometry (geometry :x "290px" + :y "20px" + :width "450px" + :height "580px" + :anchor "top right") + :stacking "fg" + :exclusive true + (control)) \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/yuck/dash/_init.yuck b/modules/home-manager/ricing/hyprland/eww/yuck/dash/_init.yuck new file mode 100644 index 0000000..0418b8f --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/yuck/dash/_init.yuck @@ -0,0 +1,157 @@ +(defwidget notification [title summary body id icon ?LC ?reveal_close_icon] + (box :class "notification" :orientation "v" :height 150 :space-evenly "false" + (box :class "notification-title" + (label :class "notification-title-text" :halign "start" :text title) + (box :halign "end" + (button :class "notification-close" + :onclick "dunstctl history-rm ${id}" + "󰅖") + ) + ) + (box :class "notification-body" :space-evenly "false" :orientation "v" + (box :space-evenly "false" :spacing 20 :orientation "h" + (image :path icon :image-height 70) + (box + (box :class "notification-content" :orientation "v" :space-evenly "false" + (label :class "notification-summary" :halign "start" :valign "start" + :limit-width 15 + :text summary) + (label :class "notification-message" :halign "start" :valign "start" + :limit-width 45 :wrap true :tooltip body + :xalign 0 + :text body) + ) + ) + ) + ) + ) +) + +(defwidget sc[color val] + (box + (scale :orientation 'v' :flipped true :min 0 :max 100 :active false :class "${color}scale statscale" :value val) + ) +) + +(defwidget circprog[value icon label color] + (box :class "altstat" :orientation 'v' :spacing 10 :space-evenly false + (box :class "clabel" :halign "start" label) + (box :class "circbar" + (circular-progress :class " circ${color}" + :value value + :thickness 3 + :clockwise true + :start-at 30 + (box :class "tt" icon) + )) + ) +) +(defwidget dash[] + (box :class "dash" :spacing 20 :orientation "h" + (box :class "leftthing" :orientation 'v' :space-evenly false :spacing 20 + (box :orientation 'h' :spacing 20 + (overlay + (box :class "dashpfp" :style "background: url('${fullpfp}'); background-size: cover;") + (box :class "dashgradient") + ) + (box :orientation 'v' :spacing 20 + (box :class "dashtime" :orientation 'v' :space-evenly false + (box :orientation 'v' :space-evenly false :valign "center" :spacing 3 :vexpand true + (box :valign "center" :halign "start" :class "timelabelu" "Hello There") + (box :valign "center" :halign "start" :class "timelabel" uptime) + ) + ) + (box :class "dashtime" :orientation 'v' :space-evenly false :spacing 5 + (box :orientation 'v' :space-evenly false :valign "center" :spacing 3 :vexpand true + (box :valign "center" :halign "start" :class "timelabelu" "Time") + (box :valign "center" :halign "start" :class "timelabel" thourtime) + ) + ) + ) + ) + (box :orientation 'h' :space-evenly false :spacing 20 + (box :class "altstats" :orientation 'v' :spacing 20 + (circprog :value {EWW_CPU.avg} :icon "󰍛" :label "CPU" :color "red") + (circprog :value cputemp :icon "󰔏" :label "TEMP" :color "green") + ) + (box :class "stats" :orientation 'h' :hexpand true + (overlay + (box :orientation 'v' :spacing 60 + (box :height 3 :class "gridline") + (box :height 3 :class "gridline") + (box :height 3 :class "gridline") + (box :height 3 :class "gridline") + (box :height 3 :class "gridline") + ) + (box :orientation 'h' :spacing 75 + (box :width 3 :class "gridline") + (box :width 3 :class "gridline") + (box :width 3 :class "gridline") + (box :width 3 :class "gridline") + ) + (box :orientation 'h' + (sc :val {EWW_RAM.used_mem_perc} :color "red") + (sc :val wifisped :color "blue") + (sc :val {EWW_DISK["/"].used_perc} :color "magenta") + (sc :val battery :color "green") + ) + )) + ) + (box :orientation "h" :vexpand true :class "dashmusic" :space-evenly false :spacing 20 + (box :class "dashart" :style "background-image: url('${cover_art}'); background-size:cover;") + (box :orientation 'v' :halign "center" :hexpand true :valign "center" :vexpand true :space-evenly false :class "dmi" + (box :halign 'center' :class "musicname" song) + (box :halign 'center' :class "musicartist" song_artist) + (box :orientation 'h' (button :onclick "~/.config/eww/scripts/ms.sh --prev":valign 'center' :class "musicbutton" "󰒮") + (button :onclick "~/.config/eww/scripts/ms.sh --toggle" :valign 'center' :class "musicbutton" "${song_status}") + (button :onclick "~/.config/eww/scripts/ms.sh --next" :valign 'center' :class "musicbutton" "󰒭") + ) + ) + ) + ) + (box :class "notifcenter" :orientation 'v' :space-evenly true + (scroll :vscroll true + (box :orientation 'v' :space-evenly false + (box :orientation "v" :space-evenly false :spacing 20 + (for entry in {dunsthistory["data"][0]} + (box :class "notification-history" :orientation "v" :space-evenly "false" + (box :orientation 'v' :space-evenly false + (notification :class 'notif-${entry["id"]["data"]}' + :title {entry["appname"]["data"]} + :id {entry["id"]["data"]} + :summary {entry["summary"]["data"]} + :body {entry["body"]["data"]} + :icon {(entry["icon_path"]["data"] ?: "/home/namish/.config/awesome/theme/assets/notif.png")} + :reveal_close_icon "false" + :is_ss {entry["appname"]["data"] == "Screenshot Tool" ? "true" : "false"} + ) + ) + ) + ) + ) + + (revealer :valign "center" :vexpand true :reveal {dunstcount <= 0} :transition "crossfade" + (box :orientation "v" :space-evenly "false" :spacing 10 :valign "center" + (image :image-height 200 :path "/home/namish/.config/eww/assets/empty-notification.png") + (label :class "eon" + :valign "center" + :text "No Notifications." + ) + ) + ) + + ) + ) + ) +) +) +(defwindow dash + :monitor 0 + :geometry (geometry :x "0px" + :y "20px" + :width "900px" + :height "700px" + :anchor "top center") + :stacking "fg" + :exclusive false + (dash)) \ No newline at end of file diff --git a/modules/home-manager/ricing/hyprland/eww/yuck/moment/_init.yuck b/modules/home-manager/ricing/hyprland/eww/yuck/moment/_init.yuck new file mode 100644 index 0000000..bf0e14c --- /dev/null +++ b/modules/home-manager/ricing/hyprland/eww/yuck/moment/_init.yuck @@ -0,0 +1,68 @@ +(defwidget moment_calendar[] + (box :class " moment_calendar" :orientation "v" :space-evenly false + (box :class "moment_up" :space-evenly false :orientation "v" :spacing 20 (mtime) (label :class "m" :halign 'center' :hexpand true :text "${day}, ${calendar_day} ${month_year}") ) + (box :class "moment_cal-box" + :orientation "v" + :space-evenly "false" + (label :class "moment_month-year" :text month_year) + (box :class "moment_day-names" :orientation "h" :space-evenly "true" + (label :text "Su") + (label :text "Mo") + (label :text "Tu") + (label :text "We") + (label :text "Th") + (label :text "Fr") + (label :text "Sa") + ) + (calendar :class "moment_cal" + :show-details false :show-heading false :show-day-names false) + ) + ) +) + +(defwidget mtime[] + (box :space-evenly false :halign "center" :orientation 'h' :spacing 15 + (label :class "mo" :halign 'center' :text "${hour}") + (box :class "sep" :valign "center" :space-evenly false :orientation 'v' + (box :width 3 :height 20 :class "bgblue") + (box :width 3 :height 20 :class "bgpink") + (box :width 3 :height 20 :class "bgred") + ) + (label :class "mo" :halign 'center':text "${minute}") + ) +) + +(defwidget weather[] + (box :orientation 'v' + (overlay :vexpand true + (box :orientation 'v' :hexpand true :space-evenly false :halign 'center' :class "weatherimage" :style "background: url('/home/namish/.config/eww/assets/weather/weather-${weatherimage}.jpg'); background-size:cover;") + (box :class "woverlay" :hexpand true :vexpand true) + (box :class "ok" :hexpand true :valign "center" + (box :orientation 'v' :halign "start" :space-evenly false + (box :class "wicon" weathericon) + ) + (box :orientation 'v' :space-evenly false :valign "center" + (box :class "wtemp" :halign "end" "${current_temp}°C") + (box :class "wdesc" :halign "end" current_desc) + ) + ) + ) + ) + ) + +(defwidget moment[] + (box :orientation 'v' :spacing 20 :class 'moment' :space-evenly false + (moment_calendar) (weather)) +) + + +(defwindow moment + :monitor 0 + :geometry (geometry :x "290px" + :y "20px" + :width "360px" + :height "650px" + :anchor "top right") + :stacking "fg" + :exclusive true + (moment)) diff --git a/modules/home-manager/terminal/default.nix b/modules/home-manager/terminal/default.nix index 00ba443..e0af135 100644 --- a/modules/home-manager/terminal/default.nix +++ b/modules/home-manager/terminal/default.nix @@ -4,5 +4,6 @@ imports = [ ./shell ./kitty + ./wezterm ]; } \ No newline at end of file diff --git a/modules/home-manager/terminal/wezterm/default.nix b/modules/home-manager/terminal/wezterm/default.nix new file mode 100644 index 0000000..9a635ac --- /dev/null +++ b/modules/home-manager/terminal/wezterm/default.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + home.packages = [ + pkgs.wezterm + ]; +} \ No newline at end of file diff --git a/modules/system/desktop/awesome.nix b/modules/system/desktop/awesome.nix index 830c6e2..9255ef5 100644 --- a/modules/system/desktop/awesome.nix +++ b/modules/system/desktop/awesome.nix @@ -1,11 +1,32 @@ { config, pkgs, ... }: -{ +let + awesome = pkgs.awesome.overrideAttrs (oa: { + version = "ad0290bc1aac3ec2391aa14784146a53ebf9d1f0"; + src = pkgs.fetchFromGitHub { + owner = "awesomeWM"; + repo = "awesome"; + rev = "ad0290bc1aac3ec2391aa14784146a53ebf9d1f0"; + hash = "sha256-uaskBbnX8NgxrprI4UbPfb5cRqdRsJZv0YXXshfsxFU="; + }; + + patches = [ ]; + + postPatch = '' + patchShebangs tests/examples/_postprocess.lua + ''; + }); +in { services.xserver.windowManager.awesome = { enable = true; + package = awesome; luaModules = with pkgs.luaPackages; [ luarocks luadbi-mysql ]; }; + + environment.systemPackages = with pkgs; [ + picom + ]; } \ No newline at end of file diff --git a/modules/system/desktop/hyprland.nix b/modules/system/desktop/hyprland.nix index 995014c..6ce1ecd 100644 --- a/modules/system/desktop/hyprland.nix +++ b/modules/system/desktop/hyprland.nix @@ -1,8 +1,13 @@ -{ pkgs, ... }: +{ inputs, pkgs, ... }: { - programs.hyprland = { - enable = true; - xwayland.enable = true; - }; + nix.settings = { + substituters = ["https://hyprland.cachix.org"]; + trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="]; + }; + + programs.hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; + }; } \ No newline at end of file