diff --git a/.gitignore b/.gitignore index 020a0a24..80249fc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -.netrwhist *.swp .python-version .DS_Store __pycache__ -.luarc.json diff --git a/Makefile b/Makefile index b069f825..95af30ed 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,33 @@ $(eval HOSTNAME=$(shell hostname)) -CONFIG_REPO := git@gitlab.com:elitherl/nixos.git -HOMEMANAGER_CONFIG := $(PWD)/home/$(HOSTNAME)-$(USER).nix +NIXOS_REPO := git@git.xenia.me.uk:xenia/nixos.git +NVIM_REPO := git@git.xenia.me.uk:xenia/nvim.git +HOMEMANAGER_CONFIG := $(PWD)/home/$(HOSTNAME)/$(USER).nix CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config) BIN_DIR := $(HOME)/.local/bin HOMEMANAGER_CONFIG_DIR := $(CONFIG_DIR)/home-manager -.PHONY: default all clean nixos home legacy lclean +.PHONY: default all clean nixos home nvim default: [ -e /etc/nixos/ ] && make nixos || make home -all: install nixos home +all: default nvim clean: - rm -rf $(HOME)/.local/share/nvim - rm -rf $(HOME)/.local/state/nvim [ -e $(HOMEMANAGER_CONFIG_DIR) ] && rm -rf $(HOMEMANAGER_CONFIG_DIR) -/nix: - command -v nix > /dev/null && echo "Nix already installed" || ./scripts/installers/nix.sh --daemon - -/etc/nixos/config: - sudo git clone $(CONFIG_REPO) /etc/nixos/config - nixos: /etc/nixos/config home: $(HOMEMANAGER_CONFIG_DIR)/home.nix +nvim: $(CONFIG_DIR)/nvim + +/nix: + command -v nix > /dev/null || echo "Install nix package manager before continuing"; exit 1 + +/etc/nixos/config: + sudo git clone $(NIXOS_REPO) $@ + $(HOMEMANAGER_CONFIG_DIR)/home.nix: $(HOMEMANAGER_CONFIG_DIR) /nix [ -f $(HOMEMANAGER_CONFIG) ] || touch $(HOMEMANAGER_CONFIG) ln -s $(HOMEMANAGER_CONFIG) $@ @@ -34,18 +35,5 @@ $(HOMEMANAGER_CONFIG_DIR)/home.nix: $(HOMEMANAGER_CONFIG_DIR) /nix $(CONFIG_DIR) $(HOMEMANAGER_CONFIG_DIR) $(BIN_DIR): mkdir -p $@ -legacy: $(CONFIG_DIR) $(BIN_DIR) - fc-list | grep -iE "(fira.*code)*(nerd.*font)" > /dev/null || ./scripts/installers/firacode.sh && fc-cache - command -v nvim > /dev/null || ./scripts/installers/nvim.sh - [ -e $(CONFIG_DIR)/nvim ] || ln -s $(PWD)/home/tui/config/nvim $(CONFIG_DIR)/ - command -v starship > /dev/null || ./scripts/installers/starship.sh --yes --bin-dir $(BIN_DIR) - [ -e $(CONFIG_DIR)/starship.toml ] || ln -s $(PWD)/home/env/config/starship.toml $(CONFIG_DIR)/ - command -v direnv > /dev/null || bin_path="$(BIN_DIR)" ./scripts/installers/direnv.sh - -lclean: clean - [ -e $(HOME)/.fonts/FiraCode ] && rm -rf $(HOME)/.fonts/FiraCode - [ -e $(BIN_DIR)/nvim ] && rm $(BIN_DIR)/nvim - [ -e $(CONFIG_DIR)/nvim ] && rm $(CONFIG_DIR)/nvim - [ -e $(BIN_DIR)/starship ] && rm $(BIN_DIR)/starship - [ -e $(CONFIG_DIR)/starship.toml ] && rm $(CONFIG_DIR)/starship.toml - [ -e $(BIN_DIR)/direnv ] && rm $(BIN_DIR)/direnv +$(CONFIG_DIR)/nvim: $(CONFIG_DIR) + git clone $(NVIM_REPO) $@ diff --git a/home/tui/config/nvim/init.lua b/home/tui/config/nvim/init.lua deleted file mode 100644 index 93ee5214..00000000 --- a/home/tui/config/nvim/init.lua +++ /dev/null @@ -1,78 +0,0 @@ -vim.g.mapleader = " " - --- bootstrap lazy.nvim -local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system { - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - } -end -vim.opt.rtp:prepend(lazypath) -require("lazy").setup { - root = vim.fn.stdpath "data" .. "/lazy", - spec = "plugins", - lockfile = vim.fn.stdpath "data" .. "/lazy-lock.json", - dev = { path = "~/Projects/lua/nvim" }, - install = { colorscheme = { "catppuccin" } }, - ui = { - border = "rounded", - icons = { lazy = " " }, - }, - diff = { cmd = "diffview.nvim" }, - checker = { enabled = true, frequency = 3600 }, - performance = { - rtp = { - disabled_plugins = { - "gzip", - "matchit", - "matchparen", - "netrwPlugin", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, - }, - }, -} - --- Set vim options -vim.opt.laststatus = 3 -vim.opt.showtabline = 1 -vim.opt.shiftwidth = 4 -vim.opt.expandtab = true -vim.opt.number = true -vim.opt.relativenumber = true -vim.opt.listchars = { lead = ".", trail = ".", tab = ">-" } -vim.opt.list = true -vim.opt.splitbelow = true -vim.opt.splitright = true - --- Global -vim.g.loaded_perl_provider = 0 - --- Common keymaps -vim.keymap.set("i", "jk", "") -vim.keymap.set("n", "l", "Lazy") - -vim.opt.winblend = 15 -vim.opt.pumblend = 15 - --- neovide -if vim.g.neovide then - vim.g.neovide_padding_top = 5 - vim.g.neovide_padding_bottom = 5 - vim.g.neovide_padding_left = 5 - vim.g.neovide_padding_right = 5 - - vim.g.neovide_floating_blur_amount_x = 2.0 - vim.g.neovide_floating_blur_amount_y = 2.0 - - vim.g.neovide_hide_mouse_when_typing = false - vim.g.neovide_remember_window_size = false -end diff --git a/home/tui/config/nvim/lua/lsp/attach.lua b/home/tui/config/nvim/lua/lsp/attach.lua deleted file mode 100644 index fa68929c..00000000 --- a/home/tui/config/nvim/lua/lsp/attach.lua +++ /dev/null @@ -1,27 +0,0 @@ --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer -local on_attach = function(client, bufnr) - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set("n", "gD", vim.lsp.buf.definition, bufopts) - vim.keymap.set("n", "gd", "Trouble lsp_definitions", bufopts) - vim.keymap.set("n", "gR", vim.lsp.buf.references, bufopts) - vim.keymap.set("n", "gr", "Trouble lsp_references", bufopts) - vim.keymap.set("n", "gI", vim.lsp.buf.implementation, bufopts) - vim.keymap.set("n", "gi", "Trouble lsp_implementations", bufopts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) - vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, bufopts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "i", require "lsp.formatting", bufopts) - if client.server_capabilities.documentSymbolProvider then - require("nvim-navic").attach(client, bufnr) - require("nvim-navbuddy").attach(client, bufnr) - end -end -return on_attach diff --git a/home/tui/config/nvim/lua/lsp/cmp.lua b/home/tui/config/nvim/lua/lsp/cmp.lua deleted file mode 100644 index 97f34750..00000000 --- a/home/tui/config/nvim/lua/lsp/cmp.lua +++ /dev/null @@ -1,98 +0,0 @@ -local cmp = require "cmp" -local luasnip = require "luasnip" -local cmp_autopairs = require "nvim-autopairs.completion.cmp" - -require("luasnip.loaders.from_vscode").lazy_load() - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = cmp.mapping.preset.insert { - [""] = cmp.mapping.scroll_docs(-4), -- Up - [""] = cmp.mapping.scroll_docs(4), -- Down - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - }, -} - --- Set configuration for specific filetype. -cmp.setup.filetype("python", { - sources = { - { name = "nvim_lsp" }, - }, -}) - -cmp.setup.filetype("nix", { - sources = { - { name = "nvim_lsp" }, - }, -}) - -cmp.setup.filetype("gitcommit", { - sources = { - { name = "nvim_lsp" }, - { name = "git" }, - { name = "spell" }, - { name = "commit" }, - { name = "buffer" }, - { name = "luasnip" }, - { name = "latex_symbols" }, - }, -}) - -cmp.setup.filetype("markdown", { - sources = { - { name = "nvim_lsp" }, - { name = "spell" }, - { name = "buffer" }, - { name = "luasnip" }, - { name = "latex_symbols" }, - }, -}) - -cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "nvim_lsp" }, - { name = "buffer" }, - }, -}) - -cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "nvim_lsp" }, - { name = "path" }, - { name = "cmdline" }, - }, -}) - -cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) diff --git a/home/tui/config/nvim/lua/lsp/config.lua b/home/tui/config/nvim/lua/lsp/config.lua deleted file mode 100644 index c4a43192..00000000 --- a/home/tui/config/nvim/lua/lsp/config.lua +++ /dev/null @@ -1,39 +0,0 @@ -local M = {} - --- Mappings. --- See `:help vim.diagnostic.*` for documentation on any of the below functions -local opts = { noremap = true, silent = true } -vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) -vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) - -local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } -for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) -end - -require("neodev").setup() - -M.on_attach = require "lsp.attach" -M.lsp_flags = require "lsp.flags" -M.capabilities = require("cmp_nvim_lsp").default_capabilities() - -local servers = { "jedi_language_server", "lua_ls", "rnix", "nil_ls", "fortls" } -for _, name in ipairs(servers) do - require("lspconfig")[name].setup { - on_attach = M.on_attach, - flags = M.lsp_flags, - capabilities = M.capabilities, - } -end - -require("null-ls").setup { - sources = require "lsp.null_ls_sources", - on_attach = M.on_attach, - flags = M.lsp_flags, - capabilities = M.capabilities, -} - -return M diff --git a/home/tui/config/nvim/lua/lsp/flags.lua b/home/tui/config/nvim/lua/lsp/flags.lua deleted file mode 100644 index 3f61fcac..00000000 --- a/home/tui/config/nvim/lua/lsp/flags.lua +++ /dev/null @@ -1,5 +0,0 @@ -local lsp_flags = { - -- This is the default in Nvim 0.7+ - debounce_text_changes = 150, -} -return lsp_flags diff --git a/home/tui/config/nvim/lua/lsp/formatting.lua b/home/tui/config/nvim/lua/lsp/formatting.lua deleted file mode 100644 index 796a682e..00000000 --- a/home/tui/config/nvim/lua/lsp/formatting.lua +++ /dev/null @@ -1,11 +0,0 @@ -local lsp_formatting = function(bufnr) - vim.lsp.buf.format { - bufnr = bufnr, - timeout_ms = 2000, - async = true, - filter = function(client) - return client.name ~= "jedi_language_server" and client.name ~= "lua_ls" - end, - } -end -return lsp_formatting diff --git a/home/tui/config/nvim/lua/lsp/null_ls_sources.lua b/home/tui/config/nvim/lua/lsp/null_ls_sources.lua deleted file mode 100644 index a3a5fbf9..00000000 --- a/home/tui/config/nvim/lua/lsp/null_ls_sources.lua +++ /dev/null @@ -1,13 +0,0 @@ -local null_ls = require "null-ls" -return { - null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.diagnostics.zsh, - null_ls.builtins.diagnostics.mypy, - null_ls.builtins.diagnostics.ruff, - null_ls.builtins.formatting.black, - null_ls.builtins.formatting.isort, - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.trim_whitespace, - null_ls.builtins.hover.dictionary, -} diff --git a/home/tui/config/nvim/lua/plugins/alpha.lua b/home/tui/config/nvim/lua/plugins/alpha.lua deleted file mode 100644 index 4de8e5be..00000000 --- a/home/tui/config/nvim/lua/plugins/alpha.lua +++ /dev/null @@ -1,58 +0,0 @@ -return { - "goolord/alpha-nvim", - event = "VimEnter", - opts = function() - local dashboard = require "alpha.themes.dashboard" - local logo = [[ - ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z - ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z - ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z - ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z - ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ - ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ - ]] - - dashboard.section.header.val = vim.split(logo, "\n") - dashboard.section.buttons.val = { - dashboard.button("f", " " .. " Find file", ":Telescope find_files "), - dashboard.button("e", " " .. " Edit new file", ":ene startinsert "), - dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), - dashboard.button("n", "󱏒 " .. " Neotree", ":Neotree left "), - dashboard.button("g", "󰊢 " .. " Git status", ":Neogit "), - dashboard.button("c", " " .. " Config", ":e $MYVIMRC "), - dashboard.button("l", "󰒲 " .. " Lazy", ":Lazy"), - dashboard.button("q", " " .. " Quit", ":qa"), - } - for _, button in ipairs(dashboard.section.buttons.val) do - button.opts.hl = "AlphaButtons" - button.opts.hl_shortcut = "AlphaShortcut" - end - dashboard.section.header.opts.hl = "AlphaHeader" - dashboard.section.buttons.opts.hl = "AlphaButtons" - dashboard.section.footer.opts.hl = "AlphaFooter" - dashboard.opts.layout[1].val = 8 - return dashboard - end, - config = function(_, dashboard) - -- close Lazy and re-open when the dashboard is ready - if vim.o.filetype == "lazy" then - vim.cmd.close() - vim.api.nvim_create_autocmd("User", { - pattern = "AlphaReady", - callback = function() require("lazy").show() end, - }) - end - - require("alpha").setup(dashboard.opts) - - vim.api.nvim_create_autocmd("User", { - pattern = "LazyVimStarted", - callback = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - dashboard.section.footer.val = "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" - pcall(vim.cmd.AlphaRedraw) - end, - }) - end, -} diff --git a/home/tui/config/nvim/lua/plugins/catppuccin.lua b/home/tui/config/nvim/lua/plugins/catppuccin.lua deleted file mode 100644 index e6c1ab8a..00000000 --- a/home/tui/config/nvim/lua/plugins/catppuccin.lua +++ /dev/null @@ -1,48 +0,0 @@ -local config = { - flavour = "macchiato", - term_colors = true, - transparent_background = true, - integrations = { - alpha = true, - gitsigns = true, - hop = true, - indent_blankline = { - enabled = true, - colored_indent_levels = true, - }, - cmp = true, - markdown = true, - mini = true, - native_lsp = { - enabled = true, - }, - neogit = true, - neotree = true, - noice = true, - notify = true, - navic = { - enabled = true, - custom_bg = "NONE", - }, - treesitter = true, - treesitter_context = true, - telescope = true, - lsp_trouble = true, - which_key = true, - }, -} - -return { - "catppuccin/nvim", - name = "catppuccin", - lazy = false, - priority = 1000, - init = function() - vim.opt.termguicolors = true - require "ui.fillchars" - end, - config = function() - require("catppuccin").setup(config) - vim.cmd.colorscheme "catppuccin" - end, -} diff --git a/home/tui/config/nvim/lua/plugins/comment.lua b/home/tui/config/nvim/lua/plugins/comment.lua deleted file mode 100644 index babc58bd..00000000 --- a/home/tui/config/nvim/lua/plugins/comment.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "numToStr/Comment.nvim", - keys = { "gcc", "gcb" }, - event = { "BufReadPre" }, - config = true, - opts = { ignore = "^$" }, -} diff --git a/home/tui/config/nvim/lua/plugins/diffview.lua b/home/tui/config/nvim/lua/plugins/diffview.lua deleted file mode 100644 index 7e9ea049..00000000 --- a/home/tui/config/nvim/lua/plugins/diffview.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - "sindrets/diffview.nvim", - dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, - cmd = { - "DiffviewFileHistory", - "DiffviewOpen", - }, - config = true, - opts = { - enhanced_diff_hl = true, - file_panel = { - listing_style = "list", - }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/direnv.lua b/home/tui/config/nvim/lua/plugins/direnv.lua deleted file mode 100644 index a15276b1..00000000 --- a/home/tui/config/nvim/lua/plugins/direnv.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "https://github.com/direnv/direnv.vim.git", - name = "direnv.vim", - lazy = false, - config = function() - vim.g.direnv_auto = 1 - vim.g.direnv_silent_load = 1 - end, -} diff --git a/home/tui/config/nvim/lua/plugins/dressing.lua b/home/tui/config/nvim/lua/plugins/dressing.lua deleted file mode 100644 index d19febdb..00000000 --- a/home/tui/config/nvim/lua/plugins/dressing.lua +++ /dev/null @@ -1 +0,0 @@ -return { "stevearc/dressing.nvim", event = "VeryLazy" } diff --git a/home/tui/config/nvim/lua/plugins/gitsigns.lua b/home/tui/config/nvim/lua/plugins/gitsigns.lua deleted file mode 100644 index e25d158d..00000000 --- a/home/tui/config/nvim/lua/plugins/gitsigns.lua +++ /dev/null @@ -1,50 +0,0 @@ -return { - "lewis6991/gitsigns.nvim", - event = { "BufReadPre", "BufNewFile" }, - config = true, - opts = { - signcolumn = true, - numhl = true, - linehl = false, - current_line_blame = true, - word_diff = false, - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map("n", "]c", function() - if vim.wo.diff then return "]c" end - vim.schedule(function() gs.next_hunk() end) - return "" - end, { expr = true }) - - map("n", "[c", function() - if vim.wo.diff then return "[c" end - vim.schedule(function() gs.prev_hunk() end) - return "" - end, { expr = true }) - - -- Actions - map({ "n", "v" }, "hs", ":Gitsigns stage_hunk") - map({ "n", "v" }, "hr", ":Gitsigns reset_hunk") - map("n", "hS", gs.stage_buffer) - map("n", "hu", gs.undo_stage_hunk) - map("n", "hR", gs.reset_buffer) - map("n", "hp", gs.preview_hunk) - map("n", "hb", function() gs.blame_line { full = true } end) - map("n", "tb", gs.toggle_current_line_blame) - map("n", "hd", gs.diffthis) - map("n", "hD", function() gs.diffthis "~" end) - map("n", "td", gs.toggle_deleted) - - -- Text object - map({ "o", "x" }, "ih", ":Gitsigns select_hunk") - end, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/hop.lua b/home/tui/config/nvim/lua/plugins/hop.lua deleted file mode 100644 index daf94913..00000000 --- a/home/tui/config/nvim/lua/plugins/hop.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "phaazon/hop.nvim", - cmd = { "HopWord", "HopLine" }, - init = function() - vim.keymap.set("n", "hw", "HopWord") - vim.keymap.set("n", "hl", "HopLine") - end, - config = true, -} diff --git a/home/tui/config/nvim/lua/plugins/indent_blankline.lua b/home/tui/config/nvim/lua/plugins/indent_blankline.lua deleted file mode 100644 index 943c4ed3..00000000 --- a/home/tui/config/nvim/lua/plugins/indent_blankline.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "lukas-reineke/indent-blankline.nvim", - event = { "BufReadPre", "BufNewFile" }, - config = true, - opts = { - show_current_context = true, - show_current_context_start = false, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/init.lua b/home/tui/config/nvim/lua/plugins/init.lua deleted file mode 100644 index 83c7a0a7..00000000 --- a/home/tui/config/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - { "folke/lazy.nvim", cmd = "Lazy" }, -} diff --git a/home/tui/config/nvim/lua/plugins/lspconfig.lua b/home/tui/config/nvim/lua/plugins/lspconfig.lua deleted file mode 100644 index 656c1124..00000000 --- a/home/tui/config/nvim/lua/plugins/lspconfig.lua +++ /dev/null @@ -1,25 +0,0 @@ -return { - "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile", "BufEnter" }, - cmd = { - "LspLog", - "LspStop", - "LspStart", - "LspRestart", - "LspInfo", - }, - dependencies = { - { "hrsh7th/nvim-cmp" }, - { "rafamadriz/friendly-snippets" }, - { "windwp/nvim-autopairs" }, - { "jose-elias-alvarez/null-ls.nvim", lazy = true }, - { "mfussenegger/nvim-dap", lazy = true }, - { "folke/neodev.nvim", dependencies = { "hrsh7th/nvim-cmp" }, lazy = true }, - { "SmiteshP/nvim-navic" }, - { "SmiteshP/nvim-navbuddy" }, - }, - config = function() - require "lsp.config" - require "lsp.cmp" - end, -} diff --git a/home/tui/config/nvim/lua/plugins/lualine.lua b/home/tui/config/nvim/lua/plugins/lualine.lua deleted file mode 100644 index 4c06b24c..00000000 --- a/home/tui/config/nvim/lua/plugins/lualine.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons", "SmiteshP/nvim-navic", "folke/noice.nvim" }, - event = { "BufEnter" }, - config = true, - opts = { - options = { - theme = "catppuccin", - component_separators = "|", - section_separators = { left = "", right = "" }, - globalstatus = true, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "filename", { "branch", icon = "󰊢" }, "diff" }, - lualine_c = { "diagnostics", "require('noice').api.status.lsp.get_hl()" }, - lualine_x = { "filetype", "fileformat", "encoding" }, - lualine_y = { "progress" }, - lualine_z = { "selectioncount", "location" }, - }, - tabline = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { "require('nvim-navic').get_location()" }, - lualine_x = { "windows" }, - lualine_y = {}, - lualine_z = {}, - }, - winbar = {}, - extensions = { "aerial", "fzf", "lazy", "neo-tree", "toggleterm", "trouble" }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/navigator.lua b/home/tui/config/nvim/lua/plugins/navigator.lua deleted file mode 100644 index b50ea4f0..00000000 --- a/home/tui/config/nvim/lua/plugins/navigator.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - "numToStr/Navigator.nvim", - cmd = { - "NavigatorUp", - "NavigatorDown", - "NavigatorLeft", - "NavigatorRight", - "NavigatorPrevious", - }, - init = function() - vim.keymap.set({ "n", "t" }, "", "NavigatorLeft") - vim.keymap.set({ "n", "t" }, "", "NavigatorRight") - vim.keymap.set({ "n", "t" }, "", "NavigatorUp") - vim.keymap.set({ "n", "t" }, "", "NavigatorDown") - vim.keymap.set({ "n", "t" }, "", "NavigatorPrevious") - end, - config = true, -} diff --git a/home/tui/config/nvim/lua/plugins/neogit.lua b/home/tui/config/nvim/lua/plugins/neogit.lua deleted file mode 100644 index 257bbb8a..00000000 --- a/home/tui/config/nvim/lua/plugins/neogit.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - "TimUntersberger/neogit", - dependencies = { - "nvim-lua/plenary.nvim", - "sindrets/diffview.nvim", - }, - cmd = "Neogit", - init = function() - vim.keymap.set("n", "gg", "Neogit") - vim.keymap.set("n", "cc", "Neogit commit") - vim.keymap.set("n", "gp", "Neogit pull") - vim.keymap.set("n", "gP", "Neogit push") - end, - config = true, - opts = { - disable_commit_confirmation = true, - disable_builtin_notifications = true, - -- kind = "floating", - -- commit_popup = { kind = "floating" }, - -- preview_buffer = { kind = "floating" }, - -- popup = { kind = "floating" }, - integrations = { diffview = true }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/neotree.lua b/home/tui/config/nvim/lua/plugins/neotree.lua deleted file mode 100644 index 3ddd8f60..00000000 --- a/home/tui/config/nvim/lua/plugins/neotree.lua +++ /dev/null @@ -1,48 +0,0 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - branch = "v2.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - cmd = "NeoTree", - event = { "BufEnter" }, - init = function() - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - vim.g.neo_tree_remove_legacy_commands = 1 - vim.keymap.set("n", "nn", "Neotree left reveal reveal_force_cwd") - vim.keymap.set("n", "nb", "Neotree toggle show buffers right") - end, - config = true, - opts = { - close_if_last_window = true, - use_popups_for_input = false, - filesystem = { - window = { - mappings = { - ["Z"] = "expand_all_nodes", - [""] = "toggle_node", - }, - }, - filtered_items = { - hide_dotfiles = false, - }, - group_empty_dirs = true, - hijack_netrw_behavior = "open_current", - }, - buffers = { - bind_to_cwd = true, - follow_current_file = true, - group_empty_dirs = true, - }, - git_status = { - group_empty_dirs = true, - }, - source_selector = { - winbar = true, - statusline = false, - }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/noice.lua b/home/tui/config/nvim/lua/plugins/noice.lua deleted file mode 100644 index 28dbfc64..00000000 --- a/home/tui/config/nvim/lua/plugins/noice.lua +++ /dev/null @@ -1,44 +0,0 @@ -return { - "folke/noice.nvim", - dependencies = { - "MunifTanjim/nui.nvim", - "rcarriga/nvim-notify", - }, - config = true, - opts = { - lsp = { - progress = { - enabled = true, - format = { - "({data.progress.percentage}%) ", - { "{spinner} ", hl_group = "NoiceLspProgressSpinner" }, - { "{data.progress.title} ", hl_group = "NoiceLspProgressTitle" }, - { "{data.progress.client} ", hl_group = "NoiceLspProgressClient" }, - }, - }, - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - views = { - mini = { - position = { row = -2 }, - border = { style = "rounded" }, - win_options = { winblend = 0 }, - }, - }, - status = { lsp = { event = "lsp", kind = "progress" } }, - routes = { { view = "mini", filter = { event = "lsp", kind = "progress" }, opts = { skip = true } } }, - -- you can enable a preset for easier configuration - presets = { - bottom_search = false, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = false, -- long messages will be sent to a splitnoice - inc_rename = true, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = true, -- add a border to hover docs and signature help - }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/notify.lua b/home/tui/config/nvim/lua/plugins/notify.lua deleted file mode 100644 index 30d58225..00000000 --- a/home/tui/config/nvim/lua/plugins/notify.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "rcarriga/nvim-notify", - config = true, - opts = { - background_colour = "#000000", - fps = 60, - render = "default", -- "minimal", "simple" - }, -} diff --git a/home/tui/config/nvim/lua/plugins/nvim-cmp.lua b/home/tui/config/nvim/lua/plugins/nvim-cmp.lua deleted file mode 100644 index 7c7e20e9..00000000 --- a/home/tui/config/nvim/lua/plugins/nvim-cmp.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - "hrsh7th/nvim-cmp", - dependencies = { - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-buffer" }, - { "hrsh7th/cmp-path" }, - { "hrsh7th/cmp-cmdline" }, - { "f3fora/cmp-spell" }, - { "petertriho/cmp-git" }, - { "Dosx001/cmp-commit" }, - { "kdheepak/cmp-latex-symbols" }, - { "L3MON4D3/LuaSnip" }, - { "saadparwaiz1/cmp_luasnip" }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/nvim_autopairs.lua b/home/tui/config/nvim/lua/plugins/nvim_autopairs.lua deleted file mode 100644 index 88626dcb..00000000 --- a/home/tui/config/nvim/lua/plugins/nvim_autopairs.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - "windwp/nvim-autopairs", - lazy = true, - dependencies = { - "nvim-treesitter/nvim-treesitter", - "hrsh7th/nvim-cmp", - }, - config = true, - opts = { - disable_in_macro = true, - disable_in_visualblock = true, - check_ts = true, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/nvim_navbuddy.lua b/home/tui/config/nvim/lua/plugins/nvim_navbuddy.lua deleted file mode 100644 index 8efa7572..00000000 --- a/home/tui/config/nvim/lua/plugins/nvim_navbuddy.lua +++ /dev/null @@ -1,27 +0,0 @@ -return { - "SmiteshP/nvim-navbuddy", - dependencies = { "SmiteshP/nvim-navic", "MunifTanjim/nui.nvim" }, - cmd = { "Navbuddy" }, - init = function() vim.keymap.set("n", "na", "Navbuddy") end, - config = true, - opts = { - icons = require "ui.navic_icons", - window = { - border = "none", - size = "80%", - sections = { - left = { border = "rounded" }, - mid = { border = "rounded" }, - right = { border = "rounded", preview = "leaf" }, - }, - }, - node_markers = { - enabled = true, - icons = { - leaf = " ", - leaf_selected = " → ", - branch = " ", - }, - }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/nvim_navic.lua b/home/tui/config/nvim/lua/plugins/nvim_navic.lua deleted file mode 100644 index 80e82267..00000000 --- a/home/tui/config/nvim/lua/plugins/nvim_navic.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "SmiteshP/nvim-navic", - dependencies = "neovim/nvim-lspconfig", - lazy = true, - config = true, - opts = { - safe_output = true, - click = true, - icons = require "ui.navic_icons", - }, -} diff --git a/home/tui/config/nvim/lua/plugins/nvim_test.lua b/home/tui/config/nvim/lua/plugins/nvim_test.lua deleted file mode 100644 index c54b3ea6..00000000 --- a/home/tui/config/nvim/lua/plugins/nvim_test.lua +++ /dev/null @@ -1,28 +0,0 @@ -return { - "klen/nvim-test", - cmd = { - "TestFile", - "TestEdit", - "TestNearest", - "TestLast", - "TestVisit", - "TestInfo", - "TestSuite", - }, - init = function() - vim.keymap.set("n", "ts", "TestSuite") - vim.keymap.set("n", "tf", "TestFile") - vim.keymap.set("n", "te", "TestEdit") - vim.keymap.set("n", "tn", "TestNearest") - vim.keymap.set("n", "tl", "TestLast") - vim.keymap.set("n", "tv", "TestVisit") - vim.keymap.set("n", "ti", "TestInfo") - end, - config = true, - otps = { - termOpts = { - direction = "horizontal", - keep_one = true, - }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/project.lua b/home/tui/config/nvim/lua/plugins/project.lua deleted file mode 100644 index 6e127ba5..00000000 --- a/home/tui/config/nvim/lua/plugins/project.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "ahmedkhalf/project.nvim", - name = "project_nvim", - event = { "BufEnter" }, - config = true, - opts = { - ignore_lsp = { "efm", "null-ls" }, - show_hidden = true, - silent_chdir = true, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/telescope.lua b/home/tui/config/nvim/lua/plugins/telescope.lua deleted file mode 100644 index f9b78b46..00000000 --- a/home/tui/config/nvim/lua/plugins/telescope.lua +++ /dev/null @@ -1,61 +0,0 @@ -return { - "nvim-telescope/telescope.nvim", - branch = "0.1.x", - dependencies = { - { - "nvim-lua/plenary.nvim", - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - { "tsakirist/telescope-lazy.nvim", dependencies = { "folke/lazy.nvim" } }, - "folke/noice.nvim", - { "benfowler/telescope-luasnip.nvim", dependencies = { "L3MON4D3/LuaSnip" } }, - { - "paopaol/telescope-git-diffs.nvim", - dependencies = { "nvim-lua/plenary.nvim", "sindrets/diffview.nvim" }, - }, - "FeiyouG/command_center.nvim", - { "barrett-ruth/telescope-http.nvim", dependencies = { "savq/paq-nvim" } }, - "aaronhallaert/advanced-git-search.nvim", - }, - }, - cmd = "Telescope", - init = function() - vim.keymap.set("n", ";", "Telescope builtin") - vim.keymap.set("n", "ff", "Telescope find_files") - vim.keymap.set("n", "fr", "Telescope oldfiles") - vim.keymap.set("n", "fg", "Telescope live_grep") - vim.keymap.set("n", "fb", "Telescope buffers") - vim.keymap.set("n", "fs", "Telescope lsp_document_symbols") - vim.keymap.set("n", "fe", "Telescope diagnostics") - vim.keymap.set("n", "ft", "Telescope treesitter") - vim.keymap.set("n", "fz", "Telescope current_buffer_fuzzy_find") - end, - config = function() - local trouble = require "trouble.providers.telescope" - require("telescope").setup { - defaults = { - layout_strategy = "flex", - mappings = { - i = { [""] = trouble.open_with_trouble }, - n = { [""] = trouble.open_with_trouble }, - }, - winblend = vim.o.winblend, - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - }, - }, - } - require("telescope").load_extension "fzf" - require("telescope").load_extension "lazy" - require("telescope").load_extension "noice" - require("telescope").load_extension "luasnip" - require("telescope").load_extension "git_diffs" - require("telescope").load_extension "command_center" - require("telescope").load_extension "http" - require("telescope").load_extension "advanced_git_search" - require("telescope").load_extension "projects" - end, -} diff --git a/home/tui/config/nvim/lua/plugins/toggleterm.lua b/home/tui/config/nvim/lua/plugins/toggleterm.lua deleted file mode 100644 index c2b8bccb..00000000 --- a/home/tui/config/nvim/lua/plugins/toggleterm.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "akinsho/toggleterm.nvim", - version = "*", - cmd = { "ToggleTerm" }, - init = function() vim.keymap.set("n", "tt", "ToggleTerm direction=horizontal") end, - config = true, -} diff --git a/home/tui/config/nvim/lua/plugins/treesitter.lua b/home/tui/config/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index e1fa4dc8..00000000 --- a/home/tui/config/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,51 +0,0 @@ -return { - "nvim-treesitter/nvim-treesitter", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { "nvim-treesitter/nvim-treesitter-refactor" }, - config = function(_, opts) - if type(opts.ensure_installed) == "table" then - -- @type table - local added = {} - opts.ensure_installed = vim.tbl_filter(function(lang) - if added[lang] then return false end - added[lang] = true - return true - end, opts.ensure_installed) - end - require("nvim-treesitter.configs").setup(opts) - end, - opts = { - ensure_installed = "all", - auto_install = true, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "gnr", - scope_incremental = "gnc", - node_decremental = "gnm", - }, - }, - indent = { - enable = true, - }, - refactor = { - smart_rename = { - enable = true, - keymaps = { - smart_rename = "grr", - }, - }, - navigation = { - enable = true, - keymaps = { - goto_definition_lsp_fallback = "gnd", - }, - }, - }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/trouble.lua b/home/tui/config/nvim/lua/plugins/trouble.lua deleted file mode 100644 index 46cc8088..00000000 --- a/home/tui/config/nvim/lua/plugins/trouble.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - "folke/trouble.nvim", - dependencies = "nvim-tree/nvim-web-devicons", - cmd = "TroubleToggle", - init = function() - vim.keymap.set("n", "xx", "TroubleToggle") - vim.keymap.set("n", "xw", "TroubleToggle workspace_diagnostics") - vim.keymap.set("n", "xd", "TroubleToggle document_diagnostics") - vim.keymap.set("n", "xq", "TroubleToggle quickfix") - vim.keymap.set("n", "xl", "TroubleToggle loclist") - end, - config = true, - opts = { - mode = "workspace_diagnostics", - auto_open = false, - auto_close = false, - auto_preview = true, - auto_jump = { "lsp_definitions", "lsp_references", "lsp_implementations" }, - }, -} diff --git a/home/tui/config/nvim/lua/plugins/twilight.lua b/home/tui/config/nvim/lua/plugins/twilight.lua deleted file mode 100644 index 2b317746..00000000 --- a/home/tui/config/nvim/lua/plugins/twilight.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "folke/twilight.nvim", - dependencies = { "nvim-treesitter" }, - cmd = "Twilight", - config = true, - opts = { context = 10, treesitter = true }, -} diff --git a/home/tui/config/nvim/lua/plugins/which_key.lua b/home/tui/config/nvim/lua/plugins/which_key.lua deleted file mode 100644 index 82b680d0..00000000 --- a/home/tui/config/nvim/lua/plugins/which_key.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "folke/which-key.nvim", - config = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - require("which-key").setup {} - end, -} diff --git a/home/tui/config/nvim/lua/plugins/zen_mode.lua b/home/tui/config/nvim/lua/plugins/zen_mode.lua deleted file mode 100644 index f661d667..00000000 --- a/home/tui/config/nvim/lua/plugins/zen_mode.lua +++ /dev/null @@ -1,30 +0,0 @@ -return { - "folke/zen-mode.nvim", - dependencies = { "folke/twilight.nvim" }, - cmd = { "ZenMode" }, - init = function() vim.keymap.set("n", "z", "ZenMode") end, - config = true, - opts = { - window = { - options = { - signcolumn = "no", -- disable signcolumn - number = false, -- disable number column - relativenumber = false, -- disable relative numbers - cursorline = false, -- disable cursorline - cursorcolumn = false, -- disable cursor column - foldcolumn = "0", -- disable fold column - list = false, -- disable whitespace characters - }, - }, - plugins = { - options = { - enabled = true, - }, - twilight = { enabled = true }, - gitsigns = { enabled = true }, - tmux = { enabled = true }, - }, - on_open = function(win) vim.wo.scrolloff = 999 end, - on_close = function(win) vim.wo.scrolloff = 0 end, - }, -} diff --git a/home/tui/config/nvim/lua/ui/feline_components.lua b/home/tui/config/nvim/lua/ui/feline_components.lua deleted file mode 100644 index efced01f..00000000 --- a/home/tui/config/nvim/lua/ui/feline_components.lua +++ /dev/null @@ -1,478 +0,0 @@ -local M = {} - -local C = require("catppuccin.palettes").get_palette() -local lsp = require "feline.providers.lsp" - -local assets = { - left_separator = "", - right_separator = "", - mode_icon = "", - dir = "", - file = "", - lsp = { - server = "", - error = "", - warning = "", - info = "", - hint = "", - }, - git = { - branch = "", - added = "", - changed = "", - removed = "", - }, -} - -local sett = { - text = C.surface0, - bkg = C.surface0, - diffs = C.mauve, - extras = C.overlay1, - curr_file = C.maroon, - curr_dir = C.flamingo, - show_modified = false, -} - -if require("catppuccin").flavour == "latte" then - local latte = require("catppuccin.palettes").get_palette "latte" - sett.text = latte.base - sett.bkg = latte.crust -end - -if require("catppuccin").options.transparent_background then sett.bkg = "NONE" end - -local mode_colors = { - ["n"] = { "NORMAL", C.lavender }, - ["no"] = { "N-PENDING", C.lavender }, - ["i"] = { "INSERT", C.green }, - ["ic"] = { "INSERT", C.green }, - ["t"] = { "TERMINAL", C.green }, - ["v"] = { "VISUAL", C.flamingo }, - ["V"] = { "V-LINE", C.flamingo }, - [""] = { "V-BLOCK", C.flamingo }, - ["R"] = { "REPLACE", C.maroon }, - ["Rv"] = { "V-REPLACE", C.maroon }, - ["s"] = { "SELECT", C.maroon }, - ["S"] = { "S-LINE", C.maroon }, - [""] = { "S-BLOCK", C.maroon }, - ["c"] = { "COMMAND", C.peach }, - ["cv"] = { "COMMAND", C.peach }, - ["ce"] = { "COMMAND", C.peach }, - ["r"] = { "PROMPT", C.teal }, - ["rm"] = { "MORE", C.teal }, - ["r?"] = { "CONFIRM", C.mauve }, - ["!"] = { "SHELL", C.green }, -} - -function M.setup(opts) - if opts then - opts.assets = opts.assets or {} - opts.sett = opts.sett or {} - opts.mode_colors = opts.mode_colors or {} - else - opts = {} - end - assets = vim.tbl_deep_extend("force", assets, opts.assets) - sett = vim.tbl_deep_extend("force", sett, opts.sett) - mode_colors = vim.tbl_deep_extend("force", mode_colors, opts.mode_colors) -end - -function M.get() - local shortline = false - - local components = { - active = { {}, {} }, -- left, right - inactive = { {} }, - } - - local function is_enabled(min_width) - if shortline then return true end - - return vim.api.nvim_win_get_width(0) > min_width - end - - -- global components - local invi_sep = { - str = " ", - hl = { - fg = sett.bkg, - bg = sett.bkg, - }, - } - - -- helpers - local function any_git_changes() - local gst = vim.b.gitsigns_status_dict -- git stats - if gst then - if - gst["added"] and gst["added"] > 0 - or gst["removed"] and gst["removed"] > 0 - or gst["changed"] and gst["changed"] > 0 - then - return true - end - end - return false - end - - -- #################### STATUSLINE -> - - -- ######## Left - - -- Current vi mode ------> - local vi_mode_hl = function() - return { - fg = sett.text, - bg = mode_colors[vim.fn.mode()][2], - style = "bold", - } - end - - components.active[1][1] = { - provider = " " .. assets.mode_icon .. " ", - hl = function() - return { - fg = sett.text, - bg = mode_colors[vim.fn.mode()][2], - } - end, - } - - components.active[1][2] = { - provider = function() return mode_colors[vim.fn.mode()][1] .. " " end, - hl = vi_mode_hl, - } - - -- there is a dilema: we need to hide Diffs if ther is no git info. We can do that, but this will - -- leave the right_separator colored with purple, and since we can't change the color conditonally - -- then the solution is to create two right_separators: one with a mauve sett.bkg and the other one normal - -- sett.bkg; both have the same fg (vi mode). The mauve one appears if there is git info, else the one with - -- the normal sett.bkg appears. Fixed :) - - -- enable if git diffs are not available - components.active[1][3] = { - provider = assets.right_separator, - hl = function() - return { - fg = mode_colors[vim.fn.mode()][2], - bg = sett.bkg, - } - end, - enabled = function() return not any_git_changes() end, - } - - -- enable if git diffs are available - components.active[1][4] = { - provider = assets.right_separator, - hl = function() - return { - fg = mode_colors[vim.fn.mode()][2], - bg = sett.diffs, - } - end, - enabled = function() return any_git_changes() end, - } - -- Current vi mode ------> - - -- Diffs ------> - components.active[1][5] = { - provider = "git_diff_added", - hl = { - fg = sett.text, - bg = sett.diffs, - }, - icon = " " .. assets.git.added .. " ", - } - - components.active[1][6] = { - provider = "git_diff_changed", - hl = { - fg = sett.text, - bg = sett.diffs, - }, - icon = " " .. assets.git.changed .. " ", - } - - components.active[1][7] = { - provider = "git_diff_removed", - hl = { - fg = sett.text, - bg = sett.diffs, - }, - icon = " " .. assets.git.removed .. " ", - } - - components.active[1][8] = { - provider = " ", - hl = { - fg = sett.bkg, - bg = sett.diffs, - }, - enabled = function() return any_git_changes() end, - } - - components.active[1][9] = { - provider = assets.right_separator, - hl = { - fg = sett.diffs, - bg = sett.bkg, - }, - enabled = function() return any_git_changes() end, - } - -- Diffs ------> - - -- Extras ------> - - -- file progess - components.active[1][10] = { - provider = function() - local current_line = vim.fn.line "." - local total_line = vim.fn.line "$" - - if current_line == 1 then - return "Top" - elseif current_line == vim.fn.line "$" then - return "Bot" - end - local result, _ = math.modf((current_line / total_line) * 100) - return result .. "%%" - end, - -- enabled = shortline or function(winid) - -- return vim.api.nvim_win_get_width(winid) > 90 - -- end, - hl = { - fg = sett.extras, - bg = sett.bkg, - }, - left_sep = invi_sep, - } - - -- position - components.active[1][11] = { - provider = "position", - -- enabled = shortline or function(winid) - -- return vim.api.nvim_win_get_width(winid) > 90 - -- end, - hl = { - fg = sett.extras, - bg = sett.bkg, - }, - left_sep = invi_sep, - } - - -- macro - components.active[1][12] = { - provider = "macro", - enabled = function() return vim.api.nvim_get_option "cmdheight" == 0 end, - hl = { - fg = sett.extras, - bg = sett.bkg, - }, - left_sep = invi_sep, - } - - -- search count - components.active[1][13] = { - provider = "search_count", - enabled = function() return vim.api.nvim_get_option "cmdheight" == 0 end, - hl = { - fg = sett.extras, - bg = sett.bkg, - }, - left_sep = invi_sep, - } - -- Extras ------> - - -- ######## Left - -- treesitter position - -- components.active[1][14] = { - -- provider = function() - -- -- if not require("vim.treesitter.language").require_language("lua") then - -- -- return "" - -- -- end - -- local pos = require("nvim-treesitter").statusline { - -- indicator_size = 50, - -- transform_fn = function(line) return line:gsub("%s*[%[%(%{]+.*$", "") end, - -- } - -- if pos and pos ~= "" then return pos end - -- return "" - -- end, - -- hl = { - -- fg = sett.extras, - -- bg = sett.bkg, - -- }, - -- left_sep = invi_sep, - -- } - - -- ######## Right - - -- Diagnostics ------> - -- workspace loader - components.active[2][1] = { - provider = function() - local Lsp = vim.lsp.util.get_progress_messages()[1] - - if Lsp then - local msg = Lsp.message or "" - local percentage = Lsp.percentage - if not percentage then return "" end - local title = Lsp.title or "" - local spinners = { - "", - "", - "", - } - local success_icon = { - "", - "", - "", - } - local ms = vim.loop.hrtime() / 1000000 - local frame = math.floor(ms / 120) % #spinners - - if percentage >= 70 then - return string.format(" %%<%s %s %s (%s%%%%) ", success_icon[frame + 1], title, msg, percentage) - end - - return string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage) - end - - return "" - end, - enabled = is_enabled(80), - hl = { - fg = sett.extras, - bg = sett.bkg, - }, - right_sep = invi_sep, - } - - components.active[2][2] = { - provider = "git_branch", - enabled = is_enabled(70), - hl = { - fg = sett.extras, - bg = sett.bkg, - }, - icon = assets.git.branch .. " ", - right_sep = invi_sep, - } - - components.active[2][3] = { - provider = function() - if next(vim.lsp.buf_get_clients()) ~= nil then - return assets.lsp.server .. " " .. "Lsp" - else - return "" - end - end, - hl = { - fg = sett.extras, - bg = sett.bkg, - }, - right_sep = invi_sep, - } - - -- genral diagnostics (errors, warnings. info and hints) - components.active[2][4] = { - provider = "diagnostic_errors", - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.ERROR) end, - - hl = { - fg = C.red, - bg = sett.bkg, - }, - icon = " " .. assets.lsp.error .. " ", - right_sep = invi_sep, - } - - components.active[2][5] = { - provider = "diagnostic_warnings", - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.WARN) end, - hl = { - fg = C.yellow, - bg = sett.bkg, - }, - icon = " " .. assets.lsp.warning .. " ", - right_sep = invi_sep, - } - - components.active[2][6] = { - provider = "diagnostic_info", - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.INFO) end, - hl = { - fg = C.sky, - bg = sett.bkg, - }, - icon = " " .. assets.lsp.info .. " ", - right_sep = invi_sep, - } - - components.active[2][7] = { - provider = "diagnostic_hints", - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.HINT) end, - hl = { - fg = C.rosewater, - bg = sett.bkg, - }, - icon = " " .. assets.lsp.hint .. " ", - right_sep = invi_sep, - } - -- Diagnostics ------> - - components.active[2][8] = { - provider = function() - local filename = vim.fn.expand "%:t" - local extension = vim.fn.expand "%:e" - local present, icons = pcall(require, "nvim-web-devicons") - local icon = present and icons.get_icon(filename, extension) or assets.file - return (sett.show_modified and "%m" or "") .. " " .. icon .. " " .. filename .. " " - end, - enabled = is_enabled(70), - hl = { - fg = sett.text, - bg = sett.curr_file, - }, - left_sep = { - str = assets.left_separator, - hl = { - fg = sett.curr_file, - bg = sett.bkg, - }, - }, - } - - components.active[2][9] = { - provider = function() - local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") - return " " .. assets.dir .. " " .. dir_name .. " " - end, - enabled = is_enabled(80), - hl = { - fg = sett.text, - bg = sett.curr_dir, - }, - left_sep = { - str = assets.left_separator, - hl = { - fg = sett.curr_dir, - bg = sett.curr_file, - }, - }, - } - -- ######## Right - - -- Inanctive components - components.inactive[1][1] = { - provider = function() return " " .. string.upper(vim.bo.ft) .. " " end, - hl = { - fg = C.overlay2, - bg = C.mantle, - }, - } - - return components -end - -return M diff --git a/home/tui/config/nvim/lua/ui/fillchars.lua b/home/tui/config/nvim/lua/ui/fillchars.lua deleted file mode 100644 index 61a2aa07..00000000 --- a/home/tui/config/nvim/lua/ui/fillchars.lua +++ /dev/null @@ -1,9 +0,0 @@ -vim.opt.fillchars:append { - horiz = "━", - horizup = "┻", - horizdown = "┳", - vert = "┃", - vertleft = "┨", - vertright = "┣", - verthoriz = "╋", -} diff --git a/home/tui/config/nvim/lua/ui/navic_icons.lua b/home/tui/config/nvim/lua/ui/navic_icons.lua deleted file mode 100644 index cfb49089..00000000 --- a/home/tui/config/nvim/lua/ui/navic_icons.lua +++ /dev/null @@ -1,28 +0,0 @@ -return { - File = " ", - Module = " ", - Namespace = " ", - Package = " ", - Class = " ", - Method = " ", - Property = " ", - Field = " ", - Constructor = " ", - Enum = " ", - Interface = " ", - Function = " ", - Variable = " ", - Constant = " ", - String = " ", - Number = " ", - Boolean = " ", - Array = " ", - Object = " ", - Key = " ", - Null = " ", - EnumMember = " ", - Struct = " ", - Event = " ", - Operator = " ", - TypeParameter = " ", -} diff --git a/scripts/import-gsettings b/scripts/import-gsettings deleted file mode 100755 index 967620fc..00000000 --- a/scripts/import-gsettings +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# usage: import-gsettings -config="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini" -if [ ! -f "$config" ]; then exit 1; fi - -gnome_schema="org.gnome.desktop.interface" -gtk_theme="$(grep 'gtk-theme-name' "$config" | sed 's/.*\s*=\s*//')" -icon_theme="$(grep 'gtk-icon-theme-name' "$config" | sed 's/.*\s*=\s*//')" -cursor_theme="$(grep 'gtk-cursor-theme-name' "$config" | sed 's/.*\s*=\s*//')" -font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')" -gsettings set "$gnome_schema" gtk-theme "$gtk_theme" -gsettings set "$gnome_schema" icon-theme "$icon_theme" -gsettings set "$gnome_schema" cursor-theme "$cursor_theme" -gsettings set "$gnome_schema" font-name "$font_name" diff --git a/scripts/installers/direnv.sh b/scripts/installers/direnv.sh deleted file mode 100755 index f6796ded..00000000 --- a/scripts/installers/direnv.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env bash -# -# A good old bash | curl script for direnv. -# -set -euo pipefail - -{ # Prevent execution if this script was only partially downloaded - - log() { - echo "[installer] $*" >&2 - } - - die() { - log "$@" - exit 1 - } - - at_exit() { - ret=$? - if [[ $ret -gt 0 ]]; then - log "the script failed with error $ret.\n" \ - "\n" \ - "To report installation errors, submit an issue to\n" \ - " https://github.com/direnv/direnv/issues/new/choose" - fi - exit "$ret" - } - trap at_exit EXIT - - kernel=$(uname -s | tr "[:upper:]" "[:lower:]") - case "${kernel}" in - mingw*) - kernel=windows - ;; - esac - case "$(uname -m)" in - x86_64) - machine=amd64 - ;; - i686 | i386) - machine=386 - ;; - aarch64 | arm64) - machine=arm64 - ;; - *) - die "Machine $(uname -m) not supported by the installer.\n" \ - "Go to https://direnv for alternate installation methods." - ;; - esac - log "kernel=$kernel machine=$machine" - - : "${use_sudo:=}" - : "${bin_path:=}" - - if [[ -z "$bin_path" ]]; then - log "bin_path is not set, you can set bin_path to specify the installation path" - log "e.g. export bin_path=/path/to/installation before installing" - log "looking for a writeable path from PATH environment variable" - for path in $(echo "$PATH" | tr ':' '\n'); do - if [[ -w $path ]]; then - bin_path=$path - break - fi - done - fi - if [[ -z "$bin_path" ]]; then - die "did not find a writeable path in $PATH" - fi - echo "bin_path=$bin_path" - - if [[ -n "${version:-}" ]]; then - release="tags/${version}" - else - release="latest" - fi - echo "release=$release" - - log "looking for a download URL" - download_url=$( - curl -fL "https://api.github.com/repos/direnv/direnv/releases/$release" \ - | grep browser_download_url \ - | cut -d '"' -f 4 \ - | grep "direnv.$kernel.$machine" - ) - echo "download_url=$download_url" - - log "downloading" - curl -o "$bin_path/direnv" -fL "$download_url" - chmod a+x "$bin_path/direnv" - - cat <&2 - exit 1 -} - -umask 0022 - -tmpDir="$(mktemp -d -t nix-binary-tarball-unpack.XXXXXXXXXX || \ - oops "Can't create temporary directory for downloading the Nix binary tarball")" -cleanup() { - rm -rf "$tmpDir" -} -trap cleanup EXIT INT QUIT TERM - -require_util() { - command -v "$1" > /dev/null 2>&1 || - oops "you do not have '$1' installed, which I need to $2" -} - -case "$(uname -s).$(uname -m)" in - Linux.x86_64) - hash=1bdf98f951ce82ad1a12b9e6874f5858cb2aa2e402907e8c3079d8482cb8430b - path=dw0gkcqnig9qwyhkrq0sjrzai63zi6wy/nix-2.15.0-x86_64-linux.tar.xz - system=x86_64-linux - ;; - Linux.i?86) - hash=c868bed9bfff72a363b1a41f95bce971f8ccca111e5e3c9f8e2fa5e9bde91f75 - path=ayl7z135hkqhf4px5pacv47b4njqb9yj/nix-2.15.0-i686-linux.tar.xz - system=i686-linux - ;; - Linux.aarch64) - hash=3a08669bf8d27b5994fceb2bc4653fddab189832a8bd111d013591862eb45961 - path=26zpxva102pm9jz8nkb391ws3c7six2j/nix-2.15.0-aarch64-linux.tar.xz - system=aarch64-linux - ;; - Linux.armv6l) - hash=88736c6fda47d2c244d38ec81250111263c6756a5c9e5232fb56d5e1245f3aae - path=1m9il80f2y41qsarmarf3dkb23ryg2h8/nix-2.15.0-armv6l-linux.tar.xz - system=armv6l-linux - ;; - Linux.armv7l) - hash=44010bc59ad7504274533daf5d23d6773a286c5b7ac87960d330cc0580149462 - path=v2z7fhd4rq2n5s2svdk2dh6mf112w7ca/nix-2.15.0-armv7l-linux.tar.xz - system=armv7l-linux - ;; - Darwin.x86_64) - hash=d8b6a6e89f82113fcbce3d946fa501d5d2cf7cb35c88fb2017f3c12ef8392e7d - path=m01jb6iyf73jiyzdn6vfap8da347nmwf/nix-2.15.0-x86_64-darwin.tar.xz - system=x86_64-darwin - ;; - Darwin.arm64|Darwin.aarch64) - hash=2d4a8060e12077f174e0635ec06d94daeee0460166165414698dfdf0ef87915a - path=aa9fsy71mdsqp6kgf5sag6kv50zavhj5/nix-2.15.0-aarch64-darwin.tar.xz - system=aarch64-darwin - ;; - *) oops "sorry, there is no binary distribution of Nix for your platform";; -esac - -# Use this command-line option to fetch the tarballs using nar-serve or Cachix -if [ "${1:-}" = "--tarball-url-prefix" ]; then - if [ -z "${2:-}" ]; then - oops "missing argument for --tarball-url-prefix" - fi - url=${2}/${path} - shift 2 -else - url=https://releases.nixos.org/nix/nix-2.15.0/nix-2.15.0-$system.tar.xz -fi - -tarball=$tmpDir/nix-2.15.0-$system.tar.xz - -require_util tar "unpack the binary tarball" -if [ "$(uname -s)" != "Darwin" ]; then - require_util xz "unpack the binary tarball" -fi - -if command -v curl > /dev/null 2>&1; then - fetch() { curl --fail -L "$1" -o "$2"; } -elif command -v wget > /dev/null 2>&1; then - fetch() { wget "$1" -O "$2"; } -else - oops "you don't have wget or curl installed, which I need to download the binary tarball" -fi - -echo "downloading Nix 2.15.0 binary tarball for $system from '$url' to '$tmpDir'..." -fetch "$url" "$tarball" || oops "failed to download '$url'" - -if command -v sha256sum > /dev/null 2>&1; then - hash2="$(sha256sum -b "$tarball" | cut -c1-64)" -elif command -v shasum > /dev/null 2>&1; then - hash2="$(shasum -a 256 -b "$tarball" | cut -c1-64)" -elif command -v openssl > /dev/null 2>&1; then - hash2="$(openssl dgst -r -sha256 "$tarball" | cut -c1-64)" -else - oops "cannot verify the SHA-256 hash of '$url'; you need one of 'shasum', 'sha256sum', or 'openssl'" -fi - -if [ "$hash" != "$hash2" ]; then - oops "SHA-256 hash mismatch in '$url'; expected $hash, got $hash2" -fi - -unpack=$tmpDir/unpack -mkdir -p "$unpack" -tar -xJf "$tarball" -C "$unpack" || oops "failed to unpack '$url'" - -script=$(echo "$unpack"/*/install) - -[ -e "$script" ] || oops "installation script is missing from the binary tarball!" -export INVOKED_FROM_INSTALL_IN=1 -"$script" "$@" - -} # End of wrapping diff --git a/scripts/installers/nvim.sh b/scripts/installers/nvim.sh deleted file mode 100755 index 6ab98408..00000000 --- a/scripts/installers/nvim.sh +++ /dev/null @@ -1,9 +0,0 @@ -curl -sSLO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage -curl -sSLO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage.sha256sum -sha256sum -c nvim.appimage.sha256sum || { - rm nvim.appimage nvim.appimage.sha256sum - exit 1 -} -rm nvim.appimage.sha256sum -chmod a+x nvim.appimage -mv nvim.appimage $HOME/.local/bin/nvim diff --git a/scripts/installers/starship.sh b/scripts/installers/starship.sh deleted file mode 100755 index 6c1f9a2a..00000000 --- a/scripts/installers/starship.sh +++ /dev/null @@ -1,517 +0,0 @@ -#!/usr/bin/env sh - -set -eu -printf '\n' - -BOLD="$(tput bold 2>/dev/null || printf '')" -GREY="$(tput setaf 0 2>/dev/null || printf '')" -UNDERLINE="$(tput smul 2>/dev/null || printf '')" -RED="$(tput setaf 1 2>/dev/null || printf '')" -GREEN="$(tput setaf 2 2>/dev/null || printf '')" -YELLOW="$(tput setaf 3 2>/dev/null || printf '')" -BLUE="$(tput setaf 4 2>/dev/null || printf '')" -MAGENTA="$(tput setaf 5 2>/dev/null || printf '')" -NO_COLOR="$(tput sgr0 2>/dev/null || printf '')" - -SUPPORTED_TARGETS="x86_64-unknown-linux-gnu x86_64-unknown-linux-musl \ - i686-unknown-linux-musl aarch64-unknown-linux-musl \ - arm-unknown-linux-musleabihf x86_64-apple-darwin \ - aarch64-apple-darwin x86_64-pc-windows-msvc \ - i686-pc-windows-msvc aarch64-pc-windows-msvc \ - x86_64-unknown-freebsd" - -info() { - printf '%s\n' "${BOLD}${GREY}>${NO_COLOR} $*" -} - -warn() { - printf '%s\n' "${YELLOW}! $*${NO_COLOR}" -} - -error() { - printf '%s\n' "${RED}x $*${NO_COLOR}" >&2 -} - -completed() { - printf '%s\n' "${GREEN}✓${NO_COLOR} $*" -} - -has() { - command -v "$1" 1>/dev/null 2>&1 -} - -# Make sure user is not using zsh or non-POSIX-mode bash, which can cause issues -verify_shell_is_posix_or_exit() { - if [ -n "${ZSH_VERSION+x}" ]; then - error "Running installation script with \`zsh\` is known to cause errors." - error "Please use \`sh\` instead." - exit 1 - elif [ -n "${BASH_VERSION+x}" ] && [ -z "${POSIXLY_CORRECT+x}" ]; then - error "Running installation script with non-POSIX \`bash\` may cause errors." - error "Please use \`sh\` instead." - exit 1 - else - true # No-op: no issues detected - fi -} - -# Gets path to a temporary file, even if -get_tmpfile() { - suffix="$1" - if has mktemp; then - printf "%s.%s" "$(mktemp)" "${suffix}" - else - # No really good options here--let's pick a default + hope - printf "/tmp/starship.%s" "${suffix}" - fi -} - -# Test if a location is writeable by trying to write to it. Windows does not let -# you test writeability other than by writing: https://stackoverflow.com/q/1999988 -test_writeable() { - path="${1:-}/test.txt" - if touch "${path}" 2>/dev/null; then - rm "${path}" - return 0 - else - return 1 - fi -} - -download() { - file="$1" - url="$2" - - if has curl; then - cmd="curl --fail --silent --location --output $file $url" - elif has wget; then - cmd="wget --quiet --output-document=$file $url" - elif has fetch; then - cmd="fetch --quiet --output=$file $url" - else - error "No HTTP download program (curl, wget, fetch) found, exiting…" - return 1 - fi - - $cmd && return 0 || rc=$? - - error "Command failed (exit code $rc): ${BLUE}${cmd}${NO_COLOR}" - printf "\n" >&2 - info "This is likely due to Starship not yet supporting your configuration." - info "If you would like to see a build for your configuration," - info "please create an issue requesting a build for ${MAGENTA}${TARGET}${NO_COLOR}:" - info "${BOLD}${UNDERLINE}https://github.com/starship/starship/issues/new/${NO_COLOR}" - return $rc -} - -unpack() { - archive=$1 - bin_dir=$2 - sudo=${3-} - - case "$archive" in - *.tar.gz) - flags=$(test -n "${VERBOSE-}" && echo "-xzvof" || echo "-xzof") - ${sudo} tar "${flags}" "${archive}" -C "${bin_dir}" - return 0 - ;; - *.zip) - flags=$(test -z "${VERBOSE-}" && echo "-qqo" || echo "-o") - UNZIP="${flags}" ${sudo} unzip "${archive}" -d "${bin_dir}" - return 0 - ;; - esac - - error "Unknown package extension." - printf "\n" - info "This almost certainly results from a bug in this script--please file a" - info "bug report at https://github.com/starship/starship/issues" - return 1 -} - -usage() { - printf "%s\n" \ - "install.sh [option]" \ - "" \ - "Fetch and install the latest version of starship, if starship is already" \ - "installed it will be updated to the latest version." - - printf "\n%s\n" "Options" - printf "\t%s\n\t\t%s\n\n" \ - "-V, --verbose" "Enable verbose output for the installer" \ - "-f, -y, --force, --yes" "Skip the confirmation prompt during installation" \ - "-p, --platform" "Override the platform identified by the installer [default: ${PLATFORM}]" \ - "-b, --bin-dir" "Override the bin installation directory [default: ${BIN_DIR}]" \ - "-a, --arch" "Override the architecture identified by the installer [default: ${ARCH}]" \ - "-B, --base-url" "Override the base URL used for downloading releases [default: ${BASE_URL}]" \ - "-h, --help" "Display this help message" -} - -elevate_priv() { - if ! has sudo; then - error 'Could not find the command "sudo", needed to get permissions for install.' - info "If you are on Windows, please run your shell as an administrator, then" - info "rerun this script. Otherwise, please run this script as root, or install" - info "sudo." - exit 1 - fi - if ! sudo -v; then - error "Superuser not granted, aborting installation" - exit 1 - fi -} - -install() { - ext="$1" - - if test_writeable "${BIN_DIR}"; then - sudo="" - msg="Installing Starship, please wait…" - else - warn "Escalated permissions are required to install to ${BIN_DIR}" - elevate_priv - sudo="sudo" - msg="Installing Starship as root, please wait…" - fi - info "$msg" - - archive=$(get_tmpfile "$ext") - - # download to the temp file - download "${archive}" "${URL}" - - # unpack the temp file to the bin dir, using sudo if required - unpack "${archive}" "${BIN_DIR}" "${sudo}" -} - -# Currently supporting: -# - win (Git Bash) -# - darwin -# - linux -# - linux_musl (Alpine) -# - freebsd -detect_platform() { - platform="$(uname -s | tr '[:upper:]' '[:lower:]')" - - case "${platform}" in - msys_nt*) platform="pc-windows-msvc" ;; - cygwin_nt*) platform="pc-windows-msvc";; - # mingw is Git-Bash - mingw*) platform="pc-windows-msvc" ;; - # use the statically compiled musl bins on linux to avoid linking issues. - linux) platform="unknown-linux-musl" ;; - darwin) platform="apple-darwin" ;; - freebsd) platform="unknown-freebsd" ;; - esac - - printf '%s' "${platform}" -} - -# Currently supporting: -# - x86_64 -# - i386 -# - arm -# - arm64 -detect_arch() { - arch="$(uname -m | tr '[:upper:]' '[:lower:]')" - - case "${arch}" in - amd64) arch="x86_64" ;; - armv*) arch="arm" ;; - arm64) arch="aarch64" ;; - esac - - # `uname -m` in some cases mis-reports 32-bit OS as 64-bit, so double check - if [ "${arch}" = "x86_64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then - arch=i686 - elif [ "${arch}" = "aarch64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then - arch=arm - fi - - printf '%s' "${arch}" -} - -detect_target() { - arch="$1" - platform="$2" - target="$arch-$platform" - - if [ "${target}" = "arm-unknown-linux-musl" ]; then - target="${target}eabihf" - fi - - printf '%s' "${target}" -} - - -confirm() { - if [ -z "${FORCE-}" ]; then - printf "%s " "${MAGENTA}?${NO_COLOR} $* ${BOLD}[y/N]${NO_COLOR}" - set +e - read -r yn &2 - info "If you would like to see a build for your configuration," - info "please create an issue requesting a build for ${MAGENTA}${target}${NO_COLOR}:" - info "${BOLD}${UNDERLINE}https://github.com/starship/starship/issues/new/${NO_COLOR}" - printf "\n" - exit 1 - fi -} - -# defaults -if [ -z "${PLATFORM-}" ]; then - PLATFORM="$(detect_platform)" -fi - -if [ -z "${BIN_DIR-}" ]; then - BIN_DIR=/usr/local/bin -fi - -if [ -z "${ARCH-}" ]; then - ARCH="$(detect_arch)" -fi - -if [ -z "${BASE_URL-}" ]; then - BASE_URL="https://github.com/starship/starship/releases" -fi - -# Non-POSIX shells can break once executing code due to semantic differences -verify_shell_is_posix_or_exit - -# parse argv variables -while [ "$#" -gt 0 ]; do - case "$1" in - -p | --platform) - PLATFORM="$2" - shift 2 - ;; - -b | --bin-dir) - BIN_DIR="$2" - shift 2 - ;; - -a | --arch) - ARCH="$2" - shift 2 - ;; - -B | --base-url) - BASE_URL="$2" - shift 2 - ;; - - -V | --verbose) - VERBOSE=1 - shift 1 - ;; - -f | -y | --force | --yes) - FORCE=1 - shift 1 - ;; - -h | --help) - usage - exit - ;; - - -p=* | --platform=*) - PLATFORM="${1#*=}" - shift 1 - ;; - -b=* | --bin-dir=*) - BIN_DIR="${1#*=}" - shift 1 - ;; - -a=* | --arch=*) - ARCH="${1#*=}" - shift 1 - ;; - -B=* | --base-url=*) - BASE_URL="${1#*=}" - shift 1 - ;; - -V=* | --verbose=*) - VERBOSE="${1#*=}" - shift 1 - ;; - -f=* | -y=* | --force=* | --yes=*) - FORCE="${1#*=}" - shift 1 - ;; - - *) - error "Unknown option: $1" - usage - exit 1 - ;; - esac -done - -TARGET="$(detect_target "${ARCH}" "${PLATFORM}")" - -is_build_available "${ARCH}" "${PLATFORM}" "${TARGET}" - -printf " %s\n" "${UNDERLINE}Configuration${NO_COLOR}" -info "${BOLD}Bin directory${NO_COLOR}: ${GREEN}${BIN_DIR}${NO_COLOR}" -info "${BOLD}Platform${NO_COLOR}: ${GREEN}${PLATFORM}${NO_COLOR}" -info "${BOLD}Arch${NO_COLOR}: ${GREEN}${ARCH}${NO_COLOR}" - -# non-empty VERBOSE enables verbose untarring -if [ -n "${VERBOSE-}" ]; then - VERBOSE=v - info "${BOLD}Verbose${NO_COLOR}: yes" -else - VERBOSE= -fi - -printf '\n' - -EXT=tar.gz -if [ "${PLATFORM}" = "pc-windows-msvc" ]; then - EXT=zip -fi - -URL="${BASE_URL}/latest/download/starship-${TARGET}.${EXT}" -info "Tarball URL: ${UNDERLINE}${BLUE}${URL}${NO_COLOR}" -confirm "Install Starship ${GREEN}latest${NO_COLOR} to ${BOLD}${GREEN}${BIN_DIR}${NO_COLOR}?" -check_bin_dir "${BIN_DIR}" - -install "${EXT}" -completed "Starship installed" - -printf '\n' -info "Please follow the steps for your shell to complete the installation:" - -print_install diff --git a/scripts/power-profiles b/scripts/power-profiles deleted file mode 100755 index 8436fab2..00000000 --- a/scripts/power-profiles +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env bash -# -# Use rofi/zenity to change system runstate thanks to systemd. -# -# Note: this currently relies on associative array support in the shell. -# -# Inspired from i3pystatus wiki: -# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu -# -# Copyright 2015 Benjamin Chrétien -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# power-profiles-daemon implementation: -# needs package power-profiles-daemon installed and the service running see here: -# https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon -# used in i3-blocks: ~/.config/i3/i3blocks.conf together with: ~/.config/i3/scripts/ppd-status - - -####################################################################### -# BEGIN CONFIG # -####################################################################### - -# Use a custom lock script -#LOCKSCRIPT="i3lock-extra -m pixelize" - -# Colors: FG (foreground), BG (background), HL (highlighted) -FG_COLOR="#bbbbbb" -BG_COLOR="#111111" -HLFG_COLOR="#111111" -HLBG_COLOR="#bbbbbb" -BORDER_COLOR="#222222" - -# Options not related to colors -#ROFI_TEXT=":" -#ROFI_OPTIONS=(-width -11 -location 0 -hide-scrollbar -bw 30 -color-window "#dd310027,#dd0310027,#dd310027" -padding 5) -#ROFI_OPTIONS=(-width -18 -location 4 -hide-scrollbar -color-window "#cc310027,#00a0009a,#cc310027" -padding 5 -font "Sourcecode Pro Regular 10, FontAwesome 9") -#ROFI_OPTIONS=(-theme ~/.dotfiles/rofi/power-profiles.rasi) -# Zenity options -ZENITY_TITLE="Power Profiles" -ZENITY_TEXT="Set Profiles:" -ZENITY_OPTIONS=(--column= --hide-header) - -####################################################################### -# END CONFIG # -####################################################################### - -# Whether to ask for user's confirmation -enable_confirmation=false - -# Preferred launcher if both are available -preferred_launcher="rofi" - -usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. - -where: - -h show this help text - -c ask for user confirmation - -p preferred launcher (rofi or zenity) - -This script depends on: - - systemd, - - rofi or zenity." - -# Check whether the user-defined launcher is valid -launcher_list=(rofi zenity) -function check_launcher() { - if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then - echo "Supported launchers: ${launcher_list[*]}" - exit 1 - else - # Get array with unique elements and preferred launcher first - # Note: uniq expects a sorted list, so we cannot use it - i=1 - launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ - | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) - fi -} - -# Parse CLI arguments -while getopts "hcp:" option; do - case "${option}" in - h) echo "${usage}" - exit 0 - ;; - c) enable_confirmation=true - ;; - p) preferred_launcher="${OPTARG}" - check_launcher "${preferred_launcher}" - ;; - *) exit 1 - ;; - esac -done - -# Check whether a command exists -function command_exists() { - command -v "$1" &> /dev/null 2>&1 -} - -# systemctl required -if ! command_exists systemctl ; then - exit 1 -fi - -# menu defined as an associative array -typeset -A menu - -# Menu with keys/commands - -menu=( - [ Performance]="powerprofilesctl set performance" - [ Balanced]="powerprofilesctl set balanced" - [ Power Saver]="powerprofilesctl set power-saver" - [ Cancel]="" -) - -menu_nrows=${#menu[@]} - -# Menu entries that may trigger a confirmation message -menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" - -launcher_exe="" -launcher_options="" -rofi_colors="" - -function prepare_launcher() { - if [[ "$1" == "rofi" ]]; then - rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ - -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") - launcher_exe="rofi" - launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ - "${rofi_colors}" "${ROFI_OPTIONS[@]}") - elif [[ "$1" == "zenity" ]]; then - launcher_exe="zenity" - launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ - "${ZENITY_OPTIONS[@]}") - fi -} - -for l in "${launcher_list[@]}"; do - if command_exists "${l}" ; then - prepare_launcher "${l}" - break - fi -done - -# No launcher available -if [[ -z "${launcher_exe}" ]]; then - exit 1 -fi - -launcher=(${launcher_exe} "${launcher_options[@]}") -selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" - -function ask_confirmation() { - if [ "${launcher_exe}" == "rofi" ]; then - confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ - "${rofi_colors}" "${ROFI_OPTIONS[@]}") - [ "${confirmed}" == "Yes" ] && confirmed=0 - elif [ "${launcher_exe}" == "zenity" ]; then - zenity --question --text "Are you sure you want to ${selection,,}?" - confirmed=$? - fi - - if [ "${confirmed}" == 0 ]; then - ${menu[${selection}]} - fi -} - -if [[ $? -eq 0 && ! -z ${selection} ]]; then - if [[ "${enable_confirmation}" = true && \ - ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then - ask_confirmation - else - ${menu[${selection}]} - fi -fi diff --git a/scripts/powermenu b/scripts/powermenu deleted file mode 100755 index 69d51d46..00000000 --- a/scripts/powermenu +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env bash -# -# Use rofi/zenity to change system runstate thanks to systemd. -# -# Note: this currently relies on associative array support in the shell. -# -# Inspired from i3pystatus wiki: -# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu -# -# Copyright 2015 Benjamin Chrétien -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# modified to work with latest rofi update by joekamprad - -####################################################################### -# BEGIN CONFIG # -####################################################################### - -# Use a custom lock script -#LOCKSCRIPT="i3lock-extra -m pixelize" - -# Colors: FG (foreground), BG (background), HL (highlighted) -FG_COLOR="#bbbbbb" -BG_COLOR="#111111" -HLFG_COLOR="#111111" -HLBG_COLOR="#bbbbbb" -BORDER_COLOR="#222222" - -# Options not related to colors (most rofi options do not work anymore) -#ROFI_OPTIONS=(-theme ~/.dotfiles/rofi/powermenu.rasi) -# Zenity options -ZENITY_TITLE="Power Menu" -ZENITY_TEXT="Action:" -ZENITY_OPTIONS=(--column= --hide-header) - -####################################################################### -# END CONFIG # -####################################################################### - -# Whether to ask for user's confirmation -enable_confirmation=false - -# Preferred launcher if both are available -preferred_launcher="rofi" - -usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. - -where: - -h show this help text - -c ask for user confirmation - -p preferred launcher (rofi or zenity) - -This script depends on: - - systemd, - - rofi or zenity." - -# Check whether the user-defined launcher is valid -launcher_list=(rofi zenity) -function check_launcher() { - if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then - echo "Supported launchers: ${launcher_list[*]}" - exit 1 - else - # Get array with unique elements and preferred launcher first - # Note: uniq expects a sorted list, so we cannot use it - i=1 - launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ - | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) - fi -} - -# Parse CLI arguments -while getopts "hcp:" option; do - case "${option}" in - h) echo "${usage}" - exit 0 - ;; - c) enable_confirmation=true - ;; - p) preferred_launcher="${OPTARG}" - check_launcher "${preferred_launcher}" - ;; - *) exit 1 - ;; - esac -done - -# Check whether a command exists -function command_exists() { - command -v "$1" &> /dev/null 2>&1 -} - -# systemctl required -if ! command_exists systemctl ; then - exit 1 -fi - -# menu defined as an associative array -typeset -A menu - -# Menu with keys/commands - -menu=( - [ Shutdown]="systemctl poweroff" - [ Reboot]="systemctl reboot" - [ Suspend]="systemctl suspend" - [ Hibernate]="systemctl hibernate" - [ Lock]="hyprctl dispatch exec swaylock" - [ Logout]="hyprctl dispatch exit" - [ Cancel]="" -) - -menu_nrows=${#menu[@]} - -# Menu entries that may trigger a confirmation message -menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" - -launcher_exe="" -launcher_options="" -rofi_colors="" - -function prepare_launcher() { - if [[ "$1" == "rofi" ]]; then - rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ - -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") - launcher_exe="rofi" - launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ - "${rofi_colors}" "${ROFI_OPTIONS[@]}") - elif [[ "$1" == "zenity" ]]; then - launcher_exe="zenity" - launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ - "${ZENITY_OPTIONS[@]}") - fi -} - -for l in "${launcher_list[@]}"; do - if command_exists "${l}" ; then - prepare_launcher "${l}" - break - fi -done - -# No launcher available -if [[ -z "${launcher_exe}" ]]; then - exit 1 -fi - -launcher=(${launcher_exe} "${launcher_options[@]}") -selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" - -function ask_confirmation() { - if [ "${launcher_exe}" == "rofi" ]; then - confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ - "${rofi_colors}" "${ROFI_OPTIONS[@]}") - [ "${confirmed}" == "Yes" ] && confirmed=0 - elif [ "${launcher_exe}" == "zenity" ]; then - zenity --question --text "Are you sure you want to ${selection,,}?" - confirmed=$? - fi - - if [ "${confirmed}" == 0 ]; then - ${menu[${selection}]} - fi -} - -if [[ $? -eq 0 && ! -z ${selection} ]]; then - if [[ "${enable_confirmation}" = true && \ - ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then - ask_confirmation - else - ${menu[${selection}]} - fi -fi diff --git a/scripts/pulseaudio-control.bash b/scripts/pulseaudio-control.bash deleted file mode 100755 index 99c60ef0..00000000 --- a/scripts/pulseaudio-control.bash +++ /dev/null @@ -1,670 +0,0 @@ -#!/usr/bin/env bash - -################################################################## -# Polybar Pulseaudio Control # -# https://github.com/marioortizmanero/polybar-pulseaudio-control # -################################################################## - -# Deprecated values, to be removed in a next release. This is kept around to -# be displayed for users using it in custom FORMAT -# shellcheck disable=SC2034 -ICON_SINK="Replaced by ICON_NODE, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" -SINK_NICKNAME="Replaced by NODE_NICKNAME, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" - -# Defaults for configurable values, expected to be set by command-line arguments -AUTOSYNC="no" -COLOR_MUTED="%{F#6b6b6b}" -ICON_MUTED= -ICON_NODE= -NODE_TYPE="output" -NOTIFICATIONS="no" -OSD="no" -NODE_NICKNAMES_PROP= -VOLUME_STEP=2 -VOLUME_MAX=130 -LISTEN_TIMEOUT=0.05 -# shellcheck disable=SC2016 -FORMAT='$VOL_ICON ${VOL_LEVEL}% $ICON_NODE $NODE_NICKNAME' -declare -A NODE_NICKNAMES -declare -a ICONS_VOLUME -declare -a NODE_BLACKLIST - -# Special variable: within the script, pactl, grep, and awk commands are used -# on sinks or sources, depending on NODE_TYPE. -# -# The commands are almost always the same, except for the sink/source part. -# In order to reduce duplication, this variable is used for commands that behave -# the same, regardless of the NODE_TYPE. -# -# Having only the "radix" (ink/ource) and omitting the first letter enables us -# to use that single variable: -# -# S-ink , s-ink , s-ink -s, S-ink -s -# S-ource, s-ource, s-ource-s, S-ource-s -SINK_OR_SOURCE="ink" - -# Environment & global constants for the script -export LC_ALL=C # Some calls depend on English outputs of pactl -END_COLOR="%{F-}" # For Polybar colors - - -# Saves the currently default node into a variable named `curNode`. It will -# return an error code when pulseaudio isn't running. -function getCurNode() { - if ! pactl info &>/dev/null; then return 1; fi - local curNodeName - - curNodeName=$(pactl info | awk "/Default S${SINK_OR_SOURCE}: / {print \$3}") - curNode=$(pactl list "s${SINK_OR_SOURCE}s" | grep -B 4 -E "Name: $curNodeName\$" | sed -nE "s/^S${SINK_OR_SOURCE} #([0-9]+)$/\1/p") -} - - -# Saves the node passed by parameter's volume into a variable named `VOL_LEVEL`. -function getCurVol() { - VOL_LEVEL=$(pactl list "s${SINK_OR_SOURCE}s" | grep -A 15 -E "^S${SINK_OR_SOURCE} #$1\$" | grep 'Volume:' | grep -E -v 'Base Volume:' | awk -F : '{print $3; exit}' | grep -o -P '.{0,3}%' | sed 's/.$//' | tr -d ' ') -} - - -# Saves the name of the node passed by parameter into a variable named -# `nodeName`. -function getNodeName() { - nodeName=$(pactl list "s${SINK_OR_SOURCE}s" short | awk -v sink="$1" "{ if (\$1 == sink) {print \$2} }") - portName=$(pactl list "s${SINK_OR_SOURCE}s" | grep -e "S${SINK_OR_SOURCE} #" -e 'Active Port: ' | sed -n "/^S${SINK_OR_SOURCE} #$1\$/,+1p" | awk '/Active Port: / {print $3}') -} - - -# Saves the name to be displayed for the node passed by parameter into a -# variable called `NODE_NICKNAME`. -# If a mapping for the node name exists, that is used. Otherwise, the string -# "Node #" is used. -function getNickname() { - getNodeName "$1" - unset NODE_NICKNAME - - if [ -n "$nodeName" ] && [ -n "$portName" ] && [ -n "${NODE_NICKNAMES[$nodeName/$portName]}" ]; then - NODE_NICKNAME="${NODE_NICKNAMES[$nodeName/$portName]}" - elif [ -n "$nodeName" ] && [ -n "${NODE_NICKNAMES[$nodeName]}" ]; then - NODE_NICKNAME="${NODE_NICKNAMES[$nodeName]}" - elif [ -n "$nodeName" ]; then - # No exact match could be found, try a Glob Match - for glob in "${!NODE_NICKNAMES[@]}"; do - # shellcheck disable=SC2053 # Disable Shellcheck warning for Glob-Matching - if [[ "$nodeName/$portName" == $glob ]] || [[ "$nodeName" == $glob ]]; then - NODE_NICKNAME="${NODE_NICKNAMES[$glob]}" - # Cache that result for next time - NODE_NICKNAMES["$nodeName"]="$NODE_NICKNAME" - break - fi - done - fi - - if [ -z "$NODE_NICKNAME" ] && [ -n "$nodeName" ] && [ -n "$NODE_NICKNAMES_PROP" ]; then - getNicknameFromProp "$NODE_NICKNAMES_PROP" "$nodeName" - # Cache that result for next time - NODE_NICKNAMES["$nodeName"]="$NODE_NICKNAME" - elif [ -z "$NODE_NICKNAME" ]; then - NODE_NICKNAME="S${SINK_OR_SOURCE} #$1" - fi -} - -# Gets node nickname based on a given property. -function getNicknameFromProp() { - local nickname_prop="$1" - local for_name="$2" - - NODE_NICKNAME= - while read -r property value; do - case "$property" in - Name:) - node_name="$value" - unset node_desc - ;; - "$nickname_prop") - if [ "$node_name" != "$for_name" ]; then - continue - fi - NODE_NICKNAME="${value:3:-1}" - break - ;; - esac - done < <(pactl list "s${SINK_OR_SOURCE}s") -} - -# Saves the status of the node passed by parameter into a variable named -# `IS_MUTED`. -function getIsMuted() { - IS_MUTED=$(pactl list "s${SINK_OR_SOURCE}s" | grep -E "^S${SINK_OR_SOURCE} #$1\$" -A 15 | awk '/Mute: / {print $2}') -} - - -# Saves all the sink inputs of the sink passed by parameter into a string -# named `sinkInputs`. -function getSinkInputs() { - sinkInputs=$(pactl list sink-inputs | grep -B 4 "Sink: $1" | sed -nE "s/^Sink Input #([0-9]+)\$/\1/p") -} - - -# Saves all the source outputs of the source passed by parameter into a string -# named `sourceOutputs`. -function getSourceOutputs() { - sourceOutputs=$(pactl list source-outputs | grep -B 4 "Source: $1" | sed -nE "s/^Source Output #([0-9]+)\$/\1/p") -} - - -function volUp() { - # Obtaining the current volume from pulseaudio into $VOL_LEVEL. - if ! getCurNode; then - echo "PulseAudio not running" - return 1 - fi - getCurVol "$curNode" - local maxLimit=$((VOLUME_MAX - VOLUME_STEP)) - - # Checking the volume upper bounds so that if VOLUME_MAX was 100% and the - # increase percentage was 3%, a 99% volume would top at 100% instead - # of 102%. If the volume is above the maximum limit, nothing is done. - if [ "$VOL_LEVEL" -le "$VOLUME_MAX" ] && [ "$VOL_LEVEL" -ge "$maxLimit" ]; then - pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "$VOLUME_MAX%" - elif [ "$VOL_LEVEL" -lt "$maxLimit" ]; then - pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "+$VOLUME_STEP%" - fi - - if [ $OSD = "yes" ]; then showOSD "$curNode"; fi - if [ $AUTOSYNC = "yes" ]; then volSync; fi -} - - -function volDown() { - # Pactl already handles the volume lower bounds so that negative values - # are ignored. - if ! getCurNode; then - echo "PulseAudio not running" - return 1 - fi - pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "-$VOLUME_STEP%" - - if [ $OSD = "yes" ]; then showOSD "$curNode"; fi - if [ $AUTOSYNC = "yes" ]; then volSync; fi -} - - -function volSync() { - # This will only be called if $AUTOSYNC is `yes`. - - if ! getCurNode; then - echo "PulseAudio not running" - return 1 - fi - - getCurVol "$curNode" - - if [[ "$NODE_TYPE" = "output" ]]; then - getSinkInputs "$curNode" - - # Every output found in the active sink has their volume set to the - # current one. - for each in $sinkInputs; do - pactl "set-sink-input-volume" "$each" "$VOL_LEVEL%" - done - else - getSourceOutputs "$curNode" - - # Every input found in the active source has their volume set to the - # current one. - for each in $sourceOutputs; do - pactl "set-source-output-volume" "$each" "$VOL_LEVEL%" - done - fi -} - - -function volMute() { - # Switch to mute/unmute the volume with pactl. - if ! getCurNode; then - echo "PulseAudio not running" - return 1 - fi - if [ "$1" = "toggle" ]; then - getIsMuted "$curNode" - if [ "$IS_MUTED" = "yes" ]; then - pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no" - else - pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes" - fi - elif [ "$1" = "mute" ]; then - pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes" - elif [ "$1" = "unmute" ]; then - pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no" - fi - - if [ $OSD = "yes" ]; then showOSD "$curNode"; fi -} - - -function nextNode() { - # The final nodes list, removing the blacklisted ones from the list of - # currently available nodes. - if ! getCurNode; then - echo "PulseAudio not running" - return 1 - fi - - # Obtaining a tuple of node indexes after removing the blacklisted devices - # with their name. - nodes=() - local i=0 - while read -r line; do - index=$(echo "$line" | cut -f1) - name=$(echo "$line" | cut -f2) - - # If it's in the blacklist, continue the main loop. Otherwise, add - # it to the list. - for node in "${NODE_BLACKLIST[@]}"; do - # shellcheck disable=SC2053 # Disable Shellcheck warning for Glob-Matching - if [[ "$name" == $node ]]; then - continue 2 - fi - done - - nodes[i]="$index" - i=$((i + 1)) - done < <(pactl list short "s${SINK_OR_SOURCE}s" | sort -n) - - # If the resulting list is empty, nothing is done - if [ ${#nodes[@]} -eq 0 ]; then return; fi - - # If the current node is greater or equal than last one, pick the first - # node in the list. Otherwise just pick the next node avaliable. - local newNode - if [ "$curNode" -ge "${nodes[-1]}" ]; then - newNode=${nodes[0]} - else - for node in "${nodes[@]}"; do - if [ "$curNode" -lt "$node" ]; then - newNode=$node - break - fi - done - fi - - # The new node is set - pactl "set-default-s${SINK_OR_SOURCE}" "$newNode" - - # Move all audio threads to new node - local inputs - - if [[ "$NODE_TYPE" = "output" ]]; then - inputs="$(pactl list short sink-inputs | cut -f 1)" - for i in $inputs; do - pactl move-sink-input "$i" "$newNode" - done - else - outputs="$(pactl list short source-outputs | cut -f 1)" - for i in $outputs; do - pactl move-source-output "$i" "$newNode" - done - fi - - if [ $NOTIFICATIONS = "yes" ]; then - getNickname "$newNode" - - if command -v dunstify &>/dev/null; then - notify="dunstify --replace 201839192" - else - notify="notify-send" - fi - $notify "PulseAudio" "Changed $NODE_TYPE to $NODE_NICKNAME" --icon=audio-headphones-symbolic & - fi -} - - -# This function assumes that PulseAudio is already running. It only supports -# KDE OSDs for now. It will show a system message with the status of the -# node passed by parameter, or the currently active one by default. -function showOSD() { - if [ -z "$1" ]; then - curNode="$1" - else - getCurNode - fi - getCurVol "$curNode" - getIsMuted "$curNode" - qdbus org.kde.kded /modules/kosd showVolume "$VOL_LEVEL" "$IS_MUTED" -} - - -function listen() { - # If this is the first time start by printing the current state. Otherwise, - # directly wait for events. This is to prevent the module being empty until - # an event occurs. - output - - # Listen for changes and immediately create new output for the bar. - # This is faster than having the script on an interval. - pactl subscribe 2>/dev/null | grep --line-buffered -e "on \(card\|s${SINK_OR_SOURCE}\|server\)" | { - while read -r; do - # Output the new state - output - - # Read all stdin to flush unwanted pending events, i.e. if there are - # 15 events at the same time (100ms window), output is only called - # twice. - read -r -d '' -t "$LISTEN_TIMEOUT" -n 10000 - - # After the 100ms waiting time, output again the state, as it may - # have changed if the user did an action during the 100ms window. - output - done - } -} - - -function output() { - if ! getCurNode; then - echo "PulseAudio not running" - return 1 - fi - getCurVol "$curNode" - getIsMuted "$curNode" - - # Fixed volume icons over max volume - local iconsLen=${#ICONS_VOLUME[@]} - if [ "$iconsLen" -ne 0 ]; then - local volSplit=$((VOLUME_MAX / iconsLen)) - for i in $(seq 1 "$iconsLen"); do - if [ $((i * volSplit)) -ge "$VOL_LEVEL" ]; then - VOL_ICON="${ICONS_VOLUME[$((i-1))]}" - break - fi - done - else - VOL_ICON="" - fi - - getNickname "$curNode" - - # Showing the formatted message - if [ "$IS_MUTED" = "yes" ]; then - # shellcheck disable=SC2034 - VOL_ICON=$ICON_MUTED - content="$(eval echo "$FORMAT")" - if [ -n "$COLOR_MUTED" ]; then - echo "${COLOR_MUTED}${content}${END_COLOR}" - else - echo "$content" - fi - else - eval echo "$FORMAT" - fi -} - - -function usage() { - echo "\ -Usage: $0 [OPTION...] ACTION - -Terminology: A node represents either a sink (output) or source (input). - -Options: - --autosync | --no-autosync - Whether to maintain same volume for all programs. - Default: \"$AUTOSYNC\" - --color-muted - Color in which to format when muted. - Pass empty string to disable. - Default: \"${COLOR_MUTED:4:-1}\" - --notifications | --no-notifications - Whether to show notifications when changing nodes. - Default: \"$NOTIFICATIONS\" - --osd | --no-osd - Whether to display KDE's OSD message. - Default: \"$OSD\" - --icon-muted - Icon to use when muted. - Default: none - --icon-node - Icon to use for node. - Default: none - --format - Use a format string to control the output. - Remember to pass this argument wrapped in single quotes (\`'\`) instead - of double quotes (\`\"\`) to avoid your shell from evaluating the - variables early. - Available variables: - * \$VOL_ICON - * \$VOL_LEVEL - * \$ICON_NODE - * \$NODE_NICKNAME - * \$IS_MUTED (yes/no) - Default: '$FORMAT' - --icons-volume [,...] - Icons for volume, from lower to higher. - Default: none - --node-type - Whether to consider PulseAudio sinks (output) or sources (input). - All the operations of pulseaudio-control will apply to one of the two. - Pass \`input\` for the sources, e.g. a microphone. - Pass \`output\` for the sinks, e.g. speakers, headphones. - Default: \"$NODE_TYPE\" - --volume-max - Maximum volume to which to allow increasing. - Default: \"$VOLUME_MAX\" - --volume-step - Step size when inc/decrementing volume. - Default: \"$VOLUME_STEP\" - --node-blacklist [,...] - Nodes to ignore when switching. You can use globs. Don't forget to - quote the string when using globs, to avoid unwanted shell glob - extension. - Default: none - --node-nicknames-from - pactl property to use for node names, unless overridden by - --node-nickname. Its possible values are listed under the 'Properties' - key in the output of \`pactl list sinks\` and \`pactl list sources\`. - Default: none - --node-nickname : - Nickname to assign to given node name, taking priority over - --node-nicknames-from. May be given multiple times, and 'name' is - exactly as listed in the output of \`pactl list sinks short | cut -f2\` - and \`pactl list sources short | cut -f2\`. - Note that you can also specify a port name for the node with - \`/\`. - It is also possible to use glob matching to match node and port names. - Exact matches are prioritized. Don't forget to quote the string when - using globs, to avoid unwanted shell glob extension. - Default: none - --listen-timeout-secs - The listen command updates the output as soon as it receives an event - from PulseAudio. However, events are often accompanied by many other - useless ones, which may result in unnecessary consecutive output - updates. This script buffers the following events until a timeout is - reached to avoid this scenario, which lessens the CPU load on events. - However, this may result in noticeable latency when performing many - actions quickly (e.g., updating the volume with the mouse wheel). You - can specify what timeout to use to control the responsiveness, in - seconds. - Default: \"$LISTEN_TIMEOUT\" - -Actions: - help display this message and exit - output print the PulseAudio status once - listen listen for changes in PulseAudio to automatically update - this script's output - up, down increase or decrease the default node's volume - mute, unmute mute or unmute the default node's audio - togmute switch between muted and unmuted - next-node switch to the next available node - sync synchronize all the output streams volume to be the same as - the current node's volume - -Author: - Mario Ortiz Manero -More info on GitHub: - https://github.com/marioortizmanero/polybar-pulseaudio-control" -} - -# Obtains the value for an option and returns 1 if no shift is needed. -function getOptVal() { - if [[ "$1" = *=* ]]; then - val="${1//*=/}" - return 1 - fi - - val="$2" -} - -# Parsing the options from the arguments -while [[ "$1" = --* ]]; do - unset arg - unset val - - arg="$1" - case "$arg" in - --autosync) - AUTOSYNC=yes - ;; - --no-autosync) - AUTOSYNC=no - ;; - --color-muted|--colour-muted) - if getOptVal "$@"; then shift; fi - COLOR_MUTED="%{F#$val}" - ;; - --notifications) - NOTIFICATIONS=yes - ;; - --no-notifications) - NOTIFICATIONS=no - ;; - --osd) - OSD=yes - ;; - --no-osd) - OSD=no - ;; - --icon-muted) - if getOptVal "$@"; then shift; fi - ICON_MUTED="$val" - ;; - --icon-node) - if getOptVal "$@"; then shift; fi - # shellcheck disable=SC2034 - ICON_NODE="$val" - ;; - --icons-volume) - if getOptVal "$@"; then shift; fi - IFS=, read -r -a ICONS_VOLUME <<< "${val//[[:space:]]/}" - ;; - --volume-max) - if getOptVal "$@"; then shift; fi - VOLUME_MAX="$val" - ;; - --volume-step) - if getOptVal "$@"; then shift; fi - VOLUME_STEP="$val" - ;; - --node-blacklist) - if getOptVal "$@"; then shift; fi - IFS=, read -r -a NODE_BLACKLIST <<< "${val//[[:space:]]/}" - ;; - --node-nicknames-from) - if getOptVal "$@"; then shift; fi - NODE_NICKNAMES_PROP="$val" - ;; - --node-nickname) - if getOptVal "$@"; then shift; fi - NODE_NICKNAMES["${val//:*/}"]="${val//*:}" - ;; - --format) - if getOptVal "$@"; then shift; fi - FORMAT="$val" - ;; - --node-type) - if getOptVal "$@"; then shift; fi - if [[ "$val" != "output" && "$val" != "input" ]]; then - echo "node-type must be 'output' or 'input', got '$val'" >&2 - exit 1 - fi - NODE_TYPE="$val" - SINK_OR_SOURCE=$([ "$NODE_TYPE" == "output" ] && echo "ink" || echo "ource") - ;; - --listen-timeout-secs) - if getOptVal "$@"; then shift; fi - LISTEN_TIMEOUT="$val" - ;; - # Deprecated options, to be removed in a next release - --icon-sink) - echo "Replaced by --icon-node, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2 - exit 1 - ;; - --sink-blacklist) - echo "Replaced by --node-blacklist, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2 - exit 1 - ;; - --sink-nicknames-from) - echo "Replaced by --node-nicknames-from, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2 - exit 1 - ;; - --sink-nickname) - echo "Replaced by --node-nickname, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2 - exit 1 - ;; - # Undocumented because the `help` action already exists, but makes the - # help message more accessible. - --help) - usage - exit 0 - ;; - *) - echo "Unrecognised option: $arg" >&2 - exit 1 - ;; - esac - shift -done - -# Parsing the action from the arguments -case "$1" in - up) - volUp - ;; - down) - volDown - ;; - togmute) - volMute toggle - ;; - mute) - volMute mute - ;; - unmute) - volMute unmute - ;; - sync) - volSync - ;; - listen) - listen - ;; - next-node) - nextNode - ;; - output) - output - ;; - help) - usage - ;; - # Deprecated action, to be removed in a next release - next-sink) - echo "Replaced by next-node, see https://github.com/marioortizmanero/polybar-pulseaudio-control/releases/tag/v3.0.0" >&2 - exit 1 - ;; - "") - echo "No action specified. Run \`$0 help\` for more information." >&2 - ;; - *) - echo "Unrecognised action: $1" >&2 - exit 1 - ;; -esac diff --git a/scripts/system-bluetooth-bluetoothctl.sh b/scripts/system-bluetooth-bluetoothctl.sh deleted file mode 100755 index 70cb88b6..00000000 --- a/scripts/system-bluetooth-bluetoothctl.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh - -bluetooth_print() { - bluetoothctl | while read -r; do - if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then - if bluetoothctl show | grep -q "Powered: no"; then - echo "󰂲 " - else - printf '󰂯 ' - - devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2) - counter=0 - - for device in $devices_paired; do - device_info=$(bluetoothctl info "$device") - - if echo "$device_info" | grep -q "Connected: yes"; then - device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-) - - if [ $counter -gt 0 ]; then - printf ", %s" "$device_alias" - else - printf " %s" "$device_alias" - fi - - counter=$((counter + 1)) - fi - done - - printf '\n' - fi - else - echo "󰂲 " - fi - done -} - -bluetooth_toggle() { - if bluetoothctl show | grep -q "Powered: no"; then - bluetoothctl power on >> /dev/null - sleep 1 - - devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2) - echo "$devices_paired" | while read -r line; do - bluetoothctl connect "$line" >> /dev/null - done - else - devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2) - echo "$devices_paired" | while read -r line; do - bluetoothctl disconnect "$line" >> /dev/null - done - - bluetoothctl power off >> /dev/null - fi -} - -case "$1" in - --toggle) - bluetooth_toggle - ;; - *) - bluetooth_print - ;; -esac