diff --git a/configs/dunst/dunstrc b/configs/dunst/dunstrc new file mode 100644 index 0000000..1c4bced --- /dev/null +++ b/configs/dunst/dunstrc @@ -0,0 +1,445 @@ +# See dunst(5) for all configuration options + +[global] + ### Display ### + + # Which monitor should the notifications be displayed on. + monitor = 0 + + # Display notification on focused monitor. Possible modes are: + # mouse: follow mouse pointer + # keyboard: follow window with keyboard focus + # none: don't follow anything + # + # "keyboard" needs a window manager that exports the + # _NET_ACTIVE_WINDOW property. + # This should be the case for almost all modern window managers. + # + # If this option is set to mouse or keyboard, the monitor option + # will be ignored. + follow = none + + ### Geometry ### + + # dynamic width from 0 to 300 + # width = (0, 300) + # constant width of 300 + width = 300 + + # The maximum height of a single notification, excluding the frame. + height = 300 + + # Position the notification in the top right corner + origin = top-right + + # Offset from the origin + offset = 10x50 + + # Scale factor. It is auto-detected if value is 0. + scale = 0 + + # Maximum number of notification (0 means no limit) + notification_limit = 0 + + ### Progress bar ### + + # Turn on the progess bar. It appears when a progress hint is passed with + # for example dunstify -h int:value:12 + progress_bar = true + + # Set the progress bar height. This includes the frame, so make sure + # it's at least twice as big as the frame width. + progress_bar_height = 10 + + # Set the frame width of the progress bar + progress_bar_frame_width = 1 + + # Set the minimum width for the progress bar + progress_bar_min_width = 150 + + # Set the maximum width for the progress bar + progress_bar_max_width = 300 + + + # Show how many messages are currently hidden (because of + # notification_limit). + indicate_hidden = yes + + # The transparency of the window. Range: [0; 100]. + # This option will only work if a compositing window manager is + # present (e.g. xcompmgr, compiz, etc.). (X11 only) + transparency = 0 + + # Draw a line of "separator_height" pixel height between two + # notifications. + # Set to 0 to disable. + # If gap_size is greater than 0, this setting will be ignored. + separator_height = 2 + + # Padding between text and separator. + padding = 8 + + # Horizontal padding. + horizontal_padding = 8 + + # Padding between text and icon. + text_icon_padding = 0 + + # Defines width in pixels of frame around the notification window. + # Set to 0 to disable. + frame_width = 2 + + # Defines color of the frame around the notification window. + frame_color = "#ffffff" + + # Size of gap to display between notifications - requires a compositor. + # If value is greater than 0, separator_height will be ignored and a border + # of size frame_width will be drawn around each notification instead. + # Click events on gaps do not currently propagate to applications below. + # gap_size = 0 + + # Define a color for the separator. + # possible values are: + # * auto: dunst tries to find a color fitting to the background; + # * foreground: use the same color as the foreground; + # * frame: use the same color as the frame; + # * anything else will be interpreted as a X color. + separator_color = frame + + # Sort messages by urgency. + sort = yes + + # Don't remove messages, if the user is idle (no mouse or keyboard input) + # for longer than idle_threshold seconds. + # Set to 0 to disable. + # A client can set the 'transient' hint to bypass this. See the rules + # section for how to disable this if necessary + # idle_threshold = 120 + + ### Text ### + + font = Hack Nerd Font Mono 14 + + # The spacing between lines. If the height is smaller than the + # font height, it will get raised to the font height. + line_height = 0 + + # Possible values are: + # full: Allow a small subset of html markup in notifications: + # bold + # italic + # strikethrough + # underline + # + # For a complete reference see + # . + # + # strip: This setting is provided for compatibility with some broken + # clients that send markup even though it's not enabled on the + # server. Dunst will try to strip the markup but the parsing is + # simplistic so using this option outside of matching rules for + # specific applications *IS GREATLY DISCOURAGED*. + # + # no: Disable markup parsing, incoming notifications will be treated as + # plain text. Dunst will not advertise that it has the body-markup + # capability if this is set as a global setting. + # + # It's important to note that markup inside the format option will be parsed + # regardless of what this is set to. + markup = full + + # The format of the message. Possible variables are: + # %a appname + # %s summary + # %b body + # %i iconname (including its path) + # %I iconname (without its path) + # %p progress value if set ([ 0%] to [100%]) or nothing + # %n progress value if set without any extra characters + # %% Literal % + # Markup is allowed + format = "%s\n%b" + + # Alignment of message text. + # Possible values are "left", "center" and "right". + alignment = left + + # Vertical alignment of message text and icon. + # Possible values are "top", "center" and "bottom". + vertical_alignment = center + + # Show age of message if message is older than show_age_threshold + # seconds. + # Set to -1 to disable. + show_age_threshold = 60 + + # Specify where to make an ellipsis in long lines. + # Possible values are "start", "middle" and "end". + ellipsize = middle + + # Ignore newlines '\n' in notifications. + ignore_newline = no + + # Stack together notifications with the same content + stack_duplicates = true + + # Hide the count of stacked notifications with the same content + hide_duplicate_count = false + + # Display indicators for URLs (U) and actions (A). + show_indicators = yes + + ### Icons ### + + # Align icons left/right/top/off + icon_position = left + + # Scale small icons up to this size, set to 0 to disable. Helpful + # for e.g. small files or high-dpi screens. In case of conflict, + # max_icon_size takes precedence over this. + min_icon_size = 32 + + # Scale larger icons down to this size, set to 0 to disable + max_icon_size = 128 + + # Paths to default icons. + icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ + + ### History ### + + # Should a notification popped up from history be sticky or timeout + # as if it would normally do. + sticky_history = yes + + # Maximum amount of notifications kept in history + history_length = 20 + + ### Misc/Advanced ### + + # dmenu path. + dmenu = /sbin/wofi --show dmenu dunst: + + # Browser for opening urls in context menu. + browser = /usr/bin/xdg-open + + # Always run rule-defined scripts, even if the notification is suppressed + always_run_script = true + + # Define the title of the windows spawned by dunst + title = Dunst + + # Define the class of the windows spawned by dunst + class = Dunst + + # Define the corner radius of the notification window + # in pixel size. If the radius is 0, you have no rounded + # corners. + # The radius will be automatically lowered if it exceeds half of the + # notification height to avoid clipping text and/or icons. + corner_radius = 0 + + # Ignore the dbus closeNotification message. + # Useful to enforce the timeout set by dunst configuration. Without this + # parameter, an application may close the notification sent before the + # user defined timeout. + ignore_dbusclose = false + + ### Wayland ### + # These settings are Wayland-specific. They have no effect when using X11 + + # Uncomment this if you want to let notications appear under fullscreen + # applications (default: overlay) + # layer = top + + # Set this to true to use X11 output on Wayland. + force_xwayland = false + + ### Legacy + + # Use the Xinerama extension instead of RandR for multi-monitor support. + # This setting is provided for compatibility with older nVidia drivers that + # do not support RandR and using it on systems that support RandR is highly + # discouraged. + # + # By enabling this setting dunst will not be able to detect when a monitor + # is connected or disconnected which might break follow mode if the screen + # layout changes. + force_xinerama = false + + ### mouse + + # Defines list of actions for each mouse event + # Possible values are: + # * none: Don't do anything. + # * do_action: Invoke the action determined by the action_name rule. If there is no + # such action, open the context menu. + # * open_url: If the notification has exactly one url, open it. If there are multiple + # ones, open the context menu. + # * close_current: Close current notification. + # * close_all: Close all notifications. + # * context: Open context menu for the notification. + # * context_all: Open context menu for all notifications. + # These values can be strung together for each mouse event, and + # will be executed in sequence. + mouse_left_click = close_current + mouse_right_click = do_action, close_current + +# Experimental features that may or may not work correctly. Do not expect them +# to have a consistent behaviour across releases. +[experimental] + # Calculate the dpi to use on a per-monitor basis. + # If this setting is enabled the Xft.dpi value will be ignored and instead + # dunst will attempt to calculate an appropriate dpi value for each monitor + # using the resolution and physical size. This might be useful in setups + # where there are multiple screens with very different dpi values. + per_monitor_dpi = false + + +[urgency_low] + # IMPORTANT: colors have to be defined in quotation marks. + # Otherwise the "#" and following would be interpreted as a comment. + background = "#000000" + foreground = "#888888" + timeout = 10 + # Icon for notifications with low urgency, uncomment to enable + #default_icon = /path/to/icon + +[urgency_normal] + background = "#000000" + foreground = "#ffffff" + timeout = 10 + # Icon for notifications with normal urgency, uncomment to enable + #default_icon = /path/to/icon + +[urgency_critical] + background = "#900000" + foreground = "#ffffff" + frame_color = "#ff0000" + timeout = 0 + # Icon for notifications with critical urgency, uncomment to enable + #default_icon = /path/to/icon + +# Every section that isn't one of the above is interpreted as a rules to +# override settings for certain messages. +# +# Messages can be matched by +# appname (discouraged, see desktop_entry) +# body +# category +# desktop_entry +# icon +# match_transient +# msg_urgency +# stack_tag +# summary +# +# and you can override the +# background +# foreground +# format +# frame_color +# fullscreen +# new_icon +# set_stack_tag +# set_transient +# set_category +# timeout +# urgency +# icon_position +# skip_display +# history_ignore +# action_name +# word_wrap +# ellipsize +# alignment +# hide_text +# +# Shell-like globbing will get expanded. +# +# Instead of the appname filter, it's recommended to use the desktop_entry filter. +# GLib based applications export their desktop-entry name. In comparison to the appname, +# the desktop-entry won't get localized. +# +# SCRIPTING +# You can specify a script that gets run when the rule matches by +# setting the "script" option. +# The script will be called as follows: +# script appname summary body icon urgency +# where urgency can be "LOW", "NORMAL" or "CRITICAL". +# +# NOTE: It might be helpful to run dunst -print in a terminal in order +# to find fitting options for rules. + +# Disable the transient hint so that idle_threshold cannot be bypassed from the +# client +#[transient_disable] +# match_transient = yes +# set_transient = no +# +# Make the handling of transient notifications more strict by making them not +# be placed in history. +#[transient_history_ignore] +# match_transient = yes +# history_ignore = yes + +# fullscreen values +# show: show the notifications, regardless if there is a fullscreen window opened +# delay: displays the new notification, if there is no fullscreen window active +# If the notification is already drawn, it won't get undrawn. +# pushback: same as delay, but when switching into fullscreen, the notification will get +# withdrawn from screen again and will get delayed like a new notification +#[fullscreen_delay_everything] +# fullscreen = delay +#[fullscreen_show_critical] +# msg_urgency = critical +# fullscreen = show + +#[espeak] +# summary = "*" +# script = dunst_espeak.sh + +#[script-test] +# summary = "*script*" +# script = dunst_test.sh + +#[ignore] +# # This notification will not be displayed +# summary = "foobar" +# skip_display = true + +#[history-ignore] +# # This notification will not be saved in history +# summary = "foobar" +# history_ignore = yes + +#[skip-display] +# # This notification will not be displayed, but will be included in the history +# summary = "foobar" +# skip_display = yes + +#[signed_on] +# appname = Pidgin +# summary = "*signed on*" +# urgency = low +# +#[signed_off] +# appname = Pidgin +# summary = *signed off* +# urgency = low +# +#[says] +# appname = Pidgin +# summary = *says* +# urgency = critical +# +#[twitter] +# appname = Pidgin +# summary = *twitter.com* +# urgency = normal +# +#[stack-volumes] +# appname = "some_volume_notifiers" +# set_stack_tag = "volume" +# + +# vi: ft=conf diff --git a/configs/dunst/scripts/actions b/configs/dunst/scripts/actions new file mode 100755 index 0000000..7f11306 --- /dev/null +++ b/configs/dunst/scripts/actions @@ -0,0 +1,27 @@ +#!/bin/bash + +reply_action () { + + echo "Eyyy" + +} +forward_action () { + echo "Sup" +} +handle_dismiss () { + echo "Dismiss" +} + +ACTION=$(dunstify --action="default,Reply" --action="forwardAction,Forward" "Message Received") + +case "$ACTION" in +"default") + reply_action + ;; +"forwardAction") + forward_action + ;; +"2") + handle_dismiss + ;; +esac diff --git a/configs/dunst/scripts/test b/configs/dunst/scripts/test new file mode 100755 index 0000000..78e39bf --- /dev/null +++ b/configs/dunst/scripts/test @@ -0,0 +1,12 @@ +#!/bin/sh + + +# Start +[ "$(dunstify --replace '999999999' --action 'cal,more' "$(date +'%I:%M %p')" "$(swaymsg --raw --type get_workspaces | jq --raw-output '.[] | "\(.focused)\(.name)\(.focused)"' | sed -e 's/^false//g' -e 's/false$//g' -e 's/^true//g' -e 's/true$/<\/u>/g' | tr '\n' ' ')")" = 'cal' ] && { + DAY=$(date +'%e') + + dunstify 'Calendar' "$(cal | sed -e "s/$DAY\b/$DAY<\/u>/g")" +} + + +exit 0 diff --git a/configs/mako/config b/configs/mako/config index 249b176..1f43f10 100644 --- a/configs/mako/config +++ b/configs/mako/config @@ -5,7 +5,7 @@ width=300 height=300 border-color=#000000 border-radius=2 -icons=0 +icons=1 max-icon-size=64 default-timeout=5000 ignore-timeout=1 @@ -14,6 +14,8 @@ text-color=#000000 margin=5 padding=0,20,20,10 border-size=5 +on-button-left=exec makoctl menu -n "$id" wofi --show dmenu 'Select action: ' +on-button-right=dismiss [urgency=low] border-size=0 @@ -32,3 +34,5 @@ default-timeout=0 [category=mpd] default-timeout=2000 group-by=category + +# vi: ft=config diff --git a/configs/nvim/lua/configs/dashboard.lua b/configs/nvim/lua/configs/dashboard.lua index bf87bf6..bbc8600 100644 --- a/configs/nvim/lua/configs/dashboard.lua +++ b/configs/nvim/lua/configs/dashboard.lua @@ -15,7 +15,7 @@ local dashboard = require("alpha.themes.dashboard") vim.opt.fillchars:append { eob = " " } -- Disable Status Line so that alpha dashboard look nice -vim.cmd [[ au User AlphaReady if winnr('$') == 1 | set laststatus=1 ]] +-- vim.cmd [[ au User AlphaReady if winnr('$') == 1 | set laststatus=1 ]] -- Custom Footer dashboard.section.footer.val = { diff --git a/configs/nvim/lua/configs/lsp.lua b/configs/nvim/lua/configs/lsp.lua index d2f18d2..52f1e5c 100644 --- a/configs/nvim/lua/configs/lsp.lua +++ b/configs/nvim/lua/configs/lsp.lua @@ -8,7 +8,23 @@ local runtime_path = vim.split(package.path, ";") table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?/init.lua") +local function on_attach(client, bufnr) + local cap = client.server_capabilities + + if (cap.documentFormattingProvider) then + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + callback = function() + vim.lsp.buf.format(); + end + }) + else + vim.notify("Lsp (" .. client.name .. ") doesnt support format") + end +end + lsp.sumneko_lua.setup { + on_attach = on_attach, settings = { Lua = { runtime = { @@ -39,6 +55,7 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true lsp.jsonls.setup { capabilities = capabilities, + on_attach = on_attach, settings = { json = { schemas = { @@ -62,20 +79,46 @@ lsp.jsonls.setup { } } -lsp.svelte.setup {} -lsp.tsserver.setup {} -lsp.html.setup {} -lsp.intelephense.setup {} -lsp.cssls.setup {} +lsp.svelte.setup { + on_attach = on_attach +} +lsp.tsserver.setup { + on_attach = on_attach +} +lsp.html.setup { + on_attach = on_attach +} +lsp.intelephense.setup { + on_attach = on_attach +} +lsp.cssls.setup { + on_attach = on_attach +} + +lsp.bashls.setup { + filetypes = { "sh", "bash" }, + on_attach = on_attach +} + +-- lsp.remark_ls.setup { +-- filetypes = { "markdown" }, +-- on_attach = on_attach +-- } lsp.ltex.setup { + on_attach = on_attach, cmd = { os.getenv("HOME") .. '/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin/ltex-ls' }, settings = { ltex = { disabledRules = { ['en-US'] = { 'PROFANITY' } }, dictionary = { - ['en-US'] = { 'perf', 'ci' }, + ['en-US'] = { 'perf', 'ci', 'neovim' }, }, + hiddenFalsePositives = { + 'neovim', + 'Neovim', + 'waybar' + } }, }, } diff --git a/configs/nvim/lua/configs/telescope.lua b/configs/nvim/lua/configs/telescope.lua index 16877ea..ce08221 100644 --- a/configs/nvim/lua/configs/telescope.lua +++ b/configs/nvim/lua/configs/telescope.lua @@ -1,5 +1,11 @@ local telescope = require("telescope") +local actions = require("telescope.actions") +local trouble = require("trouble.providers.telescope") +telescope.setup { + defaults = { + }, +} local default = { defaults = { vimgrep_arguments = { @@ -37,6 +43,10 @@ local default = { path_display = { "truncate" }, winblend = 0, border = {}, + mappings = { + i = { [""] = trouble.open_with_trouble }, + n = { [""] = trouble.open_with_trouble }, + }, borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, color_devicons = true, use_less = true, diff --git a/configs/nvim/lua/core/autocommands.lua b/configs/nvim/lua/core/autocommands.lua index 00d5d3c..08cb880 100644 --- a/configs/nvim/lua/core/autocommands.lua +++ b/configs/nvim/lua/core/autocommands.lua @@ -22,9 +22,3 @@ augroup SaveManualFolds au BufWinEnter ?* silent! loadview augroup END ]] - -vim.api.nvim_create_autocmd("BufWritePre", { - callback = function() - vim.lsp.buf.format(); - end -}) diff --git a/configs/nvim/lua/core/keymappings.lua b/configs/nvim/lua/core/keymappings.lua index d561c2b..d1bd4c4 100644 --- a/configs/nvim/lua/core/keymappings.lua +++ b/configs/nvim/lua/core/keymappings.lua @@ -31,6 +31,16 @@ map("n", "", "j", options) map("n", "", "k", options) map("n", "", "l", options) +map("n", "1", "1gt", options) +map("n", "2", "2gt", options) +map("n", "3", "3gt", options) +map("n", "4", "4gt", options) +map("n", "0", ":tablast", options) + +-- Handling Splits +map("n", "h", ":sp", remap) -- horizontal +map("n", "v", ":vs", remap) -- vertical + -- Browser like next/previous map("n", "", ":bprevious", options); map("n", "", ":bnext", options); @@ -43,8 +53,10 @@ map("v", "Y", '"+y', options) map("n", "k", "{", options) map("n", "j", "}", options) --- Don't accidently create macros when trying to quit -map('n', 'Q', 'q', {}) +-- I dont use macros at the moment, can disable this if i want to +map('v', 'Q', 'q', {}) +map('v', 'Q', 'q', {}) +map('n', 'q', '', {}) map('n', 'q', '', {}) -- Move lines vscode style @@ -79,6 +91,7 @@ map("n", "r", "lua require('rest-nvim').run()", options) -- Close on q map("n", "q", ":q", options) +map("n", "", ":qall", options) -- Open Nerdtree map("n", "", ":NvimTreeToggle", options) diff --git a/configs/nvim/lua/core/options.lua b/configs/nvim/lua/core/options.lua index 6eeb9a1..dbfd39b 100644 --- a/configs/nvim/lua/core/options.lua +++ b/configs/nvim/lua/core/options.lua @@ -39,7 +39,7 @@ set.virtualedit = "onemore" -- With This option you can move the cursor one char set.ignorecase = true -- ignores case when searching set.smartcase = true -- turns on case sensitive search when letters are capitalized set.termguicolors = true -- set term gui colors (most terminals support this) -set.laststatus = 2 -- Always display the status line +set.laststatus = 3 -- Always display the status line set.title = true -- Show current txt that you editing set.relativenumber = false -- Vim’s absolute, relative and hybrid line numbers set.cursorline = false -- Enable highlighting of the current line diff --git a/configs/nvim/lua/core/plugins.lua b/configs/nvim/lua/core/plugins.lua index 4c7954c..ce47567 100644 --- a/configs/nvim/lua/core/plugins.lua +++ b/configs/nvim/lua/core/plugins.lua @@ -71,6 +71,7 @@ return packer.startup(function(use) use "williamboman/nvim-lsp-installer" use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" } + -- More IDE like features use { 'rmagatti/session-lens', requires = { 'rmagatti/auto-session', 'nvim-telescope/telescope.nvim' }, @@ -78,6 +79,7 @@ return packer.startup(function(use) require('session-lens').setup({ path_display = { 'shorten' } }) end } + use { "rcarriga/vim-ultest", requires = { "vim-test/vim-test" }, run = ":UpdateRemotePlugins" } -- Database Feature use "tpope/vim-dadbod" diff --git a/configs/nvim/lua/utils/init.lua b/configs/nvim/lua/utils/init.lua index 1fb1c3a..c706ae9 100644 --- a/configs/nvim/lua/utils/init.lua +++ b/configs/nvim/lua/utils/init.lua @@ -20,22 +20,11 @@ function M.ReloadConfig() dofile(vim.env.MYVIMRC) end -local function dump(o) - if type(o) == "table" then - local s = "{ " - for k, v in pairs(o) do - if type(k) ~= "number" then - k = '"' .. k .. '"' - end - s = s .. "[" .. k .. "] = " .. dump(v) .. "," - end - return s .. "} " - else - return tostring(o) - end -end +local inspect = require("inspect") -M.dump = dump +function M.dump(o) + print(inspect.inspect(o)) +end function M.has_plugin(pluginName) local status = pcall(require, pluginName) diff --git a/configs/nvim/lua/utils/inspect.lua b/configs/nvim/lua/utils/inspect.lua new file mode 100644 index 0000000..f8d69dc --- /dev/null +++ b/configs/nvim/lua/utils/inspect.lua @@ -0,0 +1,337 @@ +local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table +local inspect = {Options = {}, } + + + + + + + + + + + + + + + + + +inspect._VERSION = 'inspect.lua 3.1.0' +inspect._URL = 'http://github.com/kikito/inspect.lua' +inspect._DESCRIPTION = 'human-readable representations of tables' +inspect._LICENSE = [[ + MIT LICENSE + + Copyright (c) 2022 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. +]] +inspect.KEY = setmetatable({}, { __tostring = function() return 'inspect.KEY' end }) +inspect.METATABLE = setmetatable({}, { __tostring = function() return 'inspect.METATABLE' end }) + +local tostring = tostring +local rep = string.rep +local match = string.match +local char = string.char +local gsub = string.gsub +local fmt = string.format + +local function rawpairs(t) + return next, t, nil +end + + + +local function smartQuote(str) + if match(str, '"') and not match(str, "'") then + return "'" .. str .. "'" + end + return '"' .. gsub(str, '"', '\\"') .. '"' +end + + +local shortControlCharEscapes = { + ["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", + ["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127", +} +local longControlCharEscapes = { ["\127"] = "\127" } +for i = 0, 31 do + local ch = char(i) + if not shortControlCharEscapes[ch] then + shortControlCharEscapes[ch] = "\\" .. i + longControlCharEscapes[ch] = fmt("\\%03d", i) + end +end + +local function escape(str) + return (gsub(gsub(gsub(str, "\\", "\\\\"), + "(%c)%f[0-9]", longControlCharEscapes), + "%c", shortControlCharEscapes)) +end + +local function isIdentifier(str) + return type(str) == "string" and not not str:match("^[_%a][_%a%d]*$") +end + +local flr = math.floor +local function isSequenceKey(k, sequenceLength) + return type(k) == "number" and + flr(k) == k and + 1 <= (k) and + k <= sequenceLength +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) + + + if ta == tb and (ta == 'string' or ta == 'number') then + return (a) < (b) + end + + local dta = defaultTypeOrders[ta] or 100 + local dtb = defaultTypeOrders[tb] or 100 + + + return dta == dtb and ta < tb or dta < dtb +end + +local function getKeys(t) + + local seqLen = 1 + while rawget(t, seqLen) ~= nil do + seqLen = seqLen + 1 + end + seqLen = seqLen - 1 + + local keys, keysLen = {}, 0 + for k in rawpairs(t) do + if not isSequenceKey(k, seqLen) then + keysLen = keysLen + 1 + keys[keysLen] = k + end + end + table.sort(keys, sortKeys) + return keys, keysLen, seqLen +end + +local function countCycles(x, cycles) + if type(x) == "table" then + if cycles[x] then + cycles[x] = cycles[x] + 1 + else + cycles[x] = 1 + for k, v in rawpairs(x) do + countCycles(k, cycles) + countCycles(v, cycles) + end + countCycles(getmetatable(x), cycles) + end + end +end + +local function makePath(path, a, b) + local newPath = {} + local len = #path + for i = 1, len do newPath[i] = path[i] end + + newPath[len + 1] = a + newPath[len + 2] = b + + 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 + setmetatable(processedCopy, mt) + processed = processedCopy + end + return processed +end + +local function puts(buf, str) + buf.n = buf.n + 1 + buf[buf.n] = str +end + + + +local Inspector = {} + + + + + + + + + + +local Inspector_mt = { __index = Inspector } + +local function tabify(inspector) + puts(inspector.buf, inspector.newline .. rep(inspector.indent, inspector.level)) +end + +function Inspector:getId(v) + local id = self.ids[v] + local ids = self.ids + if not id then + local tv = type(v) + id = (ids[tv] or 0) + 1 + ids[v], ids[tv] = id, id + end + return tostring(id) +end + +function Inspector:putValue(v) + local buf = self.buf + local tv = type(v) + if tv == 'string' then + puts(buf, smartQuote(escape(v))) + elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or + tv == 'cdata' or tv == 'ctype' then + puts(buf, tostring(v)) + elseif tv == 'table' and not self.ids[v] then + local t = v + + if t == inspect.KEY or t == inspect.METATABLE then + puts(buf, tostring(t)) + elseif self.level >= self.depth then + puts(buf, '{...}') + else + if self.cycles[t] > 1 then puts(buf, fmt('<%d>', self:getId(t))) end + + local keys, keysLen, seqLen = getKeys(t) + + puts(buf, '{') + self.level = self.level + 1 + + for i = 1, seqLen + keysLen do + if i > 1 then puts(buf, ',') end + if i <= seqLen then + puts(buf, ' ') + self:putValue(t[i]) + else + local k = keys[i - seqLen] + tabify(self) + if isIdentifier(k) then + puts(buf, k) + else + puts(buf, "[") + self:putValue(k) + puts(buf, "]") + end + puts(buf, ' = ') + self:putValue(t[k]) + end + end + + local mt = getmetatable(t) + if type(mt) == 'table' then + if seqLen + keysLen > 0 then puts(buf, ',') end + tabify(self) + puts(buf, ' = ') + self:putValue(mt) + end + + self.level = self.level - 1 + + if keysLen > 0 or type(mt) == 'table' then + tabify(self) + elseif seqLen > 0 then + puts(buf, ' ') + end + + puts(buf, '}') + end + + else + puts(buf, fmt('<%s %d>', 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 cycles = {} + countCycles(root, cycles) + + local inspector = setmetatable({ + buf = { n = 0 }, + ids = {}, + cycles = cycles, + depth = depth, + level = 0, + newline = newline, + indent = indent, + }, Inspector_mt) + + inspector:putValue(root) + + return table.concat(inspector.buf) +end + +setmetatable(inspect, { + __call = function(_, root, options) + return inspect.inspect(root, options) + end, +}) + +return inspect diff --git a/configs/sway/config b/configs/sway/config index 02d7e66..42c0274 100644 --- a/configs/sway/config +++ b/configs/sway/config @@ -1,4 +1,4 @@ -# vim: ft=swayconfig +# vim: ft=config # Default config for sway # @@ -319,11 +319,11 @@ mode "resize" { bindsym $mod+r mode "resize" # Handles notifications -exec_always mako +exec_always dunst # Start Audio # exec_always pulseaudio --start # Handle Authentiction requests -exec_always lxpolkit +exec_always /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 exec_always clipman # Dimms the screen exec_always wlsunset -l 39.47 -L -0.3821346 diff --git a/configs/waybar/config b/configs/waybar/config index 9597fbc..25ae3f4 100644 --- a/configs/waybar/config +++ b/configs/waybar/config @@ -14,6 +14,7 @@ "sway/mode" ], "modules-right": [ + "custom/power-profile", "custom/dpi", "custom/theme", "pulseaudio", @@ -28,12 +29,17 @@ "custom/theme": { "exec": "~/.config/waybar/scripts/toggle-theme", "on-click": "~/.config/waybar/scripts/toggle-theme --toggle", - "restart-interval": 1 + "restart-interval": 2 + }, + "custom/power-profile": { + "exec": "~/.config/waybar/scripts/power-profile", + "on-click": "~/.config/waybar/scripts/power-profile --toggle", + "restart-interval": 2 }, "custom/dpi": { "exec": "~/.config/waybar/scripts/toggle-hdpi", "on-click": "~/.config/waybar/scripts/toggle-hdpi --toggle", - "restart-interval": 1 + "restart-interval": 2 }, "sway/mode": { "format": "{}" @@ -107,3 +113,4 @@ "escape": true } } +// vi: ft=jsonc diff --git a/configs/waybar/scripts/power-profile b/configs/waybar/scripts/power-profile new file mode 100755 index 0000000..e2fc70f --- /dev/null +++ b/configs/waybar/scripts/power-profile @@ -0,0 +1,25 @@ +#!/bin/bash +CURRENT=$(powerprofilesctl get) + +LOW="🐢" +BALANCED="☯️" +HIGH="⚡" + +if [ "$CURRENT" = 'power-saver' ]; then + if [ "$1" = "--toggle" ]; then + powerprofilesctl set balanced + fi + echo $LOW +elif [ "$CURRENT" = 'balanced' ]; then + if [ "$1" = "--toggle" ]; then + powerprofilesctl set performance + fi + echo $BALANCED +elif [ "$CURRENT" = 'performance' ]; then + if [ "$1" = "--toggle" ]; then + powerprofilesctl set power-saver + fi + echo $HIGH +fi + + diff --git a/configs/waybar/scripts/set-theme b/configs/waybar/scripts/set-theme index 5f92654..9ef2651 100755 --- a/configs/waybar/scripts/set-theme +++ b/configs/waybar/scripts/set-theme @@ -169,7 +169,7 @@ esac # these two appear to be completely equivalent: dconf write /org/gnome/desktop/interface/gtk-theme "'$new_gtk_theme'" - #gsettings set org.gnome.desktop.interface gtk-theme $new_gtk_theme + gsettings set org.gnome.desktop.interface gtk-theme $new_gtk_theme dconf write /org/gnome/desktop/interface/icon-theme "'$new_icon_theme'" dconf write /org/gnome/desktop/interface/cursor-theme "'$new_cursor_theme'"