diff --git a/.Xresources b/.Xresources index 3612e5d..d405b09 100644 --- a/.Xresources +++ b/.Xresources @@ -1,34 +1,36 @@ -*background: #1E1E2E -*foreground: #CDD6F4 +*background: #EFF1F5 +*foreground: #4C4F69 +*cursorColor: #666666 ! black -*color0: #45475A -*color8: #585B70 +*color0: #5C5F77 +*color8: #6C6F85 ! red -*color1: #F38BA8 -*color9: #F38BA8 +*color1: #D20F39 +*color9: #D20F39 ! green -*color2: #A6E3A1 -*color10: #A6E3A1 +*color2: #40A02B +*color10: #40A02B ! yellow -*color3: #F9E2AF -*color11: #F9E2AF +*color3: #DF8E1D +*color11: #DF8E1D ! blue -*color4: #89B4FA -*color12: #89B4FA +*color4: #1E66F5 +*color12: #1E66F5 ! magenta -*color5: #F5C2E7 -*color13: #F5C2E7 +*color5: #EA76CB +*color13: #EA76CB ! cyan -*color6: #94E2D5 -*color14: #94E2D5 +*color6: #179299 +*color14: #179299 ! white -*color7: #BAC2DE -*color15: #A6ADC8 +*color7: #ACB0BE +*color15: #BCC0CC + diff --git a/.config/nvim/LICENSE b/.config/nvim/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/.config/nvim/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/.config/nvim/README.md b/.config/nvim/README.md new file mode 100644 index 0000000..185280b --- /dev/null +++ b/.config/nvim/README.md @@ -0,0 +1,4 @@ +# ๐Ÿ’ค LazyVim + +A starter template for [LazyVim](https://github.com/LazyVim/LazyVim). +Refer to the [documentation](https://lazyvim.github.io/installation) to get started. diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index bde8e55..2514f9e 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,5 +1,2 @@ -require('rin.settings') -require('rin.plugins') -require('rin.keymaps') -require('rin.lsp') --- TODO: treesitter, telescope, NERDtree alt +-- bootstrap lazy.nvim, LazyVim and your plugins +require("config.lazy") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..778b6ce --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,54 @@ +{ + "LazyVim": { "branch": "main", "commit": "a72a84972d85e5bbc6b9d60a0983b37efef21b8a" }, + "LuaSnip": { "branch": "master", "commit": "ea7d7ea510c641c4f15042becd27f35b3e5b3c2b" }, + "SchemaStore.nvim": { "branch": "main", "commit": "c0874b9eb5e9aecd27e122ebfe7490516ac02bd3" }, + "bufferline.nvim": { "branch": "main", "commit": "9961d87bb3ec008213c46ba14b3f384a5f520eb5" }, + "catppuccin": { "branch": "main", "commit": "a937d546f4783a1ff67f84043d2d7871ad4ecd83" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "dressing.nvim": { "branch": "master", "commit": "c1e1d5fa44fe08811b6ef4aadac2b50e602f9504" }, + "flash.nvim": { "branch": "main", "commit": "8a8e74922a383c253b7f92e042b749150140c8d1" }, + "friendly-snippets": { "branch": "main", "commit": "ebf6d6e83494cdd88a54a429340256f4dbb6a052" }, + "gitsigns.nvim": { "branch": "main", "commit": "fef5d90953f0a730483b44745fae5938ba8227f8" }, + "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, + "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" }, + "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "dfdd771b792fbb4bad8e057d72558255695aa1a7" }, + "mason.nvim": { "branch": "main", "commit": "ee6a7f179ebf8aa9da9d53b1cf1b57d292ea0182" }, + "mini.ai": { "branch": "main", "commit": "7ae226f331885e6f30e9a8229e113debc59308ae" }, + "mini.bufremove": { "branch": "main", "commit": "7821606e35c1ac931b56d8e3155f45ffe76ee7e5" }, + "mini.comment": { "branch": "main", "commit": "877acea5b2a32ff55f808fc0ebe9aa898648318c" }, + "mini.indentscope": { "branch": "main", "commit": "f60e9b51a6214c73a170ffc5445ce91560981031" }, + "mini.pairs": { "branch": "main", "commit": "dfa9f6e2576bb8853be277d96b735af59d9be7c2" }, + "mini.starter": { "branch": "main", "commit": "c7e027558477838eac7109d8576ff1f2d9804845" }, + "mini.surround": { "branch": "main", "commit": "9d1956b576d7051da3a483b251dfc778121c60db" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "2d89ca96e08eb6e9c8e50e1bb4738bc5125c9f12" }, + "neoconf.nvim": { "branch": "main", "commit": "4a344462d45a08e81b19aa3d63d2bfe06404eec0" }, + "neodev.nvim": { "branch": "main", "commit": "dcd34653b0f1d3e7ea9aeb3e37dc7c8da445c4fe" }, + "noice.nvim": { "branch": "main", "commit": "74c2902146b080035beb19944baf6f014a954720" }, + "nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" }, + "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-lspconfig": { "branch": "master", "commit": "d177ad277a638f262edb73c75ffe33e377b95dc5" }, + "nvim-navic": { "branch": "master", "commit": "9c89730da6a05acfeb6a197e212dfadf5aa60ca0" }, + "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" }, + "nvim-spectre": { "branch": "master", "commit": "411cee67fe3f8242023eb8d9edafefbbfb2d06f1" }, + "nvim-treesitter": { "branch": "master", "commit": "c13e28f8947a9200e816038d85cb1302be11f8e6" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "9bff161dfece6ecf3459e6e46ca42e49f9ed939f" }, + "nvim-web-devicons": { "branch": "master", "commit": "ecdeb4e2a4af34fc873bbfbf1f4c4e447e632255" }, + "persistence.nvim": { "branch": "main", "commit": "4b8051c01f696d8849a5cb8afa9767be8db16e40" }, + "plenary.nvim": { "branch": "master", "commit": "a56bf0071bf63d35274fdc4738bb1e8821cfd2ea" }, + "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, + "telescope.nvim": { "branch": "master", "commit": "18f10f28007cb8b4d50324217349c3f568684be2" }, + "todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" }, + "tokyonight.nvim": { "branch": "main", "commit": "9a01eada39558dc3243278e6805d90e8dff45dc0" }, + "typescript.nvim": { "branch": "main", "commit": "4de85ef699d7e6010528dcfbddc2ed4c2c421467" }, + "vim-illuminate": { "branch": "master", "commit": "76f28e858f1caae87bfa45fb4fd09e4b053fc45b" }, + "vim-startuptime": { "branch": "master", "commit": "454b3de856b7bd298700de33d79774ca9b9e3875" }, + "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" } +} \ No newline at end of file diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim/lua/config/autocmds.lua new file mode 100644 index 0000000..27e9e06 --- /dev/null +++ b/.config/nvim/lua/config/autocmds.lua @@ -0,0 +1,3 @@ +-- Autocmds are automatically loaded on the VeryLazy event +-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua +-- Add any additional autocmds here diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..2c134f7 --- /dev/null +++ b/.config/nvim/lua/config/keymaps.lua @@ -0,0 +1,3 @@ +-- Keymaps are automatically loaded on the VeryLazy event +-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua +-- Add any additional keymaps here diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..891b190 --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,46 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + spec = { + -- add LazyVim and import its plugins + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + -- import any extras modules here + -- { import = "lazyvim.plugins.extras.lang.typescript" }, + -- { import = "lazyvim.plugins.extras.lang.json" }, + -- { import = "lazyvim.plugins.extras.ui.mini-animate" }, + -- import/override with your plugins + { import = "plugins" }, + }, + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = false, + -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, + -- have outdated releases, which may break your Neovim install. + version = false, -- always use the latest git commit + -- version = "*", -- try installing the latest stable version for plugins that support semver + }, + install = { colorscheme = { "tokyonight", "habamax" } }, + checker = { enabled = true }, -- automatically check for plugin updates + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..3ea1454 --- /dev/null +++ b/.config/nvim/lua/config/options.lua @@ -0,0 +1,3 @@ +-- Options are automatically loaded before lazy.nvim startup +-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua +-- Add any additional options here diff --git a/.config/nvim/lua/plugins/example.lua b/.config/nvim/lua/plugins/example.lua new file mode 100644 index 0000000..b14c1f3 --- /dev/null +++ b/.config/nvim/lua/plugins/example.lua @@ -0,0 +1,297 @@ +-- stylua: ignore + +-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim +-- +-- In your plugin files, you can: +-- * add extra plugins +-- * disable/enabled LazyVim plugins +-- * override the configuration of LazyVim plugins +return { + { + "catppuccin/nvim", + lazy = true, + name = "catppuccin", + opts = { + integrations = { + alpha = true, + cmp = true, + gitsigns = true, + illuminate = true, + indent_blankline = { enabled = true }, + lsp_trouble = true, + mason = true, + mini = true, + native_lsp = { + enabled = true, + underlines = { + errors = { "undercurl" }, + hints = { "undercurl" }, + warnings = { "undercurl" }, + information = { "undercurl" }, + }, + }, + navic = { enabled = true, custom_bg = "lualine" }, + neotest = true, + noice = true, + notify = true, + neotree = true, + semantic_tokens = true, + telescope = true, + treesitter = true, + which_key = true, + }, + }, + }, + + -- Configure LazyVim to load gruvbox + { + "LazyVim/LazyVim", + opts = { + colorscheme = "catppuccin-latte", + }, + }, + + -- change trouble config + { + "folke/trouble.nvim", + -- opts will be merged with the parent spec + opts = { use_diagnostic_signs = true }, + }, + + -- disable trouble + { "folke/trouble.nvim", enabled = false }, + + -- add symbols-outline + { + "simrat39/symbols-outline.nvim", + cmd = "SymbolsOutline", + keys = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, + config = true, + }, + + -- override nvim-cmp and add cmp-emoji + { + "hrsh7th/nvim-cmp", + dependencies = { "hrsh7th/cmp-emoji" }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + local cmp = require("cmp") + opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "emoji" } })) + end, + }, + + -- change some telescope options and a keymap to browse plugin files + { + "nvim-telescope/telescope.nvim", + keys = { + -- add a keymap to browse plugin files + -- stylua: ignore + { + "fp", + function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end, + desc = "Find Plugin File", + }, + }, + -- change some options + opts = { + defaults = { + layout_strategy = "horizontal", + layout_config = { prompt_position = "top" }, + sorting_strategy = "ascending", + winblend = 0, + }, + }, + }, + + -- add telescope-fzf-native + { + "telescope.nvim", + dependencies = { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + config = function() + require("telescope").load_extension("fzf") + end, + }, + }, + + -- add pyright to lspconfig + { + "neovim/nvim-lspconfig", + ---@class PluginLspOpts + opts = { + ---@type lspconfig.options + servers = { + -- pyright will be automatically installed with mason and loaded with lspconfig + pyright = {}, + }, + }, + }, + + -- add tsserver and setup with typescript.nvim instead of lspconfig + { + "neovim/nvim-lspconfig", + dependencies = { + "jose-elias-alvarez/typescript.nvim", + init = function() + require("lazyvim.util").on_attach(function(_, buffer) + -- stylua: ignore + vim.keymap.set( "n", "co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" }) + vim.keymap.set("n", "cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer }) + end) + end, + }, + ---@class PluginLspOpts + opts = { + ---@type lspconfig.options + servers = { + -- tsserver will be automatically installed with mason and loaded with lspconfig + tsserver = {}, + }, + -- you can do any additional lsp server setup here + -- return true if you don't want this server to be setup with lspconfig + ---@type table + setup = { + -- example to setup with typescript.nvim + tsserver = function(_, opts) + require("typescript").setup({ server = opts }) + return true + end, + -- Specify * to use this function as a fallback for any server + -- ["*"] = function(server, opts) end, + }, + }, + }, + + -- for typescript, LazyVim also includes extra specs to properly setup lspconfig, + -- treesitter, mason and typescript.nvim. So instead of the above, you can use: + { import = "lazyvim.plugins.extras.lang.typescript" }, + + -- add more treesitter parsers + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "bash", + "html", + "javascript", + "json", + "lua", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "tsx", + "typescript", + "vim", + "yaml", + }, + }, + }, + + -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above + -- would overwrite `ensure_installed` with the new value. + -- If you'd rather extend the default config, use the code below instead: + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + -- add tsx and treesitter + vim.list_extend(opts.ensure_installed, { + "tsx", + "typescript", + }) + end, + }, + + -- the opts function can also be used to change the default opts: + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + opts = function(_, opts) + table.insert(opts.sections.lualine_x, "๐Ÿ˜„") + end, + }, + + -- or you can return new options to override all the defaults + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + opts = function() + return { + --[[add your custom lualine config here]] + } + end, + }, + + -- use mini.starter instead of alpha + { import = "lazyvim.plugins.extras.ui.mini-starter" }, + + -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc + { import = "lazyvim.plugins.extras.lang.json" }, + + -- add any tools you want to have installed below + { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "stylua", + "shellcheck", + "shfmt", + "flake8", + }, + }, + }, + + -- Use for completion and snippets (supertab) + -- first: disable default and behavior in LuaSnip + { + "L3MON4D3/LuaSnip", + keys = function() + return {} + end, + }, + -- then: setup supertab in cmp + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-emoji", + }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + + local luasnip = require("luasnip") + local cmp = require("cmp") + + opts.mapping = vim.tbl_extend("force", opts.mapping, { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- this way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + 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" }), + }) + end, + }, +} diff --git a/.config/nvim/lua/rin/keymaps.lua b/.config/nvim/lua/rin/keymaps.lua deleted file mode 100644 index 8668b0d..0000000 --- a/.config/nvim/lua/rin/keymaps.lua +++ /dev/null @@ -1,34 +0,0 @@ -local function map(kind, lhs, rhs, opts) - vim.api.nvim_set_keymap(kind, lhs, rhs, opts) -end - -local sn = {noremap = true, silent = true} - --- Brackets -map('i', '\"', '\"\"', sn) -map('i', '\'', '\'\'', sn) -map('i', '(', '()', sn) -map('i', '[', '[]', sn) -map('i', '{', '{}', sn) -map('i', '{', '{}O', sn) -map('i', '{;', '{};O', sn) - --- Spell check toggle -map('n', '', ':set spell!', sn) -map('i', '', ':set spell!', sn) - --- Identation -map('v', '<', '', '>gv', sn) - --- Split navigation -map('n', '', 'h', sn) -map('n', '', 'j', sn) -map('n', '', 'k', sn) -map('n', '', 'l', sn) - --- Run Make -map('n', 'c', ':w! | !make ', sn) -map('n', 'n', ':NERDTreeToggle', sn) - -map('n', 'l', ':Limelight!! 0.5 ', sn) diff --git a/.config/nvim/lua/rin/lsp/init.lua b/.config/nvim/lua/rin/lsp/init.lua deleted file mode 100644 index cf7768f..0000000 --- a/.config/nvim/lua/rin/lsp/init.lua +++ /dev/null @@ -1,120 +0,0 @@ --- TODO: show function signature help on hover --- web, vimtex - --- 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) - --- 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) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- 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.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, 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', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufopts) -end - -local lsp_flags = { - -- This is the default in Nvim 0.7+ - debounce_text_changes = 150, -} - -local servers = { 'tsserver', 'rust_analyzer', 'clangd', 'sumneko_lua' } -local lspconfig = require('lspconfig') - -lspconfig['sumneko_lua'].setup { - on_attach = on_attach, - flags = lsp_flags, - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { 'vim' }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, -} - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, - } -end - -local luasnip = require 'luasnip' -local cmp = require 'cmp' -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = 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' }, - }, -} diff --git a/.config/nvim/lua/rin/plugins.lua b/.config/nvim/lua/rin/plugins.lua deleted file mode 100644 index b28dc29..0000000 --- a/.config/nvim/lua/rin/plugins.lua +++ /dev/null @@ -1,31 +0,0 @@ --- Automatically run :PackerCompile whenever plugins.lua is updated with an autocommand: -vim.api.nvim_create_autocmd('BufWritePost', { - group = vim.api.nvim_create_augroup('PACKER', { clear = true }), - pattern = 'plugins.lua', - command = 'source | PackerCompile', -}) - -require('mason').setup() - -return require('packer').startup(function(use) - use 'wbthomason/packer.nvim' - use 'glepnir/dashboard-nvim' - use 'joshdick/onedark.vim' - use 'itchyny/lightline.vim' - use 'scrooloose/nerdtree' - use 'tiagofumo/vim-nerdtree-syntax-highlight' - use 'ryanoasis/vim-devicons' - use 'ap/vim-css-color' - use 'vim-syntastic/syntastic' - use 'rhysd/vim-clang-format' - use 'lambdalisue/suda.vim' - use 'neovim/nvim-lspconfig' - use 'jackguo380/vim-lsp-cxx-highlight' - use 'williamboman/mason.nvim' - use 'hrsh7th/nvim-cmp' -- Autocompletion plugin - use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp - use 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp - use 'L3MON4D3/LuaSnip' -- Snippets plugin - -- TODO: add telescope and other useful plugins -end) - diff --git a/.config/nvim/lua/rin/settings.lua b/.config/nvim/lua/rin/settings.lua deleted file mode 100644 index 429dfd0..0000000 --- a/.config/nvim/lua/rin/settings.lua +++ /dev/null @@ -1,81 +0,0 @@ -local g = vim.g -local o = vim.o -local api = vim.api -local opt = vim.opt -local cmd = vim.cmd -local home = os.getenv('HOME') - --- Decrease update time -o.timeoutlen = 500 -o.updatetime = 200 - --- Number of screen lines to keep above and below the cursor -o.scrolloff = 8 - -o.number = true -o.relativenumber = true -o.signcolumn = 'yes:1' - -o.expandtab = true --- o.smarttab = true -o.cindent = true --- o.autoindent = true - -o.wrap = false -o.textwidth = 300 -o.tabstop = 4 -o.shiftwidth = 0 -o.softtabstop = -1 -- If negative, shiftwidth value is used -o.list = true -o.listchars = 'trail:ยท,nbsp:โ—‡,tab:โ†’ ,extends:โ–ธ,precedes:โ—‚' - --- OS clipboard -o.clipboard = 'unnamedplus' - --- Mouse in all modes -opt.mouse = 'a' - --- Case insensitive searching UNLESS /C or capital in search -o.ignorecase = true -o.smartcase = true - -o.backup = false -o.writebackup = false -o.undofile = true -o.undodir = home .. '/.vim/undodir' -o.swapfile = false - -o.splitright = true -o.splitbelow = true - -g.lightline = {colorscheme = 'onedark'} - -g.mapleader = ' ' -g.maplocalleader = ' ' - -o.termguicolors = true - -api.nvim_create_autocmd('ColorScheme', { - command = [[ - highlight clear CursorLine - highlight Normal ctermbg=none - highlight Normal guibg=none - highlight LineNr ctermbg=none - highlight LineNr guibg=none - highlight Folded ctermbg=none - highlight Folded guibg=none - highlight NonText ctermbg=none - highlight NonText guibg=none - highlight SpecialKey ctermbg=none - highlight SpecialKey guibg=none - highlight VertSplit ctermbg=none - highlight VertSplit guibg=none - highlight SignColumn ctermbg=none - highlight SignColumn guibg=none - ]] -}) -cmd('colorscheme onedark') - --- BUG: this won't update the search count after pressing `n` or `N` --- When running macros and regexes on a large file, lazy redraw tells neovim/vim not to draw the screen --- o.lazyredraw = true diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua deleted file mode 100644 index d3637b2..0000000 --- a/.config/nvim/plugin/packer_compiled.lua +++ /dev/null @@ -1,184 +0,0 @@ --- Automatically generated packer.nvim plugin loader code - -if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then - vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') - return -end - -vim.api.nvim_command('packadd packer.nvim') - -local no_errors, error_msg = pcall(function() - -_G._packer = _G._packer or {} -_G._packer.inside_compile = true - -local time -local profile_info -local should_profile = false -if should_profile then - local hrtime = vim.loop.hrtime - profile_info = {} - time = function(chunk, start) - if start then - profile_info[chunk] = hrtime() - else - profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 - end - end -else - time = function(chunk, start) end -end - -local function save_profiles(threshold) - local sorted_times = {} - for chunk_name, time_taken in pairs(profile_info) do - sorted_times[#sorted_times + 1] = {chunk_name, time_taken} - end - table.sort(sorted_times, function(a, b) return a[2] > b[2] end) - local results = {} - for i, elem in ipairs(sorted_times) do - if not threshold or threshold and elem[2] > threshold then - results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' - end - end - if threshold then - table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') - end - - _G._packer.profile_output = results -end - -time([[Luarocks path setup]], true) -local package_path_str = "/home/rinri/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/rinri/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/rinri/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/rinri/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" -local install_cpath_pattern = "/home/rinri/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" -if not string.find(package.path, package_path_str, 1, true) then - package.path = package.path .. ';' .. package_path_str -end - -if not string.find(package.cpath, install_cpath_pattern, 1, true) then - package.cpath = package.cpath .. ';' .. install_cpath_pattern -end - -time([[Luarocks path setup]], false) -time([[try_loadstring definition]], true) -local function try_loadstring(s, component, name) - local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) - if not success then - vim.schedule(function() - vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) - end) - end - return result -end - -time([[try_loadstring definition]], false) -time([[Defining packer_plugins]], true) -_G.packer_plugins = { - LuaSnip = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/LuaSnip", - url = "https://github.com/L3MON4D3/LuaSnip" - }, - ["cmp-nvim-lsp"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", - url = "https://github.com/hrsh7th/cmp-nvim-lsp" - }, - cmp_luasnip = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/cmp_luasnip", - url = "https://github.com/saadparwaiz1/cmp_luasnip" - }, - ["dashboard-nvim"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/dashboard-nvim", - url = "https://github.com/glepnir/dashboard-nvim" - }, - ["lightline.vim"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/lightline.vim", - url = "https://github.com/itchyny/lightline.vim" - }, - ["mason.nvim"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/mason.nvim", - url = "https://github.com/williamboman/mason.nvim" - }, - nerdtree = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/nerdtree", - url = "https://github.com/scrooloose/nerdtree" - }, - ["nvim-cmp"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/nvim-cmp", - url = "https://github.com/hrsh7th/nvim-cmp" - }, - ["nvim-lspconfig"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", - url = "https://github.com/neovim/nvim-lspconfig" - }, - ["onedark.vim"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/onedark.vim", - url = "https://github.com/joshdick/onedark.vim" - }, - ["packer.nvim"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/packer.nvim", - url = "https://github.com/wbthomason/packer.nvim" - }, - ["suda.vim"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/suda.vim", - url = "https://github.com/lambdalisue/suda.vim" - }, - syntastic = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/syntastic", - url = "https://github.com/vim-syntastic/syntastic" - }, - ["vim-clang-format"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/vim-clang-format", - url = "https://github.com/rhysd/vim-clang-format" - }, - ["vim-css-color"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/vim-css-color", - url = "https://github.com/ap/vim-css-color" - }, - ["vim-devicons"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/vim-devicons", - url = "https://github.com/ryanoasis/vim-devicons" - }, - ["vim-lsp-cxx-highlight"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/vim-lsp-cxx-highlight", - url = "https://github.com/jackguo380/vim-lsp-cxx-highlight" - }, - ["vim-nerdtree-syntax-highlight"] = { - loaded = true, - path = "/home/rinri/.local/share/nvim/site/pack/packer/start/vim-nerdtree-syntax-highlight", - url = "https://github.com/tiagofumo/vim-nerdtree-syntax-highlight" - } -} - -time([[Defining packer_plugins]], false) - -_G._packer.inside_compile = false -if _G._packer.needs_bufread == true then - vim.cmd("doautocmd BufRead") -end -_G._packer.needs_bufread = false - -if should_profile then save_profiles() end - -end) - -if not no_errors then - error_msg = error_msg:gsub('"', '\\"') - vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') -end diff --git a/.config/nvim/stylua.toml b/.config/nvim/stylua.toml new file mode 100644 index 0000000..5d6c50d --- /dev/null +++ b/.config/nvim/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 120 \ No newline at end of file diff --git a/.config/picom/picom.conf b/.config/picom/picom.conf index f7354f0..7fcd0a3 100644 --- a/.config/picom/picom.conf +++ b/.config/picom/picom.conf @@ -8,14 +8,14 @@ glx-no-rebind-pixmap = true; opacity-rule = [ "90:class_g = 'URxvt'", "90:class_g = 'Alacritty'", - "95:class_g = 'St' && focused", - "87:class_g = 'St' && !focused", + "100:class_g = 'St' && focused", + "95:class_g = 'St' && !focused", "95:class_g = 'cmus' && focused", "87:class_g = 'cmus' && !focused", "95:class_g = 'cpsrc' && focused", "87:class_g = 'cpsrc' && !focused", "90:class_g = 'tabbed'", - "95:class_g = 'Emacs'", + "100:class_g = 'Emacs'", ]; # Blur diff --git a/.xinitrc b/.xinitrc index ed2dde5..db4749b 100755 --- a/.xinitrc +++ b/.xinitrc @@ -1,4 +1,6 @@ -export PATH=$PATH:/home/rinri/scripts:/home/rinri/scripts/Discord:/home/rinri/.local/bin +#!/bin/sh + +export PATH="$PATH:/home/rinri/scripts:/home/rinri/.local/bin" while true; do # Log stderror to a file dwm 2> ~/.dwm.log diff --git a/.zshrc b/.zshrc index 98f5652..6d4fe12 100755 --- a/.zshrc +++ b/.zshrc @@ -37,10 +37,10 @@ bindkey -v # The following lines were added by compinstall zstyle :compinstall filename '/home/rinri/.zshrc' -autoload -U compinit -zmodload zsh/complist -compinit -_comp_options+=(globdots) +#autoload -U compinit +#zmodload zsh/complist +#compinit +#_comp_options+=(globdots) bindkey -s '^o' 'fzfcd\n' bindkey -M viins '\e.' insert-last-word @@ -69,3 +69,6 @@ export FZF_DEFAULT_OPTS="--height 50% -1 --reverse --multi --inline-info --previ if [ -e /home/rinri/.nix-profile/etc/profile.d/nix.sh ]; then . /home/rinri/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer eval "$(starship init zsh)" + +autoload -U +X bashcompinit && bashcompinit +complete -o nospace -C /usr/bin/terraform terraform diff --git a/README.md b/README.md index 261b069..ad2db36 100755 --- a/README.md +++ b/README.md @@ -11,19 +11,3 @@ - Notifications: [dunst](https://github.com/dunst-project/dunst) - Status bar: [slstatus](https://tools.suckless.org/slstatus/) - Wallpaper: [pixiv](https://www.pixiv.net/member_illust.php?mode=medium&illust_id=47154393) - -## Screenshots - -![clear](clear.jpg) - -![neofetch](neofetch.jpg) - -![cmus](cmus.jpg) - -![neovim](vim.jpg) - -![doom emacs](emacs.jpg) - -![dunst](dunst.jpg) - -![firefox](firefox.jpg) diff --git a/clear.jpg b/clear.jpg deleted file mode 100644 index c0009e4..0000000 Binary files a/clear.jpg and /dev/null differ diff --git a/cmus.jpg b/cmus.jpg deleted file mode 100644 index cba56d7..0000000 Binary files a/cmus.jpg and /dev/null differ diff --git a/dunst.jpg b/dunst.jpg deleted file mode 100644 index ef2c623..0000000 Binary files a/dunst.jpg and /dev/null differ diff --git a/emacs.jpg b/emacs.jpg deleted file mode 100644 index 2049497..0000000 Binary files a/emacs.jpg and /dev/null differ diff --git a/firefox.jpg b/firefox.jpg deleted file mode 100644 index d788a78..0000000 Binary files a/firefox.jpg and /dev/null differ diff --git a/neofetch.jpg b/neofetch.jpg deleted file mode 100644 index b4a23d5..0000000 Binary files a/neofetch.jpg and /dev/null differ diff --git a/scripts/.gitignore b/scripts/.gitignore deleted file mode 100644 index 0f8323f..0000000 --- a/scripts/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -anime.sh -upload.sh -download.sh \ No newline at end of file diff --git a/scripts/automount.sh b/scripts/automount.sh new file mode 100755 index 0000000..71de288 --- /dev/null +++ b/scripts/automount.sh @@ -0,0 +1 @@ +mount -a \ No newline at end of file diff --git a/scripts/daily.sh b/scripts/daily.sh deleted file mode 100755 index 0491eab..0000000 --- a/scripts/daily.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/home/rinri/scripts/root-notify.sh "Daily Fortune" "$(fortune|cowsay -W 35)" diff --git a/scripts/discord b/scripts/discord new file mode 100755 index 0000000..7155011 --- /dev/null +++ b/scripts/discord @@ -0,0 +1,2 @@ +#!/bin/sh +~/scripts/Discord/Discord \ No newline at end of file diff --git a/scripts/dublicatescreen.sh b/scripts/dublicatescreen.sh new file mode 100755 index 0000000..bf38080 --- /dev/null +++ b/scripts/dublicatescreen.sh @@ -0,0 +1 @@ +xrandr --output HDMI-1 --same-as eDP-1 \ No newline at end of file diff --git a/scripts/mute.sh b/scripts/mute.sh index e0a89ab..409d05a 100755 --- a/scripts/mute.sh +++ b/scripts/mute.sh @@ -1,13 +1,13 @@ #!/bin/sh -card=$(aplay -l | grep Analog | awk '{print $2}' | head -c-2) +card=$(aplay -l | grep CODEC | awk '{print $2}' | head -c-2) if [ "$(amixer -c"$card" get "Capture" | grep -c "\[on\]")" -gt 0 ]; then - [ $# -ge 1 ] && amixer -c"$card" set 'Capture' nocap - [ $# -ge 1 ] && notify-send -t 700 -i "mic-off" "Microphone Muted!" - printf "๏„ฐ" + [ $# -ge 1 ] && amixer -c"$card" set 'Capture' nocap + [ $# -ge 1 ] && notify-send -t 700 -i "mic-off" "Microphone Muted!" + printf "๏„ฐ" else - [ $# -ge 1 ] && amixer -c"$card" set 'Capture' cap - [ $# -ge 1 ] && notify-send -t 700 -i "mic-on" "Microphone Activated!" - printf "๏„ฑ" + [ $# -ge 1 ] && amixer -c"$card" set 'Capture' cap + [ $# -ge 1 ] && notify-send -t 700 -i "mic-on" "Microphone Activated!" + printf "๏„ฑ" fi diff --git a/scripts/paste-image.sh b/scripts/paste-image.sh new file mode 100755 index 0000000..528adaf --- /dev/null +++ b/scripts/paste-image.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +xclip -selection clipboard -t image/jpg -o > "$1" diff --git a/scripts/pfetch b/scripts/pfetch new file mode 100755 index 0000000..7aaa9bc --- /dev/null +++ b/scripts/pfetch @@ -0,0 +1,1830 @@ +#!/bin/sh +# +# pfetch - Simple POSIX sh fetch script. + +# Wrapper around all escape sequences used by pfetch to allow for +# greater control over which sequences are used (if any at all). +esc() { + case $1 in + CUU) e="${esc_c}[${2}A" ;; # cursor up + CUD) e="${esc_c}[${2}B" ;; # cursor down + CUF) e="${esc_c}[${2}C" ;; # cursor right + CUB) e="${esc_c}[${2}D" ;; # cursor left + + # text formatting + SGR) + case ${PF_COLOR:=1} in + (1) + e="${esc_c}[${2}m" + ;; + + (0) + # colors disabled + e= + ;; + esac + ;; + + # line wrap + DECAWM) + case $TERM in + (dumb | minix | cons25) + # not supported + e= + ;; + + (*) + e="${esc_c}[?7${2}" + ;; + esac + ;; + esac +} + +# Print a sequence to the terminal. +esc_p() { + esc "$@" + printf '%s' "$e" +} + +# This is just a simple wrapper around 'command -v' to avoid +# spamming '>/dev/null' throughout this function. This also guards +# against aliases and functions. +has() { + _cmd=$(command -v "$1") 2>/dev/null || return 1 + [ -x "$_cmd" ] || return 1 +} + +log() { + # The 'log()' function handles the printing of information. + # In 'pfetch' (and 'neofetch'!) the printing of the ascii art and info + # happen independently of each other. + # + # The size of the ascii art is stored and the ascii is printed first. + # Once the ascii is printed, the cursor is located right below the art + # (See marker $[1]). + # + # Using the stored ascii size, the cursor is then moved to marker $[2]. + # This is simply a cursor up escape sequence using the "height" of the + # ascii art. + # + # 'log()' then moves the cursor to the right the "width" of the ascii art + # with an additional amount of padding to add a gap between the art and + # the information (See marker $[3]). + # + # When 'log()' has executed, the cursor is then located at marker $[4]. + # When 'log()' is run a second time, the next line of information is + # printed, moving the cursor to marker $[5]. + # + # Markers $[4] and $[5] repeat all the way down through the ascii art + # until there is no more information left to print. + # + # Every time 'log()' is called the script keeps track of how many lines + # were printed. When printing is complete the cursor is then manually + # placed below the information and the art according to the "heights" + # of both. + # + # The math is simple: move cursor down $((ascii_height - info_height)). + # If the aim is to move the cursor from marker $[5] to marker $[6], + # plus the ascii height is 8 while the info height is 2 it'd be a move + # of 6 lines downwards. + # + # However, if the information printed is "taller" (takes up more lines) + # than the ascii art, the cursor isn't moved at all! + # + # Once the cursor is at marker $[6], the script exits. This is the gist + # of how this "dynamic" printing and layout works. + # + # This method allows ascii art to be stored without markers for info + # and it allows for easy swapping of info order and amount. + # + # $[2] ___ $[3] goldie@KISS + # $[4](.ยท | $[5] os KISS Linux + # (<> | + # / __ \ + # ( / \ /| + # _/\ __)/_) + # \/-____\/ + # $[1] + # + # $[6] /home/goldie $ + + # End here if no data was found. + [ "$2" ] || return + + # Store the value of '$1' as we reset the argument list below. + name=$1 + + # Use 'set --' as a means of stripping all leading and trailing + # white-space from the info string. This also normalizes all + # white-space inside of the string. + # + # Disable the shellcheck warning for word-splitting + # as it's safe and intended ('set -f' disables globbing). + # shellcheck disable=2046,2086 + { + set -f + set +f -- $2 + info=$* + } + + # Move the cursor to the right, the width of the ascii art with an + # additional gap for text spacing. + esc_p CUF "$ascii_width" + + # Print the info name and color the text. + esc_p SGR "3${PF_COL1-4}"; + esc_p SGR 1 + printf '%s' "$name" + esc_p SGR 0 + + # Print the info name and info data separator. + printf %s "$PF_SEP" + + # Move the cursor backward the length of the *current* info name and + # then move it forwards the length of the *longest* info name. This + # aligns each info data line. + esc_p CUB "${#name}" + esc_p CUF "${PF_ALIGN:-$info_length}" + + # Print the info data, color it and strip all leading whitespace + # from the string. + esc_p SGR "3${PF_COL2-7}" + printf '%s' "$info" + esc_p SGR 0 + printf '\n' + + # Keep track of the number of times 'log()' has been run. + info_height=$((${info_height:-0} + 1)) +} + +get_title() { + # Username is retrieved by first checking '$USER' with a fallback + # to the 'id -un' command. + user=${USER:-$(id -un)} + + # Hostname is retrieved by first checking '$HOSTNAME' with a fallback + # to the 'hostname' command. + # + # Disable the warning about '$HOSTNAME' being undefined in POSIX sh as + # the intention for using it is allowing the user to overwrite the + # value on invocation. + # shellcheck disable=SC2039 + host=${HOSTNAME:-${host:-$(hostname)}} + + # If the hostname is still not found, fallback to the contents of the + # /etc/hostname file. + [ "$host" ] || read -r host < /etc/hostname + + # Add escape sequences for coloring to user and host name. As we embed + # them directly in the arguments passed to log(), we cannot use esc_p(). + esc SGR 1 + user=$e$user + esc SGR "3${PF_COL3:-1}" + user=$e$user + esc SGR 1 + user=$user$e + esc SGR 1 + host=$e$host + esc SGR "3${PF_COL3:-1}" + host=$e$host + + log "${user}@${host}" " " >&6 +} + +get_os() { + # This function is called twice, once to detect the distribution name + # for the purposes of picking an ascii art early and secondly to display + # the distribution name in the info output (if enabled). + # + # On first run, this function displays _nothing_, only on the second + # invocation is 'log()' called. + [ "$distro" ] && { + log os "$distro" >&6 + return + } + + case $os in + (Linux*) + # Some Linux distributions (which are based on others) + # fail to identify as they **do not** change the upstream + # distribution's identification packages or files. + # + # It is senseless to add a special case in the code for + # each and every distribution (which _is_ technically no + # different from what it is based on) as they're either too + # lazy to modify upstream's identification files or they + # don't have the know-how (or means) to ship their own + # lsb-release package. + # + # This causes users to think there's a bug in system detection + # tools like neofetch or pfetch when they technically *do* + # function correctly. + # + # Exceptions are made for distributions which are independent, + # not based on another distribution or follow different + # standards. + # + # This applies only to distributions which follow the standard + # by shipping unmodified identification files and packages + # from their respective upstreams. + if has lsb_release; then + distro=$(lsb_release -sd) + + # Android detection works by checking for the existence of + # the follow two directories. I don't think there's a simpler + # method than this. + elif [ -d /system/app ] && [ -d /system/priv-app ]; then + distro="Android $(getprop ro.build.version.release)" + + else + # This used to be a simple '. /etc/os-release' but I believe + # this is insecure as we blindly executed whatever was in the + # file. This parser instead simply handles 'key=val', treating + # the file contents as plain-text. + while IFS='=' read -r key val; do + case $key in + (PRETTY_NAME) + distro=$val + ;; + esac + done < /etc/os-release + fi + + # 'os-release' and 'lsb_release' sometimes add quotes + # around the distribution name, strip them. + distro=${distro##[\"\']} + distro=${distro%%[\"\']} + + # Special cases for (independent) distributions which + # don't follow any os-release/lsb standards whatsoever. + has crux && distro=$(crux) + has guix && distro='Guix System' + + # Check to see if we're running Bedrock Linux which is + # very unique. This simply checks to see if the user's + # PATH contains a Bedrock specific value. + case $PATH in + (*/bedrock/cross/*) + distro='Bedrock Linux' + ;; + esac + + # Check to see if Linux is running in Windows 10 under + # WSL1 (Windows subsystem for Linux [version 1]) and + # append a string accordingly. + # + # If the kernel version string ends in "-Microsoft", + # we're very likely running under Windows 10 in WSL1. + if [ "$WSLENV" ]; then + distro="${distro}${WSLENV+ on Windows 10 [WSL2]}" + + # Check to see if Linux is running in Windows 10 under + # WSL2 (Windows subsystem for Linux [version 2]) and + # append a string accordingly. + # + # This checks to see if '$WSLENV' is defined. This + # appends the Windows 10 string even if '$WSLENV' is + # empty. We only need to check that is has been _exported_. + elif [ -z "${kernel%%*-Microsoft}" ]; then + distro="$distro on Windows 10 [WSL1]" + fi + ;; + + (Darwin*) + # Parse the SystemVersion.plist file to grab the macOS + # version. The file is in the following format: + # + # ProductVersion + # 10.14.6 + # + # 'IFS' is set to '<>' to enable splitting between the + # keys and a second 'read' is used to operate on the + # next line directly after a match. + # + # '_' is used to nullify a field. '_ _ line _' basically + # says "populate $line with the third field's contents". + while IFS='<>' read -r _ _ line _; do + case $line in + # Match 'ProductVersion' and read the next line + # directly as it contains the key's value. + ProductVersion) + IFS='<>' read -r _ _ mac_version _ + continue + ;; + + ProductName) + IFS='<>' read -r _ _ mac_product _ + continue + ;; + esac + done < /System/Library/CoreServices/SystemVersion.plist + + # Use the ProductVersion to determine which macOS/OS X codename + # the system has. As far as I'm aware there's no "dynamic" way + # of grabbing this information. + case $mac_version in + (10.4*) distro='Mac OS X Tiger' ;; + (10.5*) distro='Mac OS X Leopard' ;; + (10.6*) distro='Mac OS X Snow Leopard' ;; + (10.7*) distro='Mac OS X Lion' ;; + (10.8*) distro='OS X Mountain Lion' ;; + (10.9*) distro='OS X Mavericks' ;; + (10.10*) distro='OS X Yosemite' ;; + (10.11*) distro='OS X El Capitan' ;; + (10.12*) distro='macOS Sierra' ;; + (10.13*) distro='macOS High Sierra' ;; + (10.14*) distro='macOS Mojave' ;; + (10.15*) distro='macOS Catalina' ;; + (11*) distro='macOS Big Sur' ;; + (*) distro='macOS' ;; + esac + + # Use the ProductName to determine if we're running in iOS. + case $mac_product in + (iP*) distro='iOS' ;; + esac + + distro="$distro $mac_version" + ;; + + (Haiku) + # Haiku uses 'uname -v' for version information + # instead of 'uname -r' which only prints '1'. + distro=$(uname -sv) + ;; + + (Minix|DragonFly) + distro="$os $kernel" + + # Minix and DragonFly don't support the escape + # sequences used, clear the exit trap. + trap '' EXIT + ;; + + (SunOS) + # Grab the first line of the '/etc/release' file + # discarding everything after '('. + IFS='(' read -r distro _ < /etc/release + ;; + + (OpenBSD*) + # Show the OpenBSD version type (current if present). + # kern.version=OpenBSD 6.6-current (GENERIC.MP) ... + IFS=' =' read -r _ distro openbsd_ver _ <<-EOF + $(sysctl kern.version) + EOF + + distro="$distro $openbsd_ver" + ;; + + FreeBSD) + distro="$os $(freebsd-version)" + ;; + + (*) + # Catch all to ensure '$distro' is never blank. + # This also handles the BSDs. + distro="$os $kernel" + ;; + esac +} + +get_kernel() { + case $os in + # Don't print kernel output on some systems as the + # OS name includes it. + (*BSD*|Haiku|Minix) + return + ;; + esac + + # '$kernel' is the cached output of 'uname -r'. + log kernel "$kernel" >&6 +} + +get_host() { + case $os in + (Linux*) + # Despite what these files are called, version doesn't + # always contain the version nor does name always contain + # the name. + read -r name < /sys/devices/virtual/dmi/id/product_name + read -r version < /sys/devices/virtual/dmi/id/product_version + read -r model < /sys/firmware/devicetree/base/model + + host="$name $version $model" + ;; + + (Darwin* | FreeBSD* | DragonFly*) + host=$(sysctl -n hw.model) + ;; + + (NetBSD*) + host=$(sysctl -n machdep.dmi.system-vendor \ + machdep.dmi.system-product) + ;; + + (OpenBSD*) + host=$(sysctl -n hw.version) + ;; + + (*BSD* | Minix) + host=$(sysctl -n hw.vendor hw.product) + ;; + esac + + # Turn the host string into an argument list so we can iterate + # over it and remove OEM strings and other information which + # shouldn't be displayed. + # + # Disable the shellcheck warning for word-splitting + # as it's safe and intended ('set -f' disables globbing). + # shellcheck disable=2046,2086 + { + set -f + set +f -- $host + host= + } + + # Iterate over the host string word by word as a means of stripping + # unwanted and OEM information from the string as a whole. + # + # This could have been implemented using a long 'sed' command with + # a list of word replacements, however I want to show that something + # like this is possible in pure sh. + # + # This string reconstruction is needed as some OEMs either leave the + # identification information as "To be filled by OEM", "Default", + # "undefined" etc and we shouldn't print this to the screen. + for word do + # This works by reconstructing the string by excluding words + # found in the "blacklist" below. Only non-matches are appended + # to the final host string. + case $word in + (To | [Bb]e | [Ff]illed | [Bb]y | O.E.M. | OEM |\ + Not | Applicable | Specified | System | Product | Name |\ + Version | Undefined | Default | string | INVALID | ๏ฟฝ | os |\ + Type1ProductConfigId ) + continue + ;; + esac + + host="$host$word " + done + + # '$arch' is the cached output from 'uname -m'. + log host "${host:-$arch}" >&6 +} + +get_uptime() { + # Uptime works by retrieving the data in total seconds and then + # converting that data into days, hours and minutes using simple + # math. + case $os in + (Linux* | Minix*) + IFS=. read -r s _ < /proc/uptime + ;; + + Darwin* | *BSD* | DragonFly*) + s=$(sysctl -n kern.boottime) + + # Extract the uptime in seconds from the following output: + # [...] { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46 2010 + s=${s#*=} + s=${s%,*} + + # The uptime format from 'sysctl' needs to be subtracted from + # the current time in seconds. + s=$(($(date +%s) - s)) + ;; + + (Haiku) + # The boot time is returned in microseconds, convert it to + # regular seconds. + s=$(($(system_time) / 1000000)) + ;; + + (SunOS) + # Split the output of 'kstat' on '.' and any white-space + # which exists in the command output. + # + # The output is as follows: + # unix:0:system_misc:snaptime 14809.906993005 + # + # The parser extracts: ^^^^^ + IFS=' .' read -r _ s _ <<-EOF + $(kstat -p unix:0:system_misc:snaptime) + EOF + ;; + + (IRIX) + # Grab the uptime in a pretty format. Usually, + # 00:00:00 from the 'ps' command. + t=$(LC_ALL=POSIX ps -o etime= -p 1) + + # Split the pretty output into days or hours + # based on the uptime. + case $t in + (*-*) d=${t%%-*} t=${t#*-} ;; + (*:*:*) h=${t%%:*} t=${t#*:} ;; + esac + + h=${h#0} t=${t#0} + + # Convert the split pretty fields back into + # seconds so we may re-convert them to our format. + s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:})) + ;; + esac + + # Convert the uptime from seconds into days, hours and minutes. + d=$((s / 60 / 60 / 24)) + h=$((s / 60 / 60 % 24)) + m=$((s / 60 % 60)) + + # Only append days, hours and minutes if they're non-zero. + case "$d" in ([!0]*) uptime="${uptime}${d}d "; esac + case "$h" in ([!0]*) uptime="${uptime}${h}h "; esac + case "$m" in ([!0]*) uptime="${uptime}${m}m "; esac + + log uptime "${uptime:-0m}" >&6 +} + +get_pkgs() { + # This works by first checking for which package managers are + # installed and finally by printing each package manager's + # package list with each package one per line. + # + # The output from this is then piped to 'wc -l' to count each + # line, giving us the total package count of whatever package + # managers are installed. + # + # Backticks are *required* here as '/bin/sh' on macOS is + # 'bash 3.2' and it can't handle the following: + # + # var=$( + # code here + # ) + # + # shellcheck disable=2006 + packages=` + case $os in + (Linux*) + # Commands which print packages one per line. + has bonsai && bonsai list + has crux && pkginfo -i + has pacman-key && pacman -Qq + has dpkg && dpkg-query -f '.\n' -W + has rpm && rpm -qa + has xbps-query && xbps-query -l + has apk && apk info + has guix && guix package --list-installed + has opkg && opkg list-installed + + # Directories containing packages. + has kiss && printf '%s\n' /var/db/kiss/installed/*/ + has cpt-list && printf '%s\n' /var/db/cpt/installed/*/ + has brew && printf '%s\n' "$(brew --cellar)/"* + has emerge && printf '%s\n' /var/db/pkg/*/*/ + has pkgtool && printf '%s\n' /var/log/packages/* + has eopkg && printf '%s\n' /var/lib/eopkg/package/* + + # 'nix' requires two commands. + has nix-store && { + nix-store -q --requisites /run/current-system/sw + nix-store -q --requisites ~/.nix-profile + } + ;; + + (Darwin*) + # Commands which print packages one per line. + has pkgin && pkgin list + has dpkg && dpkg-query -f '.\n' -W + + # Directories containing packages. + has brew && printf '%s\n' /usr/local/Cellar/* + + # 'port' prints a single line of output to 'stdout' + # when no packages are installed and exits with + # success causing a false-positive of 1 package + # installed. + # + # 'port' should really exit with a non-zero code + # in this case to allow scripts to cleanly handle + # this behavior. + has port && { + pkg_list=$(port installed) + + case "$pkg_list" in + ("No ports are installed.") + # do nothing + ;; + + (*) + printf '%s\n' "$pkg_list" + ;; + esac + } + ;; + + (FreeBSD*|DragonFly*) + pkg info + ;; + + (OpenBSD*) + printf '%s\n' /var/db/pkg/*/ + ;; + + (NetBSD*) + pkg_info + ;; + + (Haiku) + printf '%s\n' /boot/system/package-links/* + ;; + + (Minix) + printf '%s\n' /usr/pkg/var/db/pkg/*/ + ;; + + (SunOS) + has pkginfo && pkginfo -i + has pkg && pkg list + ;; + + (IRIX) + versions -b + ;; + esac | wc -l + ` + + case $os in + # IRIX's package manager adds 3 lines of extra + # output which we must account for here. + (IRIX) + packages=$((packages - 3)) + ;; + + # OpenBSD's wc prints whitespace before the output + # which needs to be stripped. + (OpenBSD) + packages=$((packages)) + ;; + esac + + case $packages in + (1?*|[2-9]*) + log pkgs "$packages" >&6 + ;; + esac +} + +get_memory() { + case $os in + # Used memory is calculated using the following "formula": + # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable + # Source: https://github.com/KittyKatt/screenFetch/issues/386 + (Linux*) + # Parse the '/proc/meminfo' file splitting on ':' and 'k'. + # The format of the file is 'key: 000kB' and an additional + # split is used on 'k' to filter out 'kB'. + while IFS=':k ' read -r key val _; do + case $key in + (MemTotal) + mem_used=$((mem_used + val)) + mem_full=$val + ;; + + (Shmem) + mem_used=$((mem_used + val)) + ;; + + (MemFree | Buffers | Cached | SReclaimable) + mem_used=$((mem_used - val)) + ;; + + # If detected this will be used over the above calculation + # for mem_used. Available since Linux 3.14rc. + # See kernel commit 34e431b0ae398fc54ea69ff85ec700722c9da773 + (MemAvailable) + mem_avail=$val + ;; + esac + done < /proc/meminfo + + case $mem_avail in + (*[0-9]*) + mem_used=$(((mem_full - mem_avail) / 1024)) + ;; + + *) + mem_used=$((mem_used / 1024)) + ;; + esac + + mem_full=$((mem_full / 1024)) + ;; + + # Used memory is calculated using the following "formula": + # (wired + active + occupied) * 4 / 1024 + (Darwin*) + mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024)) + + # Parse the 'vmstat' file splitting on ':' and '.'. + # The format of the file is 'key: 000.' and an additional + # split is used on '.' to filter it out. + while IFS=:. read -r key val; do + case $key in + (*' wired'*|*' active'*|*' occupied'*) + mem_used=$((mem_used + ${val:-0})) + ;; + esac + + # Using '<<-EOF' is the only way to loop over a command's + # output without the use of a pipe ('|'). + # This ensures that any variables defined in the while loop + # are still accessible in the script. + done <<-EOF + $(vm_stat) + EOF + + mem_used=$((mem_used * 4 / 1024)) + ;; + + (OpenBSD*) + mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) + + # This is a really simpler parser for 'vmstat' which grabs + # the used memory amount in a lazy way. 'vmstat' prints 3 + # lines of output with the needed value being stored in the + # final line. + # + # This loop simply grabs the 3rd element of each line until + # the EOF is reached. Each line overwrites the value of the + # previous one so we're left with what we wanted. This isn't + # slow as only 3 lines are parsed. + while read -r _ _ line _; do + mem_used=${line%%M} + + # Using '<<-EOF' is the only way to loop over a command's + # output without the use of a pipe ('|'). + # This ensures that any variables defined in the while loop + # are still accessible in the script. + done <<-EOF + $(vmstat) + EOF + ;; + + # Used memory is calculated using the following "formula": + # mem_full - ((inactive + free + cache) * page_size / 1024) + (FreeBSD*|DragonFly*) + mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) + + # Use 'set --' to store the output of the command in the + # argument list. POSIX sh has no arrays but this is close enough. + # + # Disable the shellcheck warning for word-splitting + # as it's safe and intended ('set -f' disables globbing). + # shellcheck disable=2046 + { + set -f + set +f -- $(sysctl -n hw.pagesize \ + vm.stats.vm.v_inactive_count \ + vm.stats.vm.v_free_count \ + vm.stats.vm.v_cache_count) + } + + # Calculate the amount of used memory. + # $1: hw.pagesize + # $2: vm.stats.vm.v_inactive_count + # $3: vm.stats.vm.v_free_count + # $4: vm.stats.vm.v_cache_count + mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024))) + ;; + + (NetBSD*) + mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024)) + + # NetBSD implements a lot of the Linux '/proc' filesystem, + # this uses the same parser as the Linux memory detection. + while IFS=':k ' read -r key val _; do + case $key in + (MemFree) + mem_free=$((val / 1024)) + break + ;; + esac + done < /proc/meminfo + + mem_used=$((mem_full - mem_free)) + ;; + + (Haiku) + # Read the first line of 'sysinfo -mem' splitting on + # '(', ' ', and ')'. The needed information is then + # stored in the 5th and 7th elements. Using '_' "consumes" + # an element allowing us to proceed to the next one. + # + # The parsed format is as follows: + # 3501142016 bytes free (used/max 792645632 / 4293787648) + IFS='( )' read -r _ _ _ _ mem_used _ mem_full <<-EOF + $(sysinfo -mem) + EOF + + mem_used=$((mem_used / 1024 / 1024)) + mem_full=$((mem_full / 1024 / 1024)) + ;; + + (Minix) + # Minix includes the '/proc' filesystem though the format + # differs from Linux. The '/proc/meminfo' file is only a + # single line with space separated elements and elements + # 2 and 3 contain the total and free memory numbers. + read -r _ mem_full mem_free _ < /proc/meminfo + + mem_used=$(((mem_full - mem_free) / 1024)) + mem_full=$(( mem_full / 1024)) + ;; + + (SunOS) + hw_pagesize=$(pagesize) + + # 'kstat' outputs memory in the following format: + # unix:0:system_pages:pagestotal 1046397 + # unix:0:system_pages:pagesfree 885018 + # + # This simply uses the first "element" (white-space + # separated) as the key and the second element as the + # value. + # + # A variable is then assigned based on the key. + while read -r key val; do + case $key in + (*total) + pages_full=$val + ;; + + (*free) + pages_free=$val + ;; + esac + done <<-EOF + $(kstat -p unix:0:system_pages:pagestotal \ + unix:0:system_pages:pagesfree) + EOF + + mem_full=$((pages_full * hw_pagesize / 1024 / 1024)) + mem_free=$((pages_free * hw_pagesize / 1024 / 1024)) + mem_used=$((mem_full - mem_free)) + ;; + + (IRIX) + # Read the memory information from the 'top' command. Parse + # and split each line until we reach the line starting with + # "Memory". + # + # Example output: Memory: 160M max, 147M avail, ..... + while IFS=' :' read -r label mem_full _ mem_free _; do + case $label in + (Memory) + mem_full=${mem_full%M} + mem_free=${mem_free%M} + break + ;; + esac + done <<-EOF + $(top -n) + EOF + + mem_used=$((mem_full - mem_free)) + ;; + esac + + log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 +} + +get_wm() { + case $os in + (Darwin*) + # Don't display window manager on macOS. + ;; + + (*) + # xprop can be used to grab the window manager's properties + # which contains the window manager's name under '_NET_WM_NAME'. + # + # The upside to using 'xprop' is that you don't need to hardcode + # a list of known window manager names. The downside is that + # not all window managers conform to setting the '_NET_WM_NAME' + # atom.. + # + # List of window managers which fail to set the name atom: + # catwm, fvwm, dwm, 2bwm, monster, wmaker and sowm [mine! ;)]. + # + # The final downside to this approach is that it does _not_ + # support Wayland environments. The only solution which supports + # Wayland is the 'ps' parsing mentioned below. + # + # A more naive implementation is to parse the last line of + # '~/.xinitrc' to extract the second white-space separated + # element. + # + # The issue with an approach like this is that this line data + # does not always equate to the name of the window manager and + # could in theory be _anything_. + # + # This also fails when the user launches xorg through a display + # manager or other means. + # + # + # Another naive solution is to parse 'ps' with a hardcoded list + # of window managers to detect the current window manager (based + # on what is running). + # + # The issue with this approach is the need to hardcode and + # maintain a list of known window managers. + # + # Another issue is that process names do not always equate to + # the name of the window manager. False-positives can happen too. + # + # This is the only solution which supports Wayland based + # environments sadly. It'd be nice if some kind of standard were + # established to identify Wayland environments. + # + # pfetch's goal is to remain _simple_, if you'd like a "full" + # implementation of window manager detection use 'neofetch'. + # + # Neofetch use a combination of 'xprop' and 'ps' parsing to + # support all window managers (including non-conforming and + # Wayland) though it's a lot more complicated! + + # Don't display window manager if X isn't running. + [ "$DISPLAY" ] || return + + # This is a two pass call to xprop. One call to get the window + # manager's ID and another to print its properties. + has xprop && { + # The output of the ID command is as follows: + # _NET_SUPPORTING_WM_CHECK: window id # 0x400000 + # + # To extract the ID, everything before the last space + # is removed. + id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK) + id=${id##* } + + # The output of the property command is as follows: + # _NAME 8t + # _NET_WM_PID = 252 + # _NET_WM_NAME = "bspwm" + # _NET_SUPPORTING_WM_CHECK: window id # 0x400000 + # WM_CLASS = "wm", "Bspwm" + # + # To extract the name, everything before '_NET_WM_NAME = \"' + # is removed and everything after the next '"' is removed. + wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t) + } + + # Handle cases of a window manager _not_ populating the + # '_NET_WM_NAME' atom. Display nothing in this case. + case $wm in + (*'_NET_WM_NAME = '*) + wm=${wm##*_NET_WM_NAME = \"} + wm=${wm%%\"*} + ;; + + (*) + # Fallback to checking the process list + # for the select few window managers which + # don't set '_NET_WM_NAME'. + while read -r ps_line; do + case $ps_line in + (*catwm*) wm=catwm ;; + (*fvwm*) wm=fvwm ;; + (*dwm*) wm=dwm ;; + (*2bwm*) wm=2bwm ;; + (*monsterwm*) wm=monsterwm ;; + (*wmaker*) wm='Window Maker' ;; + (*sowm*) wm=sowm ;; + esac + done <<-EOF + $(ps x) + EOF + ;; + esac + ;; + esac + + log wm "$wm" >&6 +} + + +get_de() { + # This only supports Xorg related desktop environments though + # this is fine as knowing the desktop environment on Windows, + # macOS etc is useless (they'll always report the same value). + # + # Display the value of '$XDG_CURRENT_DESKTOP', if it's empty, + # display the value of '$DESKTOP_SESSION'. + log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" >&6 +} + +get_shell() { + # Display the basename of the '$SHELL' environment variable. + log shell "${SHELL##*/}" >&6 +} + +get_editor() { + # Display the value of '$VISUAL', if it's empty, display the + # value of '$EDITOR'. + log editor "${VISUAL:-$EDITOR}" >&6 +} + +get_palette() { + # Print the first 8 terminal colors. This uses the existing + # sequences to change text color with a sequence prepended + # to reverse the foreground and background colors. + # + # This allows us to save hardcoding a second set of sequences + # for background colors. + # + # False positive. + # shellcheck disable=2154 + { + esc SGR 7 + palette="$e$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 " + esc SGR 0 + palette="$palette$e" + } + + # Print the palette with a new-line before and afterwards. + printf '\n' >&6 + log "$palette + " " " >&6 +} + +get_ascii() { + # This is a simple function to read the contents of + # an ascii file from 'stdin'. It allows for the use + # of '<<-EOF' to prevent the break in indentation in + # this source code. + # + # This function also sets the text colors according + # to the ascii color. + read_ascii() { + # 'PF_COL1': Set the info name color according to ascii color. + # 'PF_COL3': Set the title color to some other color. ยฏ\_(ใƒ„)_/ยฏ + PF_COL1=${PF_COL1:-${1:-7}} + PF_COL3=${PF_COL3:-$((${1:-7}%8+1))} + + # POSIX sh has no 'var+=' so 'var=${var}append' is used. What's + # interesting is that 'var+=' _is_ supported inside '$(())' + # (arithmetic) though there's no support for 'var++/var--'. + # + # There is also no $'\n' to add a "literal"(?) newline to the + # string. The simplest workaround being to break the line inside + # the string (though this has the caveat of breaking indentation). + while IFS= read -r line; do + ascii="$ascii$line +" + done + } + + # This checks for ascii art in the following order: + # '$1': Argument given to 'get_ascii()' directly. + # '$PF_ASCII': Environment variable set by user. + # '$distro': The detected distribution name. + # '$os': The name of the operating system/kernel. + # + # NOTE: Each ascii art below is indented using tabs, this + # allows indentation to continue naturally despite + # the use of '<<-EOF'. + # + # False positive. + # shellcheck disable=2154 + case ${1:-${PF_ASCII:-${distro:-$os}}} in + ([Aa]lpine*) + read_ascii 4 <<-EOF + ${c4} /\\ /\\ + /${c7}/ ${c4}\\ \\ + /${c7}/ ${c4}\\ \\ + /${c7}// ${c4}\\ \\ + ${c7}// ${c4}\\ \\ + ${c4}\\ + EOF + ;; + + ([Aa]ndroid*) + read_ascii 2 <<-EOF + ${c2} ;, ,; + ${c2} ';,.-----.,;' + ${c2} ,' ', + ${c2} / O O \\ + ${c2}| | + ${c2}'-----------------' + EOF + ;; + + ([Aa]rch*) + read_ascii 4 <<-EOF + ${c6} /\\ + ${c6} / \\ + ${c6} /\\ \\ + ${c4} / \\ + ${c4} / ,, \\ + ${c4} / | | -\\ + ${c4} /_-'' ''-_\\ + EOF + ;; + + ([Aa]rco*) + read_ascii 4 <<-EOF + ${c4} /\\ + ${c4} / \\ + ${c4} / /\\ \\ + ${c4} / / \\ \\ + ${c4} / / \\ \\ + ${c4} / / _____\\ \\ + ${c4}/_/ \`----.\\_\\ + EOF + ;; + + ([Aa]rtix*) + read_ascii 6 <<-EOF + ${c4} /\\ + ${c4} / \\ + ${c4} /\`'.,\\ + ${c4} / ', + ${c4} / ,\`\\ + ${c4} / ,.'\`. \\ + ${c4}/.,'\` \`'.\\ + EOF + ;; + + ([Bb]edrock*) + read_ascii 4 <<-EOF + ${c7}__ + ${c7}\\ \\___ + ${c7} \\ _ \\ + ${c7} \\___/ + EOF + ;; + + ([Bb]uildroot*) + read_ascii 3 <<-EOF + ${c3} ___ + ${c3} / \` \\ + ${c3}| : :| + ${c3}-. _:__.- + ${c3} \` ---- \` + EOF + ;; + + ([Cc]ent[Oo][Ss]*) + read_ascii 5 <<-EOF + ${c2} ____${c3}^${c5}____ + ${c2} |\\ ${c3}|${c5} /| + ${c2} | \\ ${c3}|${c5} / | + ${c5}<---- ${c4}----> + ${c4} | / ${c2}|${c3} \\ | + ${c4} |/__${c2}|${c3}__\\| + ${c2} v + EOF + ;; + + ([Dd]ahlia*) + read_ascii 1 <<-EOF + ${c1} _ + ${c1} ___/ \\___ + ${c1} | _-_ | + ${c1} | / \ | + ${c1}/ | | \\ + ${c1}\\ | | / + ${c1} | \ _ _ / | + ${c1} |___ - ___| + ${c1} \\_/ + EOF + ;; + + ([Dd]ebian*) + read_ascii 1 <<-EOF + ${c1} _____ + ${c1} / __ \\ + ${c1}| / | + ${c1}| \\___- + ${c1}-_ + ${c1} --_ + EOF + ;; + + ([Dd]ragon[Ff]ly*) + read_ascii 1 <<-EOF + ,${c1}_${c7}, + ('-_${c1}|${c7}_-') + >--${c1}|${c7}--< + (_-'${c1}|${c7}'-_) + ${c1}| + ${c1}| + ${c1}| + EOF + ;; + + ([Ee]lementary*) + read_ascii <<-EOF + ${c7} _______ + ${c7} / ____ \\ + ${c7}/ | / /\\ + ${c7}|__\\ / / | + ${c7}\\ /__/ / + ${c7}\\_______/ + EOF + ;; + + ([Ee]ndeavour*) + read_ascii 4 <<-EOF + ${c1}/${c4}\\ + ${c1}/${c4}/ \\${c6}\\ + ${c1}/${c4}/ \\ ${c6}\\ + ${c1}/ ${c4}/ _) ${c6}) + ${c1}/_${c4}/___-- ${c6}__- + ${c6}/____-- + EOF + ;; + + ([Ff]edora*) + read_ascii 4 <<-EOF + ${c4},'''''. + ${c4}| ,. | + ${c4}| | '_' + ${c4} ,....| |.. + ${c4}.' ,_;| ..' + ${c4}| | | | + ${c4}| ',_,' | + ${c4} '. ,' + ${c4}''''' + EOF + ;; + + ([Ff]ree[Bb][Ss][Dd]*) + read_ascii 1 <<-EOF + ${c1}/\\,-'''''-,/\\ + ${c1}\\_) (_/ + ${c1}| | + ${c1}| | + ${c1}; ; + ${c1}'-_____-' + EOF + ;; + + ([Gg]entoo*) + read_ascii 5 <<-EOF + ${c5} _-----_ + ${c5}( \\ + ${c5}\\ 0 \\ + ${c7} \\ ) + ${c7} / _/ + ${c7}( _- + ${c7}\\____- + EOF + ;; + + ([Gg][Nn][Uu]*) + read_ascii 3 <<-EOF + ${c2} _-\`\`-, ,-\`\`-_ + ${c2} .' _-_| |_-_ '. + ${c2}./ /_._ _._\\ \\. + ${c2}: _/_._\`:'_._\\_ : + ${c2}\\:._/ ,\` \\ \\ \\_.:/ + ${c2} ,-';'.@) \\ @) \\ + ${c2} ,'/' ..- .\\,-.| + ${c2} /'/' \\(( \\\` ./ ) + ${c2} '/'' \\_,----' + ${c2} '/'' ,;/'' + ${c2} \`\`;' + EOF + ;; + + ([Gg]uix[Ss][Dd]*|[Gg]uix*) + read_ascii 3 <<-EOF + ${c3}|.__ __.| + ${c3}|__ \\ / __| + ${c3}\\ \\ / / + ${c3}\\ \\ / / + ${c3}\\ \\ / / + ${c3}\\ \\/ / + ${c3}\\__/ + EOF + ;; + + ([Hh]aiku*) + read_ascii 3 <<-EOF + ${c3} ,^, + ${c3} / \\ + ${c3}*--_ ; ; _--* + ${c3}\\ '" "' / + ${c3}'. .' + ${c3}.-'" "'-. + ${c3}'-.__. .__.-' + ${c3}|_| + EOF + ;; + + ([Hh]ydroOS*) + read_ascii 4 <<-EOF + ${c1}โ•”โ•—โ•”โ•—โ”€โ”€โ•”โ•—โ”€โ”€โ”€โ•”โ•โ•ฆโ•โ•โ•— + ${c1}โ•‘โ•šโ•โ• โ•ฆโ•ฆโ•โ• โ•ฆโ•ฆโ•โ•ฃโ•‘โ•‘โ•โ•โ•ฃ + ${c1}โ•‘โ•”โ•—โ•‘โ•‘โ•‘โ•ฌโ•‘โ•”โ•ฃโ•ฌโ•‘โ•‘โ• โ•โ•โ•‘ + ${c1}โ•šโ•โ•šโ•ฌโ•—โ• โ•โ•ฉโ•โ•šโ•โ•ฉโ•โ•ฉโ•โ•โ• + ${c1}โ”€โ”€โ”€โ•šโ•โ• + EOF + ;; + + ([Hh]yperbola*) + read_ascii <<-EOF + ${c7} |\`__.\`/ + ${c7} \____/ + ${c7} .--. + ${c7} / \\ + ${c7} / ___ \\ + ${c7}/ .\` \`.\\ + ${c7}/.\` \`.\\ + EOF + ;; + + ([Ii]glunix*) + read_ascii <<-EOF + ${c0} | + ${c0} | | + ${c0} | + ${c0} | ________ + ${c0} | /\\ | \\ + ${c0} / \\ | \\ | + ${c0} / \\ \\ | + ${c0} / \\________\\ + ${c0} \\ / / + ${c0} \\ / / + ${c0} \\ / / + ${c0} \\/________/ + EOF + ;; + + ([Ii]nstant[Oo][Ss]*) + read_ascii <<-EOF + ${c0} ,-''-, + ${c0}: .''. : + ${c0}: ',,' : + ${c0} '-____:__ + ${c0} : \`. + ${c0} \`._.' + EOF + ;; + + ([Ii][Rr][Ii][Xx]*) + read_ascii 1 <<-EOF + ${c1} __ + ${c1} \\ \\ __ + ${c1} \\ \\ / / + ${c1} \\ v / + ${c1} / . \\ + ${c1} /_/ \\ \\ + ${c1} \\_\\ + EOF + ;; + + ([Kk][Dd][Ee]*[Nn]eon*) + read_ascii 6 <<-EOF + ${c7} .${c6}__${c7}.${c6}__${c7}. + ${c6} / _${c7}.${c6}_ \\ + ${c6} / / \\ \\ + ${c7} . ${c6}| ${c7}O${c6} | ${c7}. + ${c6} \\ \\_${c7}.${c6}_/ / + ${c6} \\${c7}.${c6}__${c7}.${c6}__${c7}.${c6}/ + EOF + ;; + + ([Ll]inux*[Ll]ite*|[Ll]ite*) + read_ascii 3 <<-EOF + ${c3} /\\ + ${c3} / \\ + ${c3} / ${c7}/ ${c3}/ + ${c3}> ${c7}/ ${c3}/ + ${c3}\\ ${c7}\\ ${c3}\\ + ${c3}\\_${c7}\\${c3}_\\ + ${c7} \\ + EOF + ;; + + ([Ll]inux*[Mm]int*|[Mm]int) + read_ascii 2 <<-EOF + ${c2} ___________ + ${c2}|_ \\ + ${c2}| ${c7}| _____ ${c2}| + ${c2}| ${c7}| | | | ${c2}| + ${c2}| ${c7}| | | | ${c2}| + ${c2}| ${c7}\\__${c7}___/ ${c2}| + ${c2}\\_________/ + EOF + ;; + + + ([Ll]inux*) + read_ascii 4 <<-EOF + ${c4} ___ + ${c4}(${c7}.. ${c4}| + ${c4}(${c5}<> ${c4}| + ${c4}/ ${c7}__ ${c4}\\ + ${c4}( ${c7}/ \\ ${c4}/| + ${c5}_${c4}/\\ ${c7}__)${c4}/${c5}_${c4}) + ${c5}\/${c4}-____${c5}\/ + EOF + ;; + + ([Mm]ac[Oo][Ss]*|[Dd]arwin*) + read_ascii 1 <<-EOF + ${c2} .:' + ${c2} _ :'_ + ${c3} .'\`_\`-'_\`\`. + ${c1}:________.-' + ${c1}:_______: + ${c4} :_______\`-; + ${c5} \`._.-._.' + EOF + ;; + + ([Mm]ageia*) + read_ascii 2 <<-EOF + ${c6} * + ${c6} * + ${c6} ** + ${c7} /\\__/\\ + ${c7}/ \\ + ${c7}\\ / + ${c7} \\____/ + EOF + ;; + + ([Mm]anjaro*) + read_ascii 2 <<-EOF + ${c2}||||||||| |||| + ${c2}||||||||| |||| + ${c2}|||| |||| + ${c2}|||| |||| |||| + ${c2}|||| |||| |||| + ${c2}|||| |||| |||| + ${c2}|||| |||| |||| + EOF + ;; + + ([Mm]inix*) + read_ascii 4 <<-EOF + ${c4} ,, ,, + ${c4};${c7},${c4} ', ,' ${c7},${c4}; + ${c4}; ${c7}',${c4} ',,' ${c7},'${c4} ; + ${c4}; ${c7}',${c4} ${c7},'${c4} ; + ${c4}; ${c7};, '' ,;${c4} ; + ${c4}; ${c7};${c4};${c7}',,'${c4};${c7};${c4} ; + ${c4}', ${c7};${c4};; ;;${c7};${c4} ,' + ${c4} '${c7};${c4}' '${c7};${c4}' + EOF + ;; + + ([Mm][Xx]*) + read_ascii <<-EOF + ${c7} \\\\ / + ${c7} \\\\/ + ${c7} \\\\ + ${c7} /\\/ \\\\ + ${c7} / \\ /\\ + ${c7} / \\/ \\ + ${c7}/__________\\ + EOF + ;; + + ([Nn]et[Bb][Ss][Dd]*) + read_ascii 3 <<-EOF + ${c7}\\\\${c3}\`-______,----__ + ${c7} \\\\ ${c3}__,---\`_ + ${c7} \\\\ ${c3}\`.____ + ${c7} \\\\${c3}-______,----\`- + ${c7} \\\\ + ${c7} \\\\ + ${c7} \\\\ + EOF + ;; + + ([Nn]ix[Oo][Ss]*) + read_ascii 4 <<-EOF + ${c4} \\\\ \\\\ // + ${c4} ==\\\\__\\\\/ // + ${c4} // \\\\// + ${c4}==// //== + ${c4} //\\\\___// + ${c4}// /\\\\ \\\\== + ${c4} // \\\\ \\\\ + EOF + ;; + + ([Oo]pen[Bb][Ss][Dd]*) + read_ascii 3 <<-EOF + ${c3} _____ + ${c3} \\- -/ + ${c3} \\_/ \\ + ${c3} | ${c7}O O${c3} | + ${c3} |_ < ) 3 ) + ${c3} / \\ / + ${c3} /-_____-\\ + EOF + ;; + + ([Oo]pen[Ss][Uu][Ss][Ee]*[Tt]umbleweed*) + read_ascii 2 <<-EOF + ${c2} _____ ______ + ${c2} / ____\\ / ____ \\ + ${c2}/ / \`/ / \\ \\ + ${c2}\\ \\____/ /,____/ / + ${c2} \\______/ \\_____/ + EOF + ;; + + ([Oo]pen[Ss][Uu][Ss][Ee]*|[Oo]pen*SUSE*|SUSE*|suse*) + read_ascii 2 <<-EOF + ${c2} _______ + ${c2}__| __ \\ + ${c2} / .\\ \\ + ${c2} \\__/ | + ${c2} _______| + ${c2} \\_______ + ${c2}__________/ + EOF + ;; + + ([Oo]pen[Ww]rt*) + read_ascii 1 <<-EOF + ${c1} _______ + ${c1}| |.-----.-----.-----. + ${c1}| - || _ | -__| | + ${c1}|_______|| __|_____|__|__| + ${c1} ________|__| __ + ${c1}| | | |.----.| |_ + ${c1}| | | || _|| _| + ${c1}|________||__| |____| + EOF + ;; + + ([Pp]arabola*) + read_ascii 5 <<-EOF + ${c5} __ __ __ _ + ${c5}.\`_//_//_/ / \`. + ${c5} / .\` + ${c5} / .\` + ${c5} /.\` + ${c5} /\` + EOF + ;; + + ([Pp]op!_[Oo][Ss]*) + read_ascii 6 <<-EOF + ${c6}______ + ${c6}\\ _ \\ __ + ${c6}\\ \\ \\ \\ / / + ${c6}\\ \\_\\ \\ / / + ${c6}\\ ___\\ /_/ + ${c6} \\ \\ _ + ${c6} __\\_\\__(_)_ + ${c6}(___________) + EOF + ;; + + ([Pp]ure[Oo][Ss]*) + read_ascii <<-EOF + ${c7} _____________ + ${c7}| _________ | + ${c7}| | | | + ${c7}| | | | + ${c7}| |_________| | + ${c7}|_____________| + EOF + ;; + + ([Rr]aspbian*) + read_ascii 1 <<-EOF + ${c2} __ __ + ${c2} (_\\)(/_) + ${c1} (_(__)_) + ${c1}(_(_)(_)_) + ${c1} (_(__)_) + ${c1} (__) + EOF + ;; + + ([Ss]lackware*) + read_ascii 4 <<-EOF + ${c4} ________ + ${c4} / ______| + ${c4} | |______ + ${c4} \\______ \\ + ${c4} ______| | + ${c4}| |________/ + ${c4}|____________ + EOF + ;; + + ([Ss]un[Oo][Ss]|[Ss]olaris*) + read_ascii 3 <<-EOF + ${c3} . .; . + ${c3} . :; :: ;: . + ${c3} .;. .. .. .;. + ${c3}.. .. .. .. + ${c3} .;, ,;. + EOF + ;; + + ([Uu]buntu*) + read_ascii 3 <<-EOF + ${c3} _ + ${c3} ---(_) + ${c3} _/ --- \\ + ${c3}(_) | | + ${c3} \\ --- _/ + ${c3} ---(_) + EOF + ;; + + ([Vv]oid*) + read_ascii 2 <<-EOF + ${c2} _______ + ${c2} _ \\______ - + ${c2}| \\ ___ \\ | + ${c2}| | / \ | | + ${c2}| | \___/ | | + ${c2}| \\______ \\_| + ${c2} -_______\\ + EOF + ;; + + ([Xx]eonix*) + read_ascii 2 <<-EOF + ${c2} ___ ___ + ${c2}___ \ \/ / ___ + ${c2}\ \ \ / / / + ${c2} \ \/ \/ / + ${c2} \ /\ / + ${c2} \__/ \__/ + EOF + ;; + + (*) + # On no match of a distribution ascii art, this function calls + # itself again, this time to look for a more generic OS related + # ascii art (KISS Linux -> Linux). + [ "$1" ] || { + get_ascii "$os" + return + } + + printf 'error: %s is not currently supported.\n' "$os" >&6 + printf 'error: Open an issue for support to be added.\n' >&6 + exit 1 + ;; + esac + + # Store the "width" (longest line) and "height" (number of lines) + # of the ascii art for positioning. This script prints to the screen + # *almost* like a TUI does. It uses escape sequences to allow dynamic + # printing of the information through user configuration. + # + # Iterate over each line of the ascii art to retrieve the above + # information. The 'sed' is used to strip '\033[3Xm' color codes from + # the ascii art so they don't affect the width variable. + while read -r line; do + ascii_height=$((${ascii_height:-0} + 1)) + + # This was a ternary operation but they aren't supported in + # Minix's shell. + [ "${#line}" -gt "${ascii_width:-0}" ] && + ascii_width=${#line} + + # Using '<<-EOF' is the only way to loop over a command's + # output without the use of a pipe ('|'). + # This ensures that any variables defined in the while loop + # are still accessible in the script. + done <<-EOF + $(printf %s "$ascii" | sed 's/\[3.m//g') + EOF + + # Add a gap between the ascii art and the information. + ascii_width=$((ascii_width + 4)) + + # Print the ascii art and position the cursor back where we + # started prior to printing it. + { + esc_p SGR 1 + printf '%s' "$ascii" + esc_p SGR 0 + esc_p CUU "$ascii_height" + } >&6 +} + +main() { + [ "$1" = --version ] && { + printf 'pfetch 0.7.0\n' + exit 0 + } + + # Hide 'stderr' unless the first argument is '-v'. This saves + # polluting the script with '2>/dev/null'. + [ "$1" = -v ] || { + exec 2>/dev/null + } + + # Hide 'stdout' and selectively print to it using '>&6'. + # This gives full control over what it displayed on the screen. + exec 6>&1 >/dev/null + + # Store raw escape sequence character for later reuse. + esc_c=$(printf '\033') + + # Allow the user to execute their own script and modify or + # extend pfetch's behavior. + # shellcheck source=/dev/null + . "${PF_SOURCE:-/dev/null}" ||: + + # Ensure that the 'TMPDIR' is writable as heredocs use it and + # fail without the write permission. This was found to be the + # case on Android where the temporary directory requires root. + [ -w "${TMPDIR:-/tmp}" ] || export TMPDIR=~ + + # Generic color list. + # Disable warning about unused variables. + # shellcheck disable=2034 + for _c in c1 c2 c3 c4 c5 c6 c7 c8; do + esc SGR "3${_c#?}" 0 + export "$_c=$e" + done + + # Disable line wrapping and catch the EXIT signal to enable it again + # on exit. Ideally you'd somehow query the current value and retain + # it but I'm yet to see this irk anyone. + esc_p DECAWM l >&6 + trap 'esc_p DECAWM h >&6' EXIT + + # Store the output of 'uname' to avoid calling it multiple times + # throughout the script. 'read </dev/null || continue + + # This was a ternary operation but they aren't supported in + # Minix's shell. + [ "${#info}" -gt "${info_length:-0}" ] && + info_length=${#info} + done + + # Add an additional space of length to act as a gap. + info_length=$((info_length + 1)) + + # Iterate over the above list and run any existing "get_" functions. + for info do + "get_$info" + done + } + + # Position the cursor below both the ascii art and information lines + # according to the height of both. If the information exceeds the ascii + # art in height, don't touch the cursor (0/unset), else move it down + # N lines. + # + # This was a ternary operation but they aren't supported in Minix's shell. + [ "${info_height:-0}" -lt "${ascii_height:-0}" ] && + cursor_pos=$((ascii_height - info_height)) + + # Print '$cursor_pos' amount of newlines to correctly position the + # cursor. This used to be a 'printf $(seq X X)' however 'seq' is only + # typically available (by default) on GNU based systems! + while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do + printf '\n' + i=$((i + 1)) + done >&6 +} + +main "$@" diff --git a/scripts/pipewire-restart.sh b/scripts/pipewire-restart.sh new file mode 100755 index 0000000..e0a23c8 --- /dev/null +++ b/scripts/pipewire-restart.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +systemctl restart --user pipewire.service +systemctl restart --user pipewire-pulse.service \ No newline at end of file diff --git a/scripts/pomodoro.sh b/scripts/pomodoro.sh index 3cf5631..defda38 100755 --- a/scripts/pomodoro.sh +++ b/scripts/pomodoro.sh @@ -4,7 +4,7 @@ sl=25 # study session time in minutes bl=5 # break time in minutes bll=20 # long break time in minutes bls=4 # number of study sessions before long break -ringtone="$HOME/Media/warcraft-soundtrack/2004 World of Warcraft/ringtone.flac" +ringtone="$HOME/disks/Media/warcraft-soundtrack/2004 World of Warcraft/ringtone.flac" sessions=0 # number of sessions passed # if you kill and restart pomodoro.sh, you can specify the number of sessions passed @@ -36,8 +36,8 @@ do tl=$bll else state=1 - printf "\rBreak time! Sessions done: %d\n" "$sessions" - notify-send -i "media-playback-paused" "Break time!" + printf "\rBreak time! Exercises (eyes, hands, and back) Sessions done: %d\n" "$sessions" + notify-send -i "media-playback-paused" "Break time! Exercises (eyes, hands, and back)" mpv --no-vid --no-terminal "$ringtone" & tl=$bl fi @@ -60,4 +60,4 @@ do fi sleep 1 -done \ No newline at end of file +done diff --git a/scripts/root-notify.sh b/scripts/root-notify.sh deleted file mode 100755 index bf801c0..0000000 --- a/scripts/root-notify.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -#Detect the name of the display in use -display=":$(find /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)" - -#Detect the user using such display -user="$(who | grep "tty1" | awk '{print $1}' | head -n 1)" - -#Detect the id of the user -uid="$(id -u "$user")" - -sudo -u "$user" DISPLAY="$display" DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$uid"/bus notify-send "$@" diff --git a/scripts/showcal.sh b/scripts/showcal.sh index b43d30d..96f9073 100755 --- a/scripts/showcal.sh +++ b/scripts/showcal.sh @@ -1,3 +1,3 @@ #!/bin/sh -notify-send "$(printf "`cal -m`\n`cal -m +1month`")" \ No newline at end of file +notify-send "$(printf "`cal -m`\n`cal -m $(date +%B --date="$(date +%Y-%m-15) next month")`")" diff --git a/scripts/status/date.sh b/scripts/status/date.sh index 2d1537e..af6a139 100755 --- a/scripts/status/date.sh +++ b/scripts/status/date.sh @@ -1,7 +1,6 @@ #!/bin/sh +month="$(LC_TIME=ja_JP.UTF-8 date "+%A")" +day="$(LC_TIME=ja_JP.UTF-8 date "+%x")" +time="$(date "+%H:%M")" -month=`date "+%a"` -day=`date "+%d.%m.%Y"` -time=`date "+%H:%M"` - -printf "^c#222222^^b#a77bf2^ $month ^b#9863f2^ $day ^b#884cef^ $time " \ No newline at end of file +printf "^c#222222^^b#a77bf2^ %s ^b#9863f2^ %s ^b#884cef^ %s " "$month" "$day" "$time" diff --git a/scripts/update-discord.sh b/scripts/update-discord.sh new file mode 100755 index 0000000..a832090 --- /dev/null +++ b/scripts/update-discord.sh @@ -0,0 +1,5 @@ +curl -L "https://discord.com/api/download/stable?platform=linux&format=tar.gz" -o ~/scripts/discord.tar.gz + +rm -rf ~/scripts/Discord +tar xf ~/scripts/discord.tar.gz -C ~/scripts/ +rm ~/scripts/discord.tar.gz diff --git a/scripts/update.sh b/scripts/update.sh deleted file mode 100755 index a4bdcbb..0000000 --- a/scripts/update.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -#Detect the name of the display in use -display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)" - -#Detect the user using such display -user="$(who | grep "tty1" | awk '{print $1}' | head -n 1)" - -#Detect the id of the user -uid="$(id -u $user)" - -pacman -Sy -sudo -u $user DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send -i "view-refresh" "Packages to update: $(pacman -Qqu | wc -l)" \ No newline at end of file diff --git a/scripts/xinit.sh b/scripts/xinit.sh index bb65ce7..10307f4 100755 --- a/scripts/xinit.sh +++ b/scripts/xinit.sh @@ -17,3 +17,5 @@ flameshot & eval "$(gnome-keyring-daemon --start)" & export SSH_AUTH_SOCK & easyeffects --gapplication-service & +mount ~/nextcloud & +sslocal -c vpnconf/ss.conf & diff --git a/vim.jpg b/vim.jpg deleted file mode 100644 index b4e9d68..0000000 Binary files a/vim.jpg and /dev/null differ