From 2e903b032d55917864968b39c558aacef76815e3 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 09:23:49 +0100 Subject: [PATCH 01/16] Add FireCode font as default tui requirement --- nixos/home-manager/packages/tui/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos/home-manager/packages/tui/default.nix b/nixos/home-manager/packages/tui/default.nix index 224dc6ee..11c586d4 100644 --- a/nixos/home-manager/packages/tui/default.nix +++ b/nixos/home-manager/packages/tui/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { imports = [ @@ -6,4 +6,7 @@ ./lazygit.nix ]; programs.neovim.defaultEditor = true; + home.packages = with pkgs; [ + (nerdfonts.override { fonts = [ "FiraCode" ]; }) + ]; } From 193245282a0d742c15092f35c1c4a2863326a849 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 09:23:58 +0100 Subject: [PATCH 02/16] Enable direnv program --- nixos/home-manager/packages/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nixos/home-manager/packages/default.nix b/nixos/home-manager/packages/default.nix index 6ce5fcb1..630103d1 100644 --- a/nixos/home-manager/packages/default.nix +++ b/nixos/home-manager/packages/default.nix @@ -41,4 +41,10 @@ enableFishIntegration = true; settings = builtins.fromTOML (builtins.readFile ./config/starship.toml); }; + programs.direnv = { + enable = true; + #enableBashIntegration = true; + #enableZshIntegration = true; + #enableFishIntegration = true; + }; } From 49d0c1b48f5c862f572fffc34711b37875b954fe Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 09:24:26 +0100 Subject: [PATCH 03/16] Add working python venv template and modified version using poetry --- templates/indica.nix | 18 ------------------ templates/jupyter.nix | 30 ------------------------------ templates/poetry.nix | 24 ++++++++++++++++++++++++ templates/python.nix | 27 +++++++++++++-------------- 4 files changed, 37 insertions(+), 62 deletions(-) delete mode 100644 templates/indica.nix delete mode 100644 templates/jupyter.nix create mode 100644 templates/poetry.nix diff --git a/templates/indica.nix b/templates/indica.nix deleted file mode 100644 index 9e28641d..00000000 --- a/templates/indica.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.stdenv.mkDerivation { - pname = "indica-notebook"; - version = "1.0.0"; - - buildInputs = with pkgs; [ - (python39.withPackages (ps: with ps; [ - jupyter - ])) - ]; - - configurePhase = ''''; - - buildPhase = ''''; - - installPhase = ''''; -} diff --git a/templates/jupyter.nix b/templates/jupyter.nix deleted file mode 100644 index 9c7ebe16..00000000 --- a/templates/jupyter.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ tinypkgs ? import - (fetchTarball { - url = "https://gitlab.inria.fr/nix-tutorial/packages-repository/-/archive/master/packages-repository-8e43243635cd8f28c7213205b08c12f2ca2ac74d.tar.gz"; - sha256 = "sha256:09l2w3m1z0308zc476ci0bsz5amm536hj1n9xzpwcjm59jxkqpqa"; - }) - { } -}: - -with tinypkgs; # Put tinypkgs's attributes in the current scope. -with pkgs; # Same for pkgs. - -mkShell { - buildInputs = [ - chord - - # Defines a python + set of packages. - (python3.withPackages (ps: with ps; with python3Packages; [ - jupyter - ipython - - # Uncomment the following lines to make them available in the shell. - # pandas - # numpy - # matplotlib - ])) - ]; - - # Automatically run jupyter when entering the shell. - shellHook = "jupyter notebook"; -} diff --git a/templates/poetry.nix b/templates/poetry.nix new file mode 100644 index 00000000..b9724b32 --- /dev/null +++ b/templates/poetry.nix @@ -0,0 +1,24 @@ +{ pkgs ? import {}, python ? pkgs.python39, ... }: + +let + python-packages = ps: with ps; [ + pip + setuptools + wheel + ]; +in +pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + (python.withPackages python-packages) + poetry + git + zlib + libgccjit + ]; + + shellHook = '' + export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib" + [ ! -d "./.venv" ] && poetry install --sync + source .venv/bin/activate + ''; +} diff --git a/templates/python.nix b/templates/python.nix index bfb4071f..b9193c90 100644 --- a/templates/python.nix +++ b/templates/python.nix @@ -1,4 +1,4 @@ -{ pkgs ? import { } }: +{ pkgs ? import {}, python ? pkgs.python39, ... }: let python-packages = ps: with ps; [ @@ -7,18 +7,17 @@ let wheel ]; in -with pkgs; -(buildFHSUserEnv { - name = "python"; - targetPkgs = pkgs: [ ]; - multiPkgs = pkgs: [ - zlib zlib-ng - (python39.withPackages python-packages) +pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + (python.withPackages python-packages) + git + zlib + libgccjit ]; - runScript = '' - bash -c "{ - python -m venv .venv - source .venv/bin/activate - }" + + shellHook = '' + export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib" + python -m venv .venv + source .venv/bin/activate ''; -}).env +} From bc6bed59607f5ae4be9acc66719aa6f253e137d7 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 11:26:08 +0100 Subject: [PATCH 04/16] Fix catppuccin cursors, add lightly application theme --- nixos/desktop/plasma.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/desktop/plasma.nix b/nixos/desktop/plasma.nix index d56d0e46..e5e45d4d 100644 --- a/nixos/desktop/plasma.nix +++ b/nixos/desktop/plasma.nix @@ -13,9 +13,10 @@ programs.kdeconnect.enable = true; environment.systemPackages = with pkgs; [ + libsForQt5.lightly catppuccin-kde catppuccin-gtk - catppuccin-cursors + catppuccin-cursors.macchiatoDark ]; # Configure keymap in X11 From 19b02dba5c92bad8c95443f32dff7ac53954f11d Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 11:54:22 +0100 Subject: [PATCH 05/16] Add more/better neovim config with home-manager --- nixos/home-manager/packages/env/fish.nix | 1 - nixos/home-manager/packages/tui/neovim.nix | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nixos/home-manager/packages/env/fish.nix b/nixos/home-manager/packages/env/fish.nix index e04ffab6..eadfe16d 100644 --- a/nixos/home-manager/packages/env/fish.nix +++ b/nixos/home-manager/packages/env/fish.nix @@ -7,7 +7,6 @@ update = "sudo nixos-rebuild switch --upgrade"; nr = "sudo nixos-rebuild"; lg = "lazygit"; - vim = "nvim"; }; }; } diff --git a/nixos/home-manager/packages/tui/neovim.nix b/nixos/home-manager/packages/tui/neovim.nix index 81552f28..8a340c8b 100644 --- a/nixos/home-manager/packages/tui/neovim.nix +++ b/nixos/home-manager/packages/tui/neovim.nix @@ -1,11 +1,17 @@ { pkgs, ... }: { - programs.neovim.enable = true; + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + withNodeJs = true; + withPython3 = true; + }; home.packages = with pkgs; [ gnumake gcc - python310Packages.pynvim python310Packages.mypy python310Packages.black python310Packages.isort From 6595785e625b6820a4a58b82f5c1c7b98501ab56 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 11:54:36 +0100 Subject: [PATCH 06/16] Move common desktop packages to common.nix --- nixos/desktop/common.nix | 7 ++++++- nixos/desktop/plasma.nix | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nixos/desktop/common.nix b/nixos/desktop/common.nix index 668353c1..dc538e60 100644 --- a/nixos/desktop/common.nix +++ b/nixos/desktop/common.nix @@ -1,5 +1,10 @@ -{ config, pkgs, ... }: +{ pkgs, ... }: { + environment.systemPackages = with pkgs; [ + catppuccin-gtk + catppuccin-cursors.macchiatoDark + ]; + # Enable CUPS to print documents. services.printing.enable = true; diff --git a/nixos/desktop/plasma.nix b/nixos/desktop/plasma.nix index e5e45d4d..7ca2ae34 100644 --- a/nixos/desktop/plasma.nix +++ b/nixos/desktop/plasma.nix @@ -15,8 +15,6 @@ environment.systemPackages = with pkgs; [ libsForQt5.lightly catppuccin-kde - catppuccin-gtk - catppuccin-cursors.macchiatoDark ]; # Configure keymap in X11 From c0f0bfc5b68043304216480d93dd478c4a482582 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 13:29:15 +0100 Subject: [PATCH 07/16] Improve standard templates for python packages --- templates/poetry.nix | 2 ++ templates/python.nix | 1 + 2 files changed, 3 insertions(+) diff --git a/templates/poetry.nix b/templates/poetry.nix index b9724b32..af84a269 100644 --- a/templates/poetry.nix +++ b/templates/poetry.nix @@ -18,6 +18,8 @@ pkgs.mkShell { shellHook = '' export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib" + poetry lock --check > /dev/null || poetry lock + poetry env use "$(command -v ${python}/bin/python)" [ ! -d "./.venv" ] && poetry install --sync source .venv/bin/activate ''; diff --git a/templates/python.nix b/templates/python.nix index b9193c90..dfe1bb76 100644 --- a/templates/python.nix +++ b/templates/python.nix @@ -19,5 +19,6 @@ pkgs.mkShell { export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib" python -m venv .venv source .venv/bin/activate + pip list --outdated | grep -iE "^(pip|wheel)" > /dev/null && python -m pip install --upgrade pip wheel ''; } From c199658db30f891a0dc985a500ce10cc24ce30d0 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 16:00:28 +0100 Subject: [PATCH 08/16] Re-instate i3 config until fully transferred --- {depracated_config => config}/i3/config | 0 {depracated_config => config}/i3/i3blocks.conf | 0 {depracated_config => config}/i3/keybindings | 0 {depracated_config => config}/i3/scripts/bandwidth2 | 0 {depracated_config => config}/i3/scripts/battery-pinebook-pro | 0 {depracated_config => config}/i3/scripts/battery1 | 0 {depracated_config => config}/i3/scripts/battery2 | 0 {depracated_config => config}/i3/scripts/blur-lock | 0 {depracated_config => config}/i3/scripts/cpu_usage | 0 {depracated_config => config}/i3/scripts/disk | 0 {depracated_config => config}/i3/scripts/empty_workspace | 0 {depracated_config => config}/i3/scripts/keyboard-layout | 0 {depracated_config => config}/i3/scripts/keyhint | 0 {depracated_config => config}/i3/scripts/keyhint-2 | 0 {depracated_config => config}/i3/scripts/memory | 0 {depracated_config => config}/i3/scripts/openweather | 0 {depracated_config => config}/i3/scripts/openweather-city | 0 {depracated_config => config}/i3/scripts/openweather.conf | 0 {depracated_config => config}/i3/scripts/power-profiles | 0 {depracated_config => config}/i3/scripts/powermenu | 0 {depracated_config => config}/i3/scripts/ppd-status | 0 {depracated_config => config}/i3/scripts/temperature | 0 {depracated_config => config}/i3/scripts/volume | 0 {depracated_config => config}/i3/scripts/vpn | 0 24 files changed, 0 insertions(+), 0 deletions(-) rename {depracated_config => config}/i3/config (100%) rename {depracated_config => config}/i3/i3blocks.conf (100%) rename {depracated_config => config}/i3/keybindings (100%) rename {depracated_config => config}/i3/scripts/bandwidth2 (100%) rename {depracated_config => config}/i3/scripts/battery-pinebook-pro (100%) rename {depracated_config => config}/i3/scripts/battery1 (100%) rename {depracated_config => config}/i3/scripts/battery2 (100%) rename {depracated_config => config}/i3/scripts/blur-lock (100%) rename {depracated_config => config}/i3/scripts/cpu_usage (100%) rename {depracated_config => config}/i3/scripts/disk (100%) rename {depracated_config => config}/i3/scripts/empty_workspace (100%) rename {depracated_config => config}/i3/scripts/keyboard-layout (100%) rename {depracated_config => config}/i3/scripts/keyhint (100%) rename {depracated_config => config}/i3/scripts/keyhint-2 (100%) rename {depracated_config => config}/i3/scripts/memory (100%) rename {depracated_config => config}/i3/scripts/openweather (100%) rename {depracated_config => config}/i3/scripts/openweather-city (100%) rename {depracated_config => config}/i3/scripts/openweather.conf (100%) rename {depracated_config => config}/i3/scripts/power-profiles (100%) rename {depracated_config => config}/i3/scripts/powermenu (100%) rename {depracated_config => config}/i3/scripts/ppd-status (100%) rename {depracated_config => config}/i3/scripts/temperature (100%) rename {depracated_config => config}/i3/scripts/volume (100%) rename {depracated_config => config}/i3/scripts/vpn (100%) diff --git a/depracated_config/i3/config b/config/i3/config similarity index 100% rename from depracated_config/i3/config rename to config/i3/config diff --git a/depracated_config/i3/i3blocks.conf b/config/i3/i3blocks.conf similarity index 100% rename from depracated_config/i3/i3blocks.conf rename to config/i3/i3blocks.conf diff --git a/depracated_config/i3/keybindings b/config/i3/keybindings similarity index 100% rename from depracated_config/i3/keybindings rename to config/i3/keybindings diff --git a/depracated_config/i3/scripts/bandwidth2 b/config/i3/scripts/bandwidth2 similarity index 100% rename from depracated_config/i3/scripts/bandwidth2 rename to config/i3/scripts/bandwidth2 diff --git a/depracated_config/i3/scripts/battery-pinebook-pro b/config/i3/scripts/battery-pinebook-pro similarity index 100% rename from depracated_config/i3/scripts/battery-pinebook-pro rename to config/i3/scripts/battery-pinebook-pro diff --git a/depracated_config/i3/scripts/battery1 b/config/i3/scripts/battery1 similarity index 100% rename from depracated_config/i3/scripts/battery1 rename to config/i3/scripts/battery1 diff --git a/depracated_config/i3/scripts/battery2 b/config/i3/scripts/battery2 similarity index 100% rename from depracated_config/i3/scripts/battery2 rename to config/i3/scripts/battery2 diff --git a/depracated_config/i3/scripts/blur-lock b/config/i3/scripts/blur-lock similarity index 100% rename from depracated_config/i3/scripts/blur-lock rename to config/i3/scripts/blur-lock diff --git a/depracated_config/i3/scripts/cpu_usage b/config/i3/scripts/cpu_usage similarity index 100% rename from depracated_config/i3/scripts/cpu_usage rename to config/i3/scripts/cpu_usage diff --git a/depracated_config/i3/scripts/disk b/config/i3/scripts/disk similarity index 100% rename from depracated_config/i3/scripts/disk rename to config/i3/scripts/disk diff --git a/depracated_config/i3/scripts/empty_workspace b/config/i3/scripts/empty_workspace similarity index 100% rename from depracated_config/i3/scripts/empty_workspace rename to config/i3/scripts/empty_workspace diff --git a/depracated_config/i3/scripts/keyboard-layout b/config/i3/scripts/keyboard-layout similarity index 100% rename from depracated_config/i3/scripts/keyboard-layout rename to config/i3/scripts/keyboard-layout diff --git a/depracated_config/i3/scripts/keyhint b/config/i3/scripts/keyhint similarity index 100% rename from depracated_config/i3/scripts/keyhint rename to config/i3/scripts/keyhint diff --git a/depracated_config/i3/scripts/keyhint-2 b/config/i3/scripts/keyhint-2 similarity index 100% rename from depracated_config/i3/scripts/keyhint-2 rename to config/i3/scripts/keyhint-2 diff --git a/depracated_config/i3/scripts/memory b/config/i3/scripts/memory similarity index 100% rename from depracated_config/i3/scripts/memory rename to config/i3/scripts/memory diff --git a/depracated_config/i3/scripts/openweather b/config/i3/scripts/openweather similarity index 100% rename from depracated_config/i3/scripts/openweather rename to config/i3/scripts/openweather diff --git a/depracated_config/i3/scripts/openweather-city b/config/i3/scripts/openweather-city similarity index 100% rename from depracated_config/i3/scripts/openweather-city rename to config/i3/scripts/openweather-city diff --git a/depracated_config/i3/scripts/openweather.conf b/config/i3/scripts/openweather.conf similarity index 100% rename from depracated_config/i3/scripts/openweather.conf rename to config/i3/scripts/openweather.conf diff --git a/depracated_config/i3/scripts/power-profiles b/config/i3/scripts/power-profiles similarity index 100% rename from depracated_config/i3/scripts/power-profiles rename to config/i3/scripts/power-profiles diff --git a/depracated_config/i3/scripts/powermenu b/config/i3/scripts/powermenu similarity index 100% rename from depracated_config/i3/scripts/powermenu rename to config/i3/scripts/powermenu diff --git a/depracated_config/i3/scripts/ppd-status b/config/i3/scripts/ppd-status similarity index 100% rename from depracated_config/i3/scripts/ppd-status rename to config/i3/scripts/ppd-status diff --git a/depracated_config/i3/scripts/temperature b/config/i3/scripts/temperature similarity index 100% rename from depracated_config/i3/scripts/temperature rename to config/i3/scripts/temperature diff --git a/depracated_config/i3/scripts/volume b/config/i3/scripts/volume similarity index 100% rename from depracated_config/i3/scripts/volume rename to config/i3/scripts/volume diff --git a/depracated_config/i3/scripts/vpn b/config/i3/scripts/vpn similarity index 100% rename from depracated_config/i3/scripts/vpn rename to config/i3/scripts/vpn From 072cf1980ae7f3c8742933658e2e1f8f7daad7cb Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 16:28:04 +0100 Subject: [PATCH 09/16] Change i3 config to use kitty terminal --- config/i3/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/i3/config b/config/i3/config index 40e49916..191c17e4 100644 --- a/config/i3/config +++ b/config/i3/config @@ -139,7 +139,7 @@ bindsym $mod+r mode "resize" ###################################### # start a terminal -bindsym $mod+Return exec wezterm +bindsym $mod+Return exec kitty bindsym $mod+Shift+Return exec xfce4-terminal --drop-down # kill focused window From 0a54816c70d6c00dc060bc3192b8e938cf49c519 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 16:28:48 +0100 Subject: [PATCH 10/16] Separate common xserver options from plasma.nix, add picom and i3 configs --- nixos/desktop/i3.nix | 25 +++++++++++++++++++++++++ nixos/desktop/picom.nix | 22 ++++++++++++++++++++++ nixos/desktop/plasma.nix | 11 ++--------- nixos/desktop/xserver.nix | 13 +++++++++++++ 4 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 nixos/desktop/i3.nix create mode 100644 nixos/desktop/picom.nix create mode 100644 nixos/desktop/xserver.nix diff --git a/nixos/desktop/i3.nix b/nixos/desktop/i3.nix new file mode 100644 index 00000000..95cef7c7 --- /dev/null +++ b/nixos/desktop/i3.nix @@ -0,0 +1,25 @@ +{ ... }: +{ + imports = [ + ./common.nix + ./xserver.nix + ./picom.nix + ]; + services.xserver = { + desktopManager = { + xterm.enable = false; + xfce = { + enable = true; + noDesktop = true; + enableXfwm = false; + }; + }; + displayManager = { + defaultSession = "none+i3"; + lightdm.enable = true; + }; + windowManager.i3 = { + enable = true; + }; + }; +} diff --git a/nixos/desktop/picom.nix b/nixos/desktop/picom.nix new file mode 100644 index 00000000..bc9092a8 --- /dev/null +++ b/nixos/desktop/picom.nix @@ -0,0 +1,22 @@ +{ ... }: +{ + imports = [ + ./common.nix + ]; + services.picom = { + enable = true; + shadow = true; + fade = true; + activeOpacity = 1.0; + inactiveOpacity = 0.8; + settings = { + blur = + { + method = "dual_kawase"; + size = 10; + deviation = 5.0; + strength = 7; + }; + }; + }; +} diff --git a/nixos/desktop/plasma.nix b/nixos/desktop/plasma.nix index 7ca2ae34..901da41f 100644 --- a/nixos/desktop/plasma.nix +++ b/nixos/desktop/plasma.nix @@ -2,6 +2,8 @@ { imports = [ ./common.nix + ./xserver.nix + ./picom.nix ]; # Enable the X11 windowing system. services.xserver.enable = true; @@ -16,13 +18,4 @@ libsForQt5.lightly catppuccin-kde ]; - - # Configure keymap in X11 - services.xserver = { - layout = "gb"; - xkbVariant = ""; - }; - - # Configure console keymap - console.keyMap = "uk"; } diff --git a/nixos/desktop/xserver.nix b/nixos/desktop/xserver.nix new file mode 100644 index 00000000..6bb7c47d --- /dev/null +++ b/nixos/desktop/xserver.nix @@ -0,0 +1,13 @@ +{ ... }: +{ + imports = [ + ./common.nix + ]; + services.xserver = { + enable = true; + layout = "gb"; + xkbVariant = ""; + }; + + console.keyMap = "uk"; +} From 466c64b3d98e5923e219ac303bef22c4f1dede3d Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 16:46:09 +0100 Subject: [PATCH 11/16] Separate i3_scripts --- {config => depracated_config}/i3/config | 0 .../i3/i3blocks.conf | 0 {config => depracated_config}/i3/keybindings | 0 .../i3/scripts/bandwidth2 | 0 .../i3/scripts/battery-pinebook-pro | 0 .../i3/scripts/battery1 | 0 .../i3/scripts/battery2 | 0 .../i3/scripts/blur-lock | 0 .../i3/scripts/cpu_usage | 0 {config => depracated_config}/i3/scripts/disk | 0 .../i3/scripts/empty_workspace | 0 .../i3/scripts/keyboard-layout | 0 .../i3/scripts/keyhint | 0 .../i3/scripts/keyhint-2 | 0 .../i3/scripts/memory | 0 .../i3/scripts/openweather | 0 .../i3/scripts/openweather-city | 0 .../i3/scripts/openweather.conf | 0 .../i3/scripts/power-profiles | 0 .../i3/scripts/powermenu | 0 .../i3/scripts/ppd-status | 0 .../i3/scripts/temperature | 0 .../i3/scripts/volume | 0 {config => depracated_config}/i3/scripts/vpn | 0 i3_scripts/bandwidth2 | 104 ++++++++++ i3_scripts/battery-pinebook-pro | 18 ++ i3_scripts/battery1 | 114 +++++++++++ i3_scripts/battery2 | 106 ++++++++++ i3_scripts/blur-lock | 11 + i3_scripts/cpu_usage | 62 ++++++ i3_scripts/disk | 48 +++++ i3_scripts/empty_workspace | 10 + i3_scripts/keyboard-layout | 5 + i3_scripts/keyhint | 25 +++ i3_scripts/keyhint-2 | 6 + i3_scripts/memory | 69 +++++++ i3_scripts/openweather | 93 +++++++++ i3_scripts/openweather-city | 43 ++++ i3_scripts/openweather.conf | 5 + i3_scripts/power-profiles | 190 ++++++++++++++++++ i3_scripts/powermenu | 186 +++++++++++++++++ i3_scripts/ppd-status | 11 + i3_scripts/temperature | 86 ++++++++ i3_scripts/volume | 93 +++++++++ i3_scripts/vpn | 25 +++ 45 files changed, 1310 insertions(+) rename {config => depracated_config}/i3/config (100%) rename {config => depracated_config}/i3/i3blocks.conf (100%) rename {config => depracated_config}/i3/keybindings (100%) rename {config => depracated_config}/i3/scripts/bandwidth2 (100%) rename {config => depracated_config}/i3/scripts/battery-pinebook-pro (100%) rename {config => depracated_config}/i3/scripts/battery1 (100%) rename {config => depracated_config}/i3/scripts/battery2 (100%) rename {config => depracated_config}/i3/scripts/blur-lock (100%) rename {config => depracated_config}/i3/scripts/cpu_usage (100%) rename {config => depracated_config}/i3/scripts/disk (100%) rename {config => depracated_config}/i3/scripts/empty_workspace (100%) rename {config => depracated_config}/i3/scripts/keyboard-layout (100%) rename {config => depracated_config}/i3/scripts/keyhint (100%) rename {config => depracated_config}/i3/scripts/keyhint-2 (100%) rename {config => depracated_config}/i3/scripts/memory (100%) rename {config => depracated_config}/i3/scripts/openweather (100%) rename {config => depracated_config}/i3/scripts/openweather-city (100%) rename {config => depracated_config}/i3/scripts/openweather.conf (100%) rename {config => depracated_config}/i3/scripts/power-profiles (100%) rename {config => depracated_config}/i3/scripts/powermenu (100%) rename {config => depracated_config}/i3/scripts/ppd-status (100%) rename {config => depracated_config}/i3/scripts/temperature (100%) rename {config => depracated_config}/i3/scripts/volume (100%) rename {config => depracated_config}/i3/scripts/vpn (100%) create mode 100755 i3_scripts/bandwidth2 create mode 100755 i3_scripts/battery-pinebook-pro create mode 100755 i3_scripts/battery1 create mode 100755 i3_scripts/battery2 create mode 100755 i3_scripts/blur-lock create mode 100755 i3_scripts/cpu_usage create mode 100755 i3_scripts/disk create mode 100755 i3_scripts/empty_workspace create mode 100755 i3_scripts/keyboard-layout create mode 100755 i3_scripts/keyhint create mode 100755 i3_scripts/keyhint-2 create mode 100755 i3_scripts/memory create mode 100755 i3_scripts/openweather create mode 100755 i3_scripts/openweather-city create mode 100755 i3_scripts/openweather.conf create mode 100755 i3_scripts/power-profiles create mode 100755 i3_scripts/powermenu create mode 100755 i3_scripts/ppd-status create mode 100755 i3_scripts/temperature create mode 100755 i3_scripts/volume create mode 100755 i3_scripts/vpn diff --git a/config/i3/config b/depracated_config/i3/config similarity index 100% rename from config/i3/config rename to depracated_config/i3/config diff --git a/config/i3/i3blocks.conf b/depracated_config/i3/i3blocks.conf similarity index 100% rename from config/i3/i3blocks.conf rename to depracated_config/i3/i3blocks.conf diff --git a/config/i3/keybindings b/depracated_config/i3/keybindings similarity index 100% rename from config/i3/keybindings rename to depracated_config/i3/keybindings diff --git a/config/i3/scripts/bandwidth2 b/depracated_config/i3/scripts/bandwidth2 similarity index 100% rename from config/i3/scripts/bandwidth2 rename to depracated_config/i3/scripts/bandwidth2 diff --git a/config/i3/scripts/battery-pinebook-pro b/depracated_config/i3/scripts/battery-pinebook-pro similarity index 100% rename from config/i3/scripts/battery-pinebook-pro rename to depracated_config/i3/scripts/battery-pinebook-pro diff --git a/config/i3/scripts/battery1 b/depracated_config/i3/scripts/battery1 similarity index 100% rename from config/i3/scripts/battery1 rename to depracated_config/i3/scripts/battery1 diff --git a/config/i3/scripts/battery2 b/depracated_config/i3/scripts/battery2 similarity index 100% rename from config/i3/scripts/battery2 rename to depracated_config/i3/scripts/battery2 diff --git a/config/i3/scripts/blur-lock b/depracated_config/i3/scripts/blur-lock similarity index 100% rename from config/i3/scripts/blur-lock rename to depracated_config/i3/scripts/blur-lock diff --git a/config/i3/scripts/cpu_usage b/depracated_config/i3/scripts/cpu_usage similarity index 100% rename from config/i3/scripts/cpu_usage rename to depracated_config/i3/scripts/cpu_usage diff --git a/config/i3/scripts/disk b/depracated_config/i3/scripts/disk similarity index 100% rename from config/i3/scripts/disk rename to depracated_config/i3/scripts/disk diff --git a/config/i3/scripts/empty_workspace b/depracated_config/i3/scripts/empty_workspace similarity index 100% rename from config/i3/scripts/empty_workspace rename to depracated_config/i3/scripts/empty_workspace diff --git a/config/i3/scripts/keyboard-layout b/depracated_config/i3/scripts/keyboard-layout similarity index 100% rename from config/i3/scripts/keyboard-layout rename to depracated_config/i3/scripts/keyboard-layout diff --git a/config/i3/scripts/keyhint b/depracated_config/i3/scripts/keyhint similarity index 100% rename from config/i3/scripts/keyhint rename to depracated_config/i3/scripts/keyhint diff --git a/config/i3/scripts/keyhint-2 b/depracated_config/i3/scripts/keyhint-2 similarity index 100% rename from config/i3/scripts/keyhint-2 rename to depracated_config/i3/scripts/keyhint-2 diff --git a/config/i3/scripts/memory b/depracated_config/i3/scripts/memory similarity index 100% rename from config/i3/scripts/memory rename to depracated_config/i3/scripts/memory diff --git a/config/i3/scripts/openweather b/depracated_config/i3/scripts/openweather similarity index 100% rename from config/i3/scripts/openweather rename to depracated_config/i3/scripts/openweather diff --git a/config/i3/scripts/openweather-city b/depracated_config/i3/scripts/openweather-city similarity index 100% rename from config/i3/scripts/openweather-city rename to depracated_config/i3/scripts/openweather-city diff --git a/config/i3/scripts/openweather.conf b/depracated_config/i3/scripts/openweather.conf similarity index 100% rename from config/i3/scripts/openweather.conf rename to depracated_config/i3/scripts/openweather.conf diff --git a/config/i3/scripts/power-profiles b/depracated_config/i3/scripts/power-profiles similarity index 100% rename from config/i3/scripts/power-profiles rename to depracated_config/i3/scripts/power-profiles diff --git a/config/i3/scripts/powermenu b/depracated_config/i3/scripts/powermenu similarity index 100% rename from config/i3/scripts/powermenu rename to depracated_config/i3/scripts/powermenu diff --git a/config/i3/scripts/ppd-status b/depracated_config/i3/scripts/ppd-status similarity index 100% rename from config/i3/scripts/ppd-status rename to depracated_config/i3/scripts/ppd-status diff --git a/config/i3/scripts/temperature b/depracated_config/i3/scripts/temperature similarity index 100% rename from config/i3/scripts/temperature rename to depracated_config/i3/scripts/temperature diff --git a/config/i3/scripts/volume b/depracated_config/i3/scripts/volume similarity index 100% rename from config/i3/scripts/volume rename to depracated_config/i3/scripts/volume diff --git a/config/i3/scripts/vpn b/depracated_config/i3/scripts/vpn similarity index 100% rename from config/i3/scripts/vpn rename to depracated_config/i3/scripts/vpn diff --git a/i3_scripts/bandwidth2 b/i3_scripts/bandwidth2 new file mode 100755 index 00000000..b03250e1 --- /dev/null +++ b/i3_scripts/bandwidth2 @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2015 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to monitor bandwidth usage + +iface="${BLOCK_INSTANCE}" +iface="${IFACE:-$iface}" +dt="${DT:-3}" +unit="${UNIT:-MB}" +LABEL="${LABEL:-}" # down arrow up arrow +printf_command="${PRINTF_COMMAND:-"printf \"${LABEL}%1.0f/%1.0f %s/s\\n\", rx, wx, unit;"}" + +function default_interface { + ip route | awk '/^default via/ {print $5; exit}' +} + +function check_proc_net_dev { + if [ ! -f "/proc/net/dev" ]; then + echo "/proc/net/dev not found" + exit 1 + fi +} + +function list_interfaces { + check_proc_net_dev + echo "Interfaces in /proc/net/dev:" + grep -o "^[^:]\\+:" /proc/net/dev | tr -d " :" +} + +while getopts i:t:u:p:lh opt; do + case "$opt" in + i) iface="$OPTARG" ;; + t) dt="$OPTARG" ;; + u) unit="$OPTARG" ;; + p) printf_command="$OPTARG" ;; + l) list_interfaces && exit 0 ;; + h) printf \ +"Usage: bandwidth3 [-i interface] [-t time] [-u unit] [-p printf_command] [-l] [-h] +Options: +-i\tNetwork interface to measure. Default determined using \`ip route\`. +-t\tTime interval in seconds between measurements. Default: 3 +-u\tUnits to measure bytes in. Default: Mb +\tAllowed units: Kb, KB, Mb, MB, Gb, GB, Tb, TB +\tUnits may have optional it/its/yte/ytes on the end, e.g. Mbits, KByte +-p\tAwk command to be called after a measurement is made. +\tDefault: printf \"%%-5.1f/%%5.1f %%s/s\\\\n\", rx, wx, unit; +\tExposed variables: rx, wx, tx, unit, iface +-l\tList available interfaces in /proc/net/dev +-h\tShow this help text +" && exit 0;; + esac +done + +check_proc_net_dev + +iface="${iface:-$(default_interface)}" +while [ -z "$iface" ]; do + echo No default interface + sleep "$dt" + iface=$(default_interface) +done + +case "$unit" in + Kb|Kbit|Kbits) bytes_per_unit=$((1024 / 8));; + KB|KByte|KBytes) bytes_per_unit=$((1024));; + Mb|Mbit|Mbits) bytes_per_unit=$((1024 * 1024 / 8));; + MB|MByte|MBytes) bytes_per_unit=$((1024 * 1024));; + Gb|Gbit|Gbits) bytes_per_unit=$((1024 * 1024 * 1024 / 8));; + GB|GByte|GBytes) bytes_per_unit=$((1024 * 1024 * 1024));; + Tb|Tbit|Tbits) bytes_per_unit=$((1024 * 1024 * 1024 * 1024 / 8));; + TB|TByte|TBytes) bytes_per_unit=$((1024 * 1024 * 1024 * 1024));; + *) echo Bad unit "$unit" && exit 1;; +esac + +scalar=$((bytes_per_unit * dt)) +init_line=$(cat /proc/net/dev | grep "^[ ]*$iface:") +if [ -z "$init_line" ]; then + echo Interface not found in /proc/net/dev: "$iface" + exit 1 +fi + +init_received=$(awk '{print $2}' <<< $init_line) +init_sent=$(awk '{print $10}' <<< $init_line) + +(while true; do cat /proc/net/dev; sleep "$dt"; done) |\ + stdbuf -oL grep "^[ ]*$iface:" |\ + awk -v scalar="$scalar" -v unit="$unit" -v iface="$iface" ' +BEGIN{old_received='"$init_received"';old_sent='"$init_sent"'} +{ + received=$2 + sent=$10 + rx=(received-old_received)/scalar; + wx=(sent-old_sent)/scalar; + tx=rx+wr; + old_received=received; + old_sent=sent; + if(rx >= 0 && wx >= 0){ + '"$printf_command"'; + fflush(stdout); + } +} +' diff --git a/i3_scripts/battery-pinebook-pro b/i3_scripts/battery-pinebook-pro new file mode 100755 index 00000000..fd97370a --- /dev/null +++ b/i3_scripts/battery-pinebook-pro @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +#simple Shellscript for i3blocks on Pinebook pro +#05012020 geri123@gmx.net Gerhard S. +#battery-symbols: on Manjaro you need the awesome-terminal-fonts package installed! +PERCENT=$(cat /sys/class/power_supply/cw2015-battery/capacity) +STATUS=$(cat /sys/class/power_supply/cw2015-battery/status) +case $(( + $PERCENT >= 0 && $PERCENT <= 20 ? 1 : + $PERCENT > 20 && $PERCENT <= 40 ? 2 : + $PERCENT > 40 && $PERCENT <= 60 ? 3 : + $PERCENT > 60 && $PERCENT <= 80 ? 4 : 5)) in +# + (1) echo $STATUS:"" :$PERCENT%;; + (2) echo $STATUS:"" :$PERCENT%;; + (3) echo $STATUS:"" :$PERCENT%;; + (4) echo $STATUS:"" :$PERCENT%;; + (5) echo $STATUS:"" :$PERCENT%;; +esac diff --git a/i3_scripts/battery1 b/i3_scripts/battery1 new file mode 100755 index 00000000..3b9d5a7a --- /dev/null +++ b/i3_scripts/battery1 @@ -0,0 +1,114 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# +# Licensed under the terms of the GNU GPL v3, or any later version. +# +# This script is meant to use with i3blocks. It parses the output of the "acpi" +# command (often provided by a package of the same name) to read the status of +# the battery, and eventually its remaining time (to full charge or discharge). +# +# The color will gradually change for a percentage below 85%, and the urgency +# (exit code 33) is set if there is less that 5% remaining. + +# Edited by Andreas Lindlbauer + +use strict; +use warnings; +use utf8; + +# otherwise we get in console "Wide character in print at" +binmode(STDOUT, ':utf8'); + +# my $acpi; +my $upower; +my $percent; +my $bat_state; +my $status; +my $ac_adapt; +my $full_text; +my $short_text; +my $label = '😅'; +my $bat_number = $ENV{BLOCK_INSTANCE} || 0; + +open (UPOWER, "upower -i /org/freedesktop/UPower/devices/battery_BAT$bat_number | grep 'percentage' |") or die; +$upower = ; +close(UPOWER); + +# fail on unexpected output +if ($upower !~ /: (\d+)%/) { + die "$upower\n"; +} + +$percent = $1; +$full_text = "$percent%"; + +open (BAT_STATE, "upower -i /org/freedesktop/UPower/devices/battery_BAT$bat_number | grep 'state' |") or die; +$bat_state = ; +close(BAT_STATE); + +if ($bat_state !~ /: (\w+)/) { + die "$bat_state\n"; +} +$status = $1; + +if ($status eq 'discharging') { + $full_text .= ' '; +} elsif ($status eq 'charging') { + $full_text .= ' '; +} elsif ($status eq 'Unknown') { + open (AC_ADAPTER, "acpi -a |") or die; + $ac_adapt = ; + close(AC_ADAPTER); + + if ($ac_adapt =~ /: ([\w-]+)/) { + $ac_adapt = $1; + + if ($ac_adapt eq 'on-line') { + $full_text .= ' CHR'; + } elsif ($ac_adapt eq 'off-line') { + $full_text .= ' DIS'; + } + } +} + +$short_text = $full_text; + +if ($percent < 20) { + $label = ''; +} elsif ($percent < 45) { + $label = ''; +} elsif ($percent < 70) { + $label = ''; +} elsif ($percent < 95) { + $label = ''; +} else { + $label = ''; +} + +# print text +print " ${label}"; +print " $full_text\n"; +print " ${label}"; +print " $short_text\n"; + +# consider color and urgent flag only on discharge +if ($status eq 'discharging') { + + if ($percent < 20) { + print "#FF0000\n"; + } elsif ($percent < 40) { + print "#FFAE00\n"; + } elsif ($percent < 60) { + print "#FFF600\n"; + } elsif ($percent < 85) { + print "#A8FF00\n"; + } + + if ($percent < 5) { + exit(33); + } +} + +exit(0); diff --git a/i3_scripts/battery2 b/i3_scripts/battery2 new file mode 100755 index 00000000..2d55dab9 --- /dev/null +++ b/i3_scripts/battery2 @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 James Murphy +# Licensed under the GPL version 2 only +# +# A battery indicator blocklet script for i3blocks + +from subprocess import check_output +import os +import re + +config = dict(os.environ) +status = check_output(['acpi'], universal_newlines=True) + +if not status: + # stands for no battery found + color = config.get("color_10", "red") + fulltext = "\uf00d \uf240".format(color) + percentleft = 100 +else: + # if there is more than one battery in one laptop, the percentage left is + # available for each battery separately, although state and remaining + # time for overall block is shown in the status of the first battery + batteries = status.split("\n") + state_batteries=[] + commasplitstatus_batteries=[] + percentleft_batteries=[] + time = "" + for battery in batteries: + if battery!='': + state_batteries.append(battery.split(": ")[1].split(", ")[0]) + commasplitstatus = battery.split(", ") + if not time: + time = commasplitstatus[-1].strip() + # check if it matches a time + time = re.match(r"(\d+):(\d+)", time) + if time: + time = ":".join(time.groups()) + timeleft = " ({})".format(time) + else: + timeleft = "" + + p = int(commasplitstatus[1].rstrip("%\n")) + if p>0: + percentleft_batteries.append(p) + commasplitstatus_batteries.append(commasplitstatus) + state = state_batteries[0] + commasplitstatus = commasplitstatus_batteries[0] + if percentleft_batteries: + percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries)) + else: + percentleft = 0 + + # stands for charging + color = config.get("color_charging", "yellow") + FA_LIGHTNING = "\uf0e7".format(color) + + # stands for plugged in + FA_PLUG = "\uf1e6" + + # stands for using battery + FA_BATTERY = "\uf240" + + # stands for unknown status of battery + FA_QUESTION = "\uf128" + + + if state == "Discharging": + fulltext = FA_BATTERY + " " + elif state == "Full": + fulltext = FA_PLUG + " " + timeleft = "" + elif state == "Unknown": + fulltext = FA_QUESTION + " " + FA_BATTERY + " " + timeleft = "" + else: + fulltext = FA_LIGHTNING + " " + FA_PLUG + " " + + def color(percent): + if percent < 10: + # exit code 33 will turn background red + return config.get("color_10", "#FFFFFF") + if percent < 20: + return config.get("color_20", "#FF3300") + if percent < 30: + return config.get("color_30", "#FF6600") + if percent < 40: + return config.get("color_40", "#FF9900") + if percent < 50: + return config.get("color_50", "#FFCC00") + if percent < 60: + return config.get("color_60", "#FFFF00") + if percent < 70: + return config.get("color_70", "#FFFF33") + if percent < 80: + return config.get("color_80", "#FFFF66") + return config.get("color_full", "#FFFFFF") + + form = '{}%' + fulltext += form.format(color(percentleft), percentleft) + #fulltext += timeleft + +print(fulltext) +print(fulltext) +if percentleft < 10: + exit(33) diff --git a/i3_scripts/blur-lock b/i3_scripts/blur-lock new file mode 100755 index 00000000..b8e96198 --- /dev/null +++ b/i3_scripts/blur-lock @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +PICTURE=/tmp/i3lock.png +SCREENSHOT="scrot -z $PICTURE" + +BLUR="15x12" + +$SCREENSHOT +convert $PICTURE -blur $BLUR $PICTURE +i3lock -i $PICTURE +rm $PICTURE diff --git a/i3_scripts/cpu_usage b/i3_scripts/cpu_usage new file mode 100755 index 00000000..8d8a267d --- /dev/null +++ b/i3_scripts/cpu_usage @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# +# Licensed under the terms of the GNU GPL v3, or any later version. + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +# default values +my $t_warn = $ENV{T_WARN} // 50; +my $t_crit = $ENV{T_CRIT} // 80; +my $cpu_usage = -1; +my $decimals = $ENV{DECIMALS} // 0; +my $label = $ENV{LABEL} // ""; + +sub help { + print "Usage: cpu_usage [-w ] [-c ] [-d ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "-d : Use decimals for percentage (default is $decimals) \n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "d=i" => \$decimals, +); + +# Get CPU usage +$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is +open (MPSTAT, 'mpstat 1 1 |') or die; +while () { + if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { + $cpu_usage = 100 - $1; # 100% - %idle + last; + } +} +close(MPSTAT); + +$cpu_usage eq -1 and die 'Can\'t find CPU information'; + +# Print short_text, full_text +print "${label}"; +printf "%02.${decimals}f%%\n", $cpu_usage; +print "${label}"; +printf "%02.${decimals}f%%\n", $cpu_usage; + +# Print color, if needed +if ($cpu_usage >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($cpu_usage >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/i3_scripts/disk b/i3_scripts/disk new file mode 100755 index 00000000..e18c7aad --- /dev/null +++ b/i3_scripts/disk @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +DIR="${DIR:-$BLOCK_INSTANCE}" +DIR="${DIR:-$HOME}" +ALERT_LOW="${ALERT_LOW:-$1}" +ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%) + +LOCAL_FLAG="-l" +if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then + LOCAL_FLAG="" +fi + +df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW ' +/\/.*/ { + # full text + print label $4 + + # short text + print label $4 + + use=$5 + + # no need to continue parsing + exit 0 +} + +END { + gsub(/%$/,"",use) + if (100 - use < alert_low) { + # color + print "#FF0000" + } +} +' diff --git a/i3_scripts/empty_workspace b/i3_scripts/empty_workspace new file mode 100755 index 00000000..b962cdea --- /dev/null +++ b/i3_scripts/empty_workspace @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +MAX_DESKTOPS=20 + +WORKSPACES=$(seq -s '\n' 1 1 ${MAX_DESKTOPS}) + +EMPTY_WORKSPACE=$( (i3-msg -t get_workspaces | tr ',' '\n' | grep num | awk -F: '{print int($2)}' ; \ + echo -e ${WORKSPACES} ) | sort -n | uniq -u | head -n 1) + +i3-msg workspace ${EMPTY_WORKSPACE} diff --git a/i3_scripts/keyboard-layout b/i3_scripts/keyboard-layout new file mode 100755 index 00000000..9a3e3140 --- /dev/null +++ b/i3_scripts/keyboard-layout @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +KBD=$(/usr/bin/xkblayout-state print '%s') +echo $KBD + diff --git a/i3_scripts/keyhint b/i3_scripts/keyhint new file mode 100755 index 00000000..8b8c3e3d --- /dev/null +++ b/i3_scripts/keyhint @@ -0,0 +1,25 @@ +#!/bin/bash + +Main() { + source /usr/share/endeavouros/scripts/eos-script-lib-yad || return 1 + + local command=( + eos_yad --title="EndeavourOS i3-wm keybindings:" --no-buttons --geometry=400x345-15-400 --list + --column=key: --column=description: --column=command: + "ESC" "close this app" "" + "=" "modkey" "(set mod Mod4)" + "+enter" "open a terminal" "" + "+Shift+n" "new empty workspace" "" + "+w" "open Browser" "" + "+n" "open Filebrowser" "" + "+d" "app menu" "" + "+q" "close focused app" "" + "Print-key" "screenshot" "" + "+Shift+e" "logout menu" "" + "F1" "open keybinding helper" "" + ) + + "${command[@]}" +} + +Main "$@" diff --git a/i3_scripts/keyhint-2 b/i3_scripts/keyhint-2 new file mode 100755 index 00000000..2e86d125 --- /dev/null +++ b/i3_scripts/keyhint-2 @@ -0,0 +1,6 @@ +I3_CONFIG=$HOME/.config/i3/config +mod_key=$(sed -nre 's/^set \$mod (.*)/\1/p' ${I3_CONFIG}) +grep "^bindsym" ${I3_CONFIG} \ + | sed "s/-\(-\w\+\)\+//g;s/\$mod/${mod_key}/g;s/Mod1/Alt/g;s/exec //;s/bindsym //;s/^\s\+//;s/^\([^ ]\+\) \(.\+\)$/\2: \1/;s/^\s\+//" \ + | tr -s ' ' \ + | rofi -dmenu -theme ~/.config/rofi/rofikeyhint.rasi diff --git a/i3_scripts/memory b/i3_scripts/memory new file mode 100755 index 00000000..6a69a6f5 --- /dev/null +++ b/i3_scripts/memory @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +TYPE="${BLOCK_INSTANCE:-mem}" + +awk -v type=$TYPE ' +/^MemTotal:/ { + mem_total=$2 +} +/^MemFree:/ { + mem_free=$2 +} +/^Buffers:/ { + mem_free+=$2 +} +/^Cached:/ { + mem_free+=$2 +} +/^SwapTotal:/ { + swap_total=$2 +} +/^SwapFree:/ { + swap_free=$2 +} +END { + if (type == "swap") { + free=swap_free/1024/1024 + used=(swap_total-swap_free)/1024/1024 + total=swap_total/1024/1024 + } else { + free=mem_free/1024/1024 + used=(mem_total-mem_free)/1024/1024 + total=mem_total/1024/1024 + } + + pct=0 + if (total > 0) { + pct=used/total*100 + } + + # full text + # printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct) + + # short text + printf("%.f%%\n", pct) + + # color + if (pct > 90) { + print("#FF0000") + } else if (pct > 80) { + print("#FFAE00") + } else if (pct > 70) { + print("#FFF600") + } +} +' /proc/meminfo diff --git a/i3_scripts/openweather b/i3_scripts/openweather new file mode 100755 index 00000000..c51f9d31 --- /dev/null +++ b/i3_scripts/openweather @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# Edited by Andreas Lindlbauer + +temps=("#0600FF" "#0500FF" "#0400FF" "#0300FF" "#0200FF" "#0100FF" "#0000FF" "#0002FF" "#0012FF" "#0022FF" "#0032FF" "#0044FF" "#0054FF" "#0064FF" "#0074FF" "#0084FF" "#0094FF" "#00A4FF" "#00B4FF" "#00C4FF" "#00D4FF" "#00E4FF" "#00FFF4" "#00FFD0" "#00FFA8" "#00FF83" "#00FF5C" "#00FF36" "#00FF10" "#17FF00" "#3EFF00" "#65FF00" "#B0FF00" "#FDFF00" "#FFF000" "#FFDC00" "#FFC800" "#FFB400" "#FFA000" "#FF8C00" "#FF7800" "#FF6400" "#FF5000" "#FF3C00" "#FF2800" "#FF1400" "#FF0000") + +command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. +Aborting."; exit 1; } +command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. +Aborting."; exit 1; } + +# To use this script you need to create an API key here https://home.openweathermap.org +# You need to put your Open Weather APIKEY here: +APIKEY="keykeykey" +# And get your Latitute and Longitudes to put in here: +LAT="XX.XXXX" +LON="XX.XXXX" +URL="http://api.openweathermap.org/data/2.5/onecall?lat=${LAT}&lon=${LON}&units=metric&exclude=minutely,hourly,daily&APPID=${APIKEY}" +WEATHER_RESPONSE=$(wget -qO- "${URL}") + +WEATHER_CONDITION=$(echo "$WEATHER_RESPONSE" | jq '.current.weather[0].main' | sed 's/"//g') +WEATHER_TEMP=$(echo "$WEATHER_RESPONSE" | jq '.current.feels_like') +WEATHER_INT=${WEATHER_TEMP%.*} + +TIME_NOW=$( echo "$WEATHER_RESPONSE" | jq '.current.dt') +SUNRISE=$( echo "$WEATHER_RESPONSE" | jq '.current.sunrise') +SUNSET=$( echo "$WEATHER_RESPONSE" | jq '.current.sunset') +DESCRIPTION=$( echo "$WEATHER_RESPONSE" | jq '.current.weather[0].description' | sed 's/"//g') +WEATHER_ALERT=$( echo "$WEATHER_RESPONSE" | jq '.alerts[0].event' | sed 's/"//g') +DAYTIME="n" + +if [[ "$TIME_NOW" > "$SUNRISE" ]] && [[ "$TIME_NOW" < "$SUNSET" ]]; then + DAYTIME="d" +fi + +case $WEATHER_CONDITION in + 'Clouds') + if [ "$DAYTIME" == "d" ]; then + WEATHER_ICON="" + else + WEATHER_ICON="" + fi + ;; + 'Rain') + WEATHER_ICON="" + ;; + 'Drizzle') + if [ "$DAYTIME" == "d" ]; then + WEATHER_ICON="" + else + WEATHER_ICON="" + fi + ;; + 'Thunderstorm') + WEATHER_ICON="" + ;; + 'Snow') + WEATHER_ICON="" + ;; + 'Clear') + if [ "$DAYTIME" == "d" ]; then + WEATHER_ICON="" + else + WEATHER_ICON="" + fi + ;; + *) + WEATHER_ICON="🌫" + ;; +esac + +WEATHER_COLOR="#FFFFFF" +if [ "$WEATHER_INT" -lt "-11" ]; then + WEATHER_COLOR="#0000FF" +elif [ "$WEATHER_INT" -gt 35 ]; then + WEATHER_COLOR="#FF0000" +else + WEATHER_INT=$(( WEATHER_INT + 11 )) + WEATHER_COLOR="${temps[$WEATHER_INT]}" +fi + +full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION} " +if [ "$WEATHER_ALERT" != "null" ]; then + WARN_START=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].start') + WARN_END=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].end') + WARN_START=$(date -d @"$WARN_START" +%a_%k:%M) + WARN_END=$(date -d @"$WARN_END" +%a_%k:%M) + full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION}  ${WEATHER_ALERT} from ${WARN_START} to ${WARN_END}  " +fi + + +echo "${full_text}" +echo "${WEATHER_TEMP}°C " +echo "${WEATHER_COLOR}" diff --git a/i3_scripts/openweather-city b/i3_scripts/openweather-city new file mode 100755 index 00000000..6ea051c1 --- /dev/null +++ b/i3_scripts/openweather-city @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. +Aborting."; exit 1; } +command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. +Aborting."; exit 1; } + +# To use this script you need to create an API key here https://home.openweathermap.org +# You need to put your Open Weather APIKEY here: +APIKEY="keykey" +# find your City ID here: https://openweathermap.org/ +# search for your city and copy the ID from the URL inside the browser. +CITY_ID="idid" +URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}" + +WEATHER_RESPONSE=$(wget -qO- "${URL}") + +WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g') +WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp') +WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg') +WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed') + +WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}") +WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}") +DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N ) +WIND_DIR=${DIR_ARRAY[WIND_DIR]} + +case $WEATHER_CONDITION in + 'Clouds') + WEATHER_ICON="" + ;; + 'Rain') + WEATHER_ICON="" + ;; + 'Snow') + WEATHER_ICON="" + ;; + *) + WEATHER_ICON="" + ;; +esac + +echo "${WEATHER_ICON} ${WEATHER_TEMP}°C: ${WIND_SPEED} km/h ${WIND_DIR}" diff --git a/i3_scripts/openweather.conf b/i3_scripts/openweather.conf new file mode 100755 index 00000000..f11aa868 --- /dev/null +++ b/i3_scripts/openweather.conf @@ -0,0 +1,5 @@ +# Weather +[Weather] +command=~/.config/i3/scripts/openweather +interval=1800 +color=#7275b3 diff --git a/i3_scripts/power-profiles b/i3_scripts/power-profiles new file mode 100755 index 00000000..feb63dc5 --- /dev/null +++ b/i3_scripts/power-profiles @@ -0,0 +1,190 @@ +#!/usr/bin/env bash +# +# Use rofi/zenity to change system runstate thanks to systemd. +# +# Note: this currently relies on associative array support in the shell. +# +# Inspired from i3pystatus wiki: +# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu +# +# Copyright 2015 Benjamin Chrétien +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# power-profiles-daemon implementation: +# needs package power-profiles-daemon installed and the service running see here: +# https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon +# used in i3-blocks: ~/.config/i3/i3blocks.conf together with: ~/.config/i3/scripts/ppd-status + + +####################################################################### +# BEGIN CONFIG # +####################################################################### + +# Use a custom lock script +#LOCKSCRIPT="i3lock-extra -m pixelize" + +# Colors: FG (foreground), BG (background), HL (highlighted) +FG_COLOR="#bbbbbb" +BG_COLOR="#111111" +HLFG_COLOR="#111111" +HLBG_COLOR="#bbbbbb" +BORDER_COLOR="#222222" + +# Options not related to colors +#ROFI_TEXT=":" +#ROFI_OPTIONS=(-width -11 -location 0 -hide-scrollbar -bw 30 -color-window "#dd310027,#dd0310027,#dd310027" -padding 5) +#ROFI_OPTIONS=(-width -18 -location 4 -hide-scrollbar -color-window "#cc310027,#00a0009a,#cc310027" -padding 5 -font "Sourcecode Pro Regular 10, FontAwesome 9") +ROFI_OPTIONS=(-theme ~/.config/rofi/power-profiles.rasi) +# Zenity options +ZENITY_TITLE="Power Profiles" +ZENITY_TEXT="Set Profiles:" +ZENITY_OPTIONS=(--column= --hide-header) + +####################################################################### +# END CONFIG # +####################################################################### + +# Whether to ask for user's confirmation +enable_confirmation=false + +# Preferred launcher if both are available +preferred_launcher="rofi" + +usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. + +where: + -h show this help text + -c ask for user confirmation + -p preferred launcher (rofi or zenity) + +This script depends on: + - systemd, + - i3, + - rofi or zenity." + +# Check whether the user-defined launcher is valid +launcher_list=(rofi zenity) +function check_launcher() { + if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then + echo "Supported launchers: ${launcher_list[*]}" + exit 1 + else + # Get array with unique elements and preferred launcher first + # Note: uniq expects a sorted list, so we cannot use it + i=1 + launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ + | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) + fi +} + +# Parse CLI arguments +while getopts "hcp:" option; do + case "${option}" in + h) echo "${usage}" + exit 0 + ;; + c) enable_confirmation=true + ;; + p) preferred_launcher="${OPTARG}" + check_launcher "${preferred_launcher}" + ;; + *) exit 1 + ;; + esac +done + +# Check whether a command exists +function command_exists() { + command -v "$1" &> /dev/null 2>&1 +} + +# systemctl required +if ! command_exists systemctl ; then + exit 1 +fi + +# menu defined as an associative array +typeset -A menu + +# Menu with keys/commands + +menu=( + [ Performance]="powerprofilesctl set performance" + [ Balanced]="powerprofilesctl set balanced" + [ Power Saver]="powerprofilesctl set power-saver" + [ Cancel]="" +) + +menu_nrows=${#menu[@]} + +# Menu entries that may trigger a confirmation message +menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" + +launcher_exe="" +launcher_options="" +rofi_colors="" + +function prepare_launcher() { + if [[ "$1" == "rofi" ]]; then + rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ + -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") + launcher_exe="rofi" + launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ + "${rofi_colors}" "${ROFI_OPTIONS[@]}") + elif [[ "$1" == "zenity" ]]; then + launcher_exe="zenity" + launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ + "${ZENITY_OPTIONS[@]}") + fi +} + +for l in "${launcher_list[@]}"; do + if command_exists "${l}" ; then + prepare_launcher "${l}" + break + fi +done + +# No launcher available +if [[ -z "${launcher_exe}" ]]; then + exit 1 +fi + +launcher=(${launcher_exe} "${launcher_options[@]}") +selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" + +function ask_confirmation() { + if [ "${launcher_exe}" == "rofi" ]; then + confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ + "${rofi_colors}" "${ROFI_OPTIONS[@]}") + [ "${confirmed}" == "Yes" ] && confirmed=0 + elif [ "${launcher_exe}" == "zenity" ]; then + zenity --question --text "Are you sure you want to ${selection,,}?" + confirmed=$? + fi + + if [ "${confirmed}" == 0 ]; then + i3-msg -q "exec --no-startup-id ${menu[${selection}]}" + fi +} + +if [[ $? -eq 0 && ! -z ${selection} ]]; then + if [[ "${enable_confirmation}" = true && \ + ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then + ask_confirmation + else + i3-msg -q "exec --no-startup-id ${menu[${selection}]}" + fi +fi diff --git a/i3_scripts/powermenu b/i3_scripts/powermenu new file mode 100755 index 00000000..791a9e4a --- /dev/null +++ b/i3_scripts/powermenu @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +# +# Use rofi/zenity to change system runstate thanks to systemd. +# +# Note: this currently relies on associative array support in the shell. +# +# Inspired from i3pystatus wiki: +# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu +# +# Copyright 2015 Benjamin Chrétien +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# modified to work with latest rofi update by joekamprad + +####################################################################### +# BEGIN CONFIG # +####################################################################### + +# Use a custom lock script +#LOCKSCRIPT="i3lock-extra -m pixelize" + +# Colors: FG (foreground), BG (background), HL (highlighted) +FG_COLOR="#bbbbbb" +BG_COLOR="#111111" +HLFG_COLOR="#111111" +HLBG_COLOR="#bbbbbb" +BORDER_COLOR="#222222" + +# Options not related to colors (most rofi options do not work anymore) +ROFI_OPTIONS=(-theme ~/.config/rofi/powermenu.rasi) +# Zenity options +ZENITY_TITLE="Power Menu" +ZENITY_TEXT="Action:" +ZENITY_OPTIONS=(--column= --hide-header) + +####################################################################### +# END CONFIG # +####################################################################### + +# Whether to ask for user's confirmation +enable_confirmation=false + +# Preferred launcher if both are available +preferred_launcher="rofi" + +usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. + +where: + -h show this help text + -c ask for user confirmation + -p preferred launcher (rofi or zenity) + +This script depends on: + - systemd, + - i3, + - rofi or zenity." + +# Check whether the user-defined launcher is valid +launcher_list=(rofi zenity) +function check_launcher() { + if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then + echo "Supported launchers: ${launcher_list[*]}" + exit 1 + else + # Get array with unique elements and preferred launcher first + # Note: uniq expects a sorted list, so we cannot use it + i=1 + launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ + | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) + fi +} + +# Parse CLI arguments +while getopts "hcp:" option; do + case "${option}" in + h) echo "${usage}" + exit 0 + ;; + c) enable_confirmation=true + ;; + p) preferred_launcher="${OPTARG}" + check_launcher "${preferred_launcher}" + ;; + *) exit 1 + ;; + esac +done + +# Check whether a command exists +function command_exists() { + command -v "$1" &> /dev/null 2>&1 +} + +# systemctl required +if ! command_exists systemctl ; then + exit 1 +fi + +# menu defined as an associative array +typeset -A menu + +# Menu with keys/commands + +menu=( + [ Shutdown]="systemctl poweroff" + [ Reboot]="systemctl reboot" + [ Suspend]="systemctl suspend" + [ Hibernate]="systemctl hibernate" + [ Lock]="~/.config/i3/scripts/blur-lock" + [ Logout]="i3-msg exit" + [ Cancel]="" +) + +menu_nrows=${#menu[@]} + +# Menu entries that may trigger a confirmation message +menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" + +launcher_exe="" +launcher_options="" +rofi_colors="" + +function prepare_launcher() { + if [[ "$1" == "rofi" ]]; then + rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ + -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") + launcher_exe="rofi" + launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ + "${rofi_colors}" "${ROFI_OPTIONS[@]}") + elif [[ "$1" == "zenity" ]]; then + launcher_exe="zenity" + launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ + "${ZENITY_OPTIONS[@]}") + fi +} + +for l in "${launcher_list[@]}"; do + if command_exists "${l}" ; then + prepare_launcher "${l}" + break + fi +done + +# No launcher available +if [[ -z "${launcher_exe}" ]]; then + exit 1 +fi + +launcher=(${launcher_exe} "${launcher_options[@]}") +selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" + +function ask_confirmation() { + if [ "${launcher_exe}" == "rofi" ]; then + confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ + "${rofi_colors}" "${ROFI_OPTIONS[@]}") + [ "${confirmed}" == "Yes" ] && confirmed=0 + elif [ "${launcher_exe}" == "zenity" ]; then + zenity --question --text "Are you sure you want to ${selection,,}?" + confirmed=$? + fi + + if [ "${confirmed}" == 0 ]; then + i3-msg -q "exec --no-startup-id ${menu[${selection}]}" + fi +} + +if [[ $? -eq 0 && ! -z ${selection} ]]; then + if [[ "${enable_confirmation}" = true && \ + ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then + ask_confirmation + else + i3-msg -q "exec --no-startup-id ${menu[${selection}]}" + fi +fi diff --git a/i3_scripts/ppd-status b/i3_scripts/ppd-status new file mode 100755 index 00000000..8e6eb7b7 --- /dev/null +++ b/i3_scripts/ppd-status @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# +# power-profiles-daemon implementation: +# needs package power-profiles-daemon installed and the service running see here: +# https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon +# used in i3-blocks: ~/.config/i3/i3blocks.conf together with: ~/.config/i3/scripts/power-profiles + +# script to show current power profile + +current_profile=$(/usr/bin/powerprofilesctl get) +echo "$current_profile" diff --git a/i3_scripts/temperature b/i3_scripts/temperature new file mode 100755 index 00000000..4e31610a --- /dev/null +++ b/i3_scripts/temperature @@ -0,0 +1,86 @@ +#!/usr/bin/env perl +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# Copyright 2014 Benjamin Chretien + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Edited by Andreas Lindlbauer + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +binmode(STDOUT, ":utf8"); + +# default values +my $t_warn = $ENV{T_WARN} || 70; +my $t_crit = $ENV{T_CRIT} || 90; +my $chip = $ENV{SENSOR_CHIP} || ""; +my $temperature = -9999; +my $label = "😀 "; + +sub help { + print "Usage: temperature [-w ] [-c ] [--chip ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "--chip : sensor chip\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "chip=s" => \$chip); + +# Get chip temperature +open (SENSORS, "sensors -u $chip |") or die; +while () { + if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) { + $temperature = $1; + last; + } +} +close(SENSORS); + +$temperature eq -9999 and die 'Cannot find temperature'; + +if ($temperature < 45) { + $label = ''; +} elsif ($temperature < 55) { + $label = ''; +} elsif ($temperature < 65) { + $label = ''; +} elsif ($temperature < 75) { + $label = ''; +} else { + $label = ''; +} +# Print short_text, full_text +print "${label}"; +print " $temperature°C\n"; +print "${label}"; +print " $temperature°C\n"; + +# Print color, if needed +if ($temperature >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($temperature >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/i3_scripts/volume b/i3_scripts/volume new file mode 100755 index 00000000..39618e1b --- /dev/null +++ b/i3_scripts/volume @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# original source: https://github.com/vivien/i3blocks-contrib/tree/master/volume +# check the readme: https://github.com/vivien/i3blocks-contrib/blob/master/volume/README.md +#------------------------------------------------------------------------ + +# The second parameter overrides the mixer selection +# For PulseAudio users, eventually use "pulse" +# For Jack/Jack2 users, use "jackplug" +# For ALSA users, you may use "default" for your primary card +# or you may use hw:# where # is the number of the card desired +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then + # pulseaudio is running, but not all installations use "pulse" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi + fi + [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" + MIXER="${2:-$MIXER}" +fi + +# The instance option sets the control to report and configure +# This defaults to the first control of your selected mixer +# For a list of the available, use `amixer -D $Your_Mixer scontrols` +if [[ -z "$SCONTROL" ]] ; then + SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | + sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | + head -n1 + )}" +fi + +# The first parameter sets the step to change the volume by (and units to display) +# This may be in in % or dB (eg. 5% or 3dB) +if [[ -z "$STEP" ]] ; then + STEP="${1:-5%}" +fi + +# AMIXER(1): +# "Use the mapped volume for evaluating the percentage representation like alsamixer, to be +# more natural for human ear." +NATURAL_MAPPING=${NATURAL_MAPPING:-0} +if [[ "$NATURAL_MAPPING" != "0" ]] ; then + AMIXER_PARAMS="-M" +fi + +#------------------------------------------------------------------------ + +capability() { # Return "Capture" if the device is a capture device + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL | + sed -n "s/ Capabilities:.*cvolume.*/Capture/p" +} + +volume() { + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL $(capability) +} + +format() { + + perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' + perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "' + # If dB was selected, print that instead + perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1') + perl_filter+='"; exit}' + output=$(perl -ne "$perl_filter") + echo "$LABEL$output" +} + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 3) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease +esac + +volume | format diff --git a/i3_scripts/vpn b/i3_scripts/vpn new file mode 100755 index 00000000..a348f96e --- /dev/null +++ b/i3_scripts/vpn @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2021 Andreas Lindlbauer +# Licensed under the terms of EUPLv1.2. +# +# i3blocks blocklet script to monitor the (nord)vpn connection + +vpnstatus="📢" +nordvpn_output=$(nordvpn status | cat -v | head -1 | sed -e 's/\^M-^M ^M//g' ) +if [ "${nordvpn_output}" = "Status: Connected" ]; then + vpnstatus="🥸" +elif [ "${nordvpn_output}" = "A new version of NordVPN is available! Please update the application." ]; then + nordvpn_output=$(nordvpn status | cat -v | head -2 | tail -1 | sed -e 's/\^M-^M ^M//g' ) + if [ "${nordvpn_output}" = "Status: Connected" ]; then + vpnstatus="🥴" + elif [ "${nordvpn_output}" = "Status: Disconnected" ]; then + vpnstatus="📢" + fi +elif [ "${nordvpn_output}" = "Status: Disconnected" ]; then + vpnstatus="📢" +elif [[ "$nordvpn_output" == *\/* ]] || [[ "$nordvpn_output" == *\\* ]]; then + vpnstatus="Something's very wrong" +fi + +echo "$vpnstatus" From 59f7900cfd288d815f62f8c6cb3be9d0a05e4a81 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 16:46:18 +0100 Subject: [PATCH 12/16] Link i3_config --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 839eea88..5840dcad 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ SSH_ITEMS := $(wildcard ssh/*) SSH_TARGETS := $(SSH_ITEMS:ssh/%=$(SSH_DIR)/%) LAZY_REPO := https://github.com/folke/lazy.nvim.git -PYENV_DIR := $(if $(PYENV_ROOT), $(PYENV_ROOT), $(HOME)/.pyenv) .PHONY: default all clean check directories link install @@ -25,12 +24,13 @@ directories: $(CONFIG_DIR) $(SSH_DIR) $(CONFIG_DIR) $(SSH_DIR): mkdir -p $@ -link: $(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc +link: $(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc $(HOME)/.i3_scripts $(CONFIG_TARGETS): $(CONFIG_DIR)/%: config/% $(SSH_DIR)/config.d: $(SSH_DIR)/%: ssh/% $(HOME)/.inputrc: $(HOME)/%: % -$(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc: +$(HOME)/.i3_scripts: $(HOME)/.%: % +$(CONFIG_TARGETS) $(SSH_DIR)/config.d $(HOME)/.inputrc $(HOME)/.i3_scripts: ln -s $(PWD)/$? $@ install: $(LAZY_DIR) From c4d0eb3df8c11abf8a2e93617da3c395f3339e2a Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 3 Apr 2023 16:53:23 +0100 Subject: [PATCH 13/16] Add more i3 cofig --- .../env/config/i3/keybindings.nix | 31 +++++ nixos/home-manager/env/config/i3/startup.nix | 5 + .../env/config/rofi/catppuccin-macchiato.rasi | 111 ++++++++++++++++++ nixos/home-manager/env/default.nix | 6 + nixos/home-manager/env/dunst.nix | 66 +++++++++++ nixos/home-manager/env/i3.nix | 37 ++++++ nixos/home-manager/env/rofi.nix | 9 ++ 7 files changed, 265 insertions(+) create mode 100644 nixos/home-manager/env/config/i3/keybindings.nix create mode 100644 nixos/home-manager/env/config/i3/startup.nix create mode 100644 nixos/home-manager/env/config/rofi/catppuccin-macchiato.rasi create mode 100644 nixos/home-manager/env/default.nix create mode 100644 nixos/home-manager/env/dunst.nix create mode 100644 nixos/home-manager/env/i3.nix create mode 100644 nixos/home-manager/env/rofi.nix diff --git a/nixos/home-manager/env/config/i3/keybindings.nix b/nixos/home-manager/env/config/i3/keybindings.nix new file mode 100644 index 00000000..b8a16889 --- /dev/null +++ b/nixos/home-manager/env/config/i3/keybindings.nix @@ -0,0 +1,31 @@ +let + mod = "Mod4"; +in +{ + "${mod}+Tab" = "workspace next"; + "${mod}+Shift+Tab" = "workspace prev"; + # + "${mod}+Return" = "exec kitty"; + #"${mod}+Shift+Return" = "exec xfce4-terminal --drop-down"; + "${mod}+q" = "kill"; + # + "${mod}+Shift+c" = "reload"; + "${mod}+Shift+r" = "restart"; + # + "${mod}+h" = "focus left"; + "${mod}+Shift+h" = "move left"; + "${mod}+Left" = "focus left"; + "${mod}+Shift+Left" = "move left"; + "${mod}+j" = "focus down"; + "${mod}+Shift+j" = "move down"; + "${mod}+Down" = "focus down"; + "${mod}+Shift+Down" = "move down"; + "${mod}+k" = "focus up"; + "${mod}+Shift+k" = "move up"; + "${mod}+Up" = "focus up"; + "${mod}+Shift+Up" = "move up"; + "${mod}+l" = "focus right"; + "${mod}+Shift+l" = "move right"; + "${mod}+Right" = "focus right"; + "${mod}+Shift+Right" = "move right"; +} diff --git a/nixos/home-manager/env/config/i3/startup.nix b/nixos/home-manager/env/config/i3/startup.nix new file mode 100644 index 00000000..fb6362ba --- /dev/null +++ b/nixos/home-manager/env/config/i3/startup.nix @@ -0,0 +1,5 @@ +{ ... }: +[ + { command = "$HOME/.screenlayout/default.sh";} + { command = "nitrogen --restore";} +] diff --git a/nixos/home-manager/env/config/rofi/catppuccin-macchiato.rasi b/nixos/home-manager/env/config/rofi/catppuccin-macchiato.rasi new file mode 100644 index 00000000..696d7697 --- /dev/null +++ b/nixos/home-manager/env/config/rofi/catppuccin-macchiato.rasi @@ -0,0 +1,111 @@ +* { + bg-col: #24273a; + bg-col-light: #24273a; + border-col: #24273a; + selected-col: #24273a; + blue: #8aadf4; + fg-col: #cad3f5; + fg-col2: #ed8796; + grey: #6e738d; + + width: 600; + font: "JetBrainsMono Nerd Font 14"; +} + +element-text, element-icon , mode-switcher { + background-color: inherit; + text-color: inherit; +} + +window { + height: 360px; + border: 3px; + border-color: @border-col; + background-color: @bg-col; +} + +mainbox { + background-color: @bg-col; +} + +inputbar { + children: [prompt,entry]; + background-color: @bg-col; + border-radius: 5px; + padding: 2px; +} + +prompt { + background-color: @blue; + padding: 6px; + text-color: @bg-col; + border-radius: 3px; + margin: 20px 0px 0px 20px; +} + +textbox-prompt-colon { + expand: false; + str: ":"; +} + +entry { + padding: 6px; + margin: 20px 0px 0px 10px; + text-color: @fg-col; + background-color: @bg-col; +} + +listview { + border: 0px 0px 0px; + padding: 6px 0px 0px; + margin: 10px 0px 0px 20px; + columns: 2; + lines: 5; + background-color: @bg-col; +} + +element { + padding: 5px; + background-color: @bg-col; + text-color: @fg-col ; +} + +element-icon { + size: 25px; +} + +element selected { + background-color: @selected-col ; + text-color: @fg-col2 ; +} + +mode-switcher { + spacing: 0; + } + +button { + padding: 10px; + background-color: @bg-col-light; + text-color: @grey; + vertical-align: 0.5; + horizontal-align: 0.5; +} + +button selected { + background-color: @bg-col; + text-color: @blue; +} + +message { + background-color: @bg-col-light; + margin: 2px; + padding: 2px; + border-radius: 5px; +} + +textbox { + padding: 6px; + margin: 20px 0px 0px 20px; + text-color: @blue; + background-color: @bg-col-light; +} diff --git a/nixos/home-manager/env/default.nix b/nixos/home-manager/env/default.nix new file mode 100644 index 00000000..ff15d2d1 --- /dev/null +++ b/nixos/home-manager/env/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./i3.nix + ]; +} diff --git a/nixos/home-manager/env/dunst.nix b/nixos/home-manager/env/dunst.nix new file mode 100644 index 00000000..b4ee57cb --- /dev/null +++ b/nixos/home-manager/env/dunst.nix @@ -0,0 +1,66 @@ +{ ... }: +{ + services.dunst = { + enable = true; + settings = { + global = { + follow = "mouse"; + width = 300; + height = 300; + origin = "top-right"; + offset = "30x40"; + scale = 0; + notification_limit = 5; + progress_bar = true; + progress_bar_height = 10; + progress_bar_frame_width = 1; + progress_bar_min_width = 150; + progress_bar_max_width = 300; + indicate_hidden = "yes"; + transparency = 16; + separator_height = 2; + padding = 8; + horizontal_padding = 8; + text_icon_padding = 0; + frame_width = 1; + frame_color = "#8AADF4"; + separator_color = "frame"; + sort = "yes"; + idle_threshold = 0; + font = "Noto Sans Regular 9"; + line_height = 0; + markup = "full"; + format = "%s\n%b"; + alignment = "left"; + vertical_alignment = "centre"; + show_age_threshold = 60; + ellipsize = "end"; + ignore_newline = "no"; + stack_duplicates = true; + hide_duplicate_count = false; + show_indicators = true; + icon_position = "left"; + corner_radius = 7; + mouse_left_click = "close_current"; + mouse_middle_click = "do_action, close_current"; + mouse_right_click = "close_all"; + }; + urgency_low = { + background = "#24273A"; + foreground = "#CAD3F5"; + timeout = 5; + }; + urgency_normal = { + background = "#24273A"; + foreground = "#CAD3F5"; + timeout = 5; + }; + urgency_critical = { + background = "#24273A"; + foreground = "#CAD3F5"; + frame_color = "#F5A97F"; + timeout = 120; + }; + }; + }; +} diff --git a/nixos/home-manager/env/i3.nix b/nixos/home-manager/env/i3.nix new file mode 100644 index 00000000..79038e0a --- /dev/null +++ b/nixos/home-manager/env/i3.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: +let + mod = "Mod4"; +in +{ + imports = [ + ./dunst.nix + ./rofi.nix + ]; + home.packages = with pkgs; [ + xfce.thunar + scrot + dex + nitrogen + i3blocks + ]; + #xsession.windowManager.i3 = { + # enable = true; + # config = { + # modifier = mod; + # floating = { + # modifier = mod; + # }; + # fonts = { + # names = ["Noto Sans Regular" "DejaVu Sans Mono"]; + # style = "Regular"; + # size = 12.0; + # }; + # gaps = { + # inner = 6; + # outer = 3; + # }; + # keybindings = import ./config/i3/keybindings.nix; + # startup = import ./config/i3/startup.nix; + # }; + #}; +} diff --git a/nixos/home-manager/env/rofi.nix b/nixos/home-manager/env/rofi.nix new file mode 100644 index 00000000..2b65507b --- /dev/null +++ b/nixos/home-manager/env/rofi.nix @@ -0,0 +1,9 @@ +{ ... }: +{ + programs.rofi = { + enable = true; + location = "right"; + pass.enable = true; + #theme = "$HOME/.dotfiles/nixos/home-manager/env/config/rofi/catppuccin-macchiato.rasi"; + }; +} From b83d57f8fadd3a6f1384823f4e84f2f54e6f9c5f Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Tue, 4 Apr 2023 08:26:27 +0100 Subject: [PATCH 14/16] Fix i3 startup commands --- nixos/home-manager/env/config/i3/startup.nix | 5 --- nixos/home-manager/env/i3.nix | 43 +++++++++++--------- 2 files changed, 23 insertions(+), 25 deletions(-) delete mode 100644 nixos/home-manager/env/config/i3/startup.nix diff --git a/nixos/home-manager/env/config/i3/startup.nix b/nixos/home-manager/env/config/i3/startup.nix deleted file mode 100644 index fb6362ba..00000000 --- a/nixos/home-manager/env/config/i3/startup.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: -[ - { command = "$HOME/.screenlayout/default.sh";} - { command = "nitrogen --restore";} -] diff --git a/nixos/home-manager/env/i3.nix b/nixos/home-manager/env/i3.nix index 79038e0a..ebc951eb 100644 --- a/nixos/home-manager/env/i3.nix +++ b/nixos/home-manager/env/i3.nix @@ -14,24 +14,27 @@ in nitrogen i3blocks ]; - #xsession.windowManager.i3 = { - # enable = true; - # config = { - # modifier = mod; - # floating = { - # modifier = mod; - # }; - # fonts = { - # names = ["Noto Sans Regular" "DejaVu Sans Mono"]; - # style = "Regular"; - # size = 12.0; - # }; - # gaps = { - # inner = 6; - # outer = 3; - # }; - # keybindings = import ./config/i3/keybindings.nix; - # startup = import ./config/i3/startup.nix; - # }; - #}; + xsession.windowManager.i3 = { + enable = true; + config = { + modifier = mod; + floating = { + modifier = mod; + }; + fonts = { + names = [ "Noto Sans Regular" "DejaVu Sans Mono" ]; + style = "Regular"; + size = 12.0; + }; + gaps = { + inner = 6; + outer = 3; + }; + keybindings = import ./config/i3/keybindings.nix; + startup = [ + { command = "$HOME/.screenlayout/default.sh"; } + { command = "nitrogen --restore"; } + ]; + }; + }; } From 49643683d44a9767bea85cd39a1245d7002cd7dd Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Tue, 4 Apr 2023 09:28:27 +0100 Subject: [PATCH 15/16] Remove nvim-mason, using nix to manager LSP installs instead --- config/nvim/lua/config/mason.lua | 13 -------- config/nvim/lua/config/mason_lspconfig.lua | 3 -- config/nvim/lua/config/mason_null_ls.lua | 4 --- config/nvim/lua/config/mason_nvim_dap.lua | 4 --- config/nvim/lua/lsp/cmp.lua | 6 ++++ config/nvim/lua/lsp/config.lua | 24 ++++++-------- config/nvim/lua/lsp/null_ls_sources.lua | 1 + config/nvim/lua/plugins/mason.lua | 33 ------------------- nixos/desktop/picom.nix | 11 +------ nixos/home-manager/packages/tui/default.nix | 2 ++ nixos/home-manager/packages/tui/neovim.nix | 36 ++++++++++++++------- 11 files changed, 44 insertions(+), 93 deletions(-) delete mode 100644 config/nvim/lua/config/mason.lua delete mode 100644 config/nvim/lua/config/mason_lspconfig.lua delete mode 100644 config/nvim/lua/config/mason_null_ls.lua delete mode 100644 config/nvim/lua/config/mason_nvim_dap.lua delete mode 100644 config/nvim/lua/plugins/mason.lua diff --git a/config/nvim/lua/config/mason.lua b/config/nvim/lua/config/mason.lua deleted file mode 100644 index 7707a8d7..00000000 --- a/config/nvim/lua/config/mason.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - pip = { - upgrade_pip = true, - }, - ui = { - border = "single", - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗", - }, - }, -} diff --git a/config/nvim/lua/config/mason_lspconfig.lua b/config/nvim/lua/config/mason_lspconfig.lua deleted file mode 100644 index e942fd62..00000000 --- a/config/nvim/lua/config/mason_lspconfig.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - automatic_installation = false, -} diff --git a/config/nvim/lua/config/mason_null_ls.lua b/config/nvim/lua/config/mason_null_ls.lua deleted file mode 100644 index 269f1b49..00000000 --- a/config/nvim/lua/config/mason_null_ls.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - automatic_installation = false, - automatic_setup = true, -} diff --git a/config/nvim/lua/config/mason_nvim_dap.lua b/config/nvim/lua/config/mason_nvim_dap.lua deleted file mode 100644 index 269f1b49..00000000 --- a/config/nvim/lua/config/mason_nvim_dap.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - automatic_installation = false, - automatic_setup = true, -} diff --git a/config/nvim/lua/lsp/cmp.lua b/config/nvim/lua/lsp/cmp.lua index aa6a3fda..97f34750 100644 --- a/config/nvim/lua/lsp/cmp.lua +++ b/config/nvim/lua/lsp/cmp.lua @@ -50,6 +50,12 @@ cmp.setup.filetype("python", { }, }) +cmp.setup.filetype("nix", { + sources = { + { name = "nvim_lsp" }, + }, +}) + cmp.setup.filetype("gitcommit", { sources = { { name = "nvim_lsp" }, diff --git a/config/nvim/lua/lsp/config.lua b/config/nvim/lua/lsp/config.lua index 0d4f8777..c4a43192 100644 --- a/config/nvim/lua/lsp/config.lua +++ b/config/nvim/lua/lsp/config.lua @@ -14,32 +14,26 @@ for type, icon in pairs(signs) do vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end -require("mason").setup() -require("mason-lspconfig").setup(require "config.mason_lspconfig") -require("mason-null-ls").setup(require "config.mason_null_ls") -require("mason-nvim-dap").setup() require("neodev").setup() M.on_attach = require "lsp.attach" M.lsp_flags = require "lsp.flags" M.capabilities = require("cmp_nvim_lsp").default_capabilities() -require("mason-lspconfig").setup_handlers { - function(server_name) - require("lspconfig")[server_name].setup { - on_attach = M.on_attach, - flags = M.lsp_flags, - capabilities = M.capabilities, - } - end, -} +local servers = { "jedi_language_server", "lua_ls", "rnix", "nil_ls", "fortls" } +for _, name in ipairs(servers) do + require("lspconfig")[name].setup { + on_attach = M.on_attach, + flags = M.lsp_flags, + capabilities = M.capabilities, + } +end + require("null-ls").setup { sources = require "lsp.null_ls_sources", on_attach = M.on_attach, flags = M.lsp_flags, capabilities = M.capabilities, } -require("mason-null-ls").setup_handlers() -require("mason-nvim-dap").setup_handlers() return M diff --git a/config/nvim/lua/lsp/null_ls_sources.lua b/config/nvim/lua/lsp/null_ls_sources.lua index d24376c6..2387d356 100644 --- a/config/nvim/lua/lsp/null_ls_sources.lua +++ b/config/nvim/lua/lsp/null_ls_sources.lua @@ -3,6 +3,7 @@ return { null_ls.builtins.code_actions.gitsigns, null_ls.builtins.diagnostics.zsh, null_ls.builtins.diagnostics.mypy, + null_ls.builtins.diagnostics.ruff, null_ls.builtins.formatting.black, null_ls.builtins.formatting.isort, null_ls.builtins.formatting.trim_whitespace, diff --git a/config/nvim/lua/plugins/mason.lua b/config/nvim/lua/plugins/mason.lua deleted file mode 100644 index 568f9530..00000000 --- a/config/nvim/lua/plugins/mason.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - { - "williamboman/mason.nvim", - cmd = { - "Mason", - }, - config = function() require("mason").setup(require "config.mason") end, - }, - { - "williamboman/mason-lspconfig.nvim", - dependencies = { - "williamboman/mason.nvim", - "neovim/nvim-lspconfig", - }, - lazy = true, - }, - { - "jay-babu/mason-null-ls.nvim", - dependencies = { - "jose-elias-alvarez/null-ls.nvim", - "neovim/nvim-lspconfig", - }, - lazy = true, - }, - { - "jay-babu/mason-nvim-dap.nvim", - dependencies = { - "mfussenegger/nvim-dap", - "neovim/nvim-lspconfig", - }, - lazy = true, - }, -} diff --git a/nixos/desktop/picom.nix b/nixos/desktop/picom.nix index bc9092a8..8aa1506e 100644 --- a/nixos/desktop/picom.nix +++ b/nixos/desktop/picom.nix @@ -8,15 +8,6 @@ shadow = true; fade = true; activeOpacity = 1.0; - inactiveOpacity = 0.8; - settings = { - blur = - { - method = "dual_kawase"; - size = 10; - deviation = 5.0; - strength = 7; - }; - }; + inactiveOpacity = 1.0; }; } diff --git a/nixos/home-manager/packages/tui/default.nix b/nixos/home-manager/packages/tui/default.nix index 11c586d4..8834a548 100644 --- a/nixos/home-manager/packages/tui/default.nix +++ b/nixos/home-manager/packages/tui/default.nix @@ -8,5 +8,7 @@ programs.neovim.defaultEditor = true; home.packages = with pkgs; [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) + file + silver-searcher ]; } diff --git a/nixos/home-manager/packages/tui/neovim.nix b/nixos/home-manager/packages/tui/neovim.nix index 8a340c8b..d453cb39 100644 --- a/nixos/home-manager/packages/tui/neovim.nix +++ b/nixos/home-manager/packages/tui/neovim.nix @@ -3,21 +3,35 @@ { programs.neovim = { enable = true; + defaultEditor = true; viAlias = true; vimAlias = true; vimdiffAlias = true; withNodeJs = true; + withRuby = true; withPython3 = true; + extraPackages = with pkgs; [ + # Used by installed plugins + gnumake + gcc + fzf + ripgrep + # LSP config + # Python + mypy + black + isort + ruff + # Nix + rnix-lsp + nil + # Lua + sumneko-lua-language-server + # Fortran + fortran-language-server + ]; + extraPython3Packages = ps: with ps; [ + jedi + ]; }; - home.packages = with pkgs; [ - gnumake - gcc - python310Packages.mypy - python310Packages.black - python310Packages.isort - fzf - ripgrep - cargo - rustc - ]; } From df08ddf5bf1c2ca1cca592189ab60e679e2bfdf9 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Tue, 4 Apr 2023 09:48:40 +0100 Subject: [PATCH 16/16] Add separate python venv template --- templates/python.nix | 3 --- templates/venv.nix | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 templates/venv.nix diff --git a/templates/python.nix b/templates/python.nix index dfe1bb76..5053d2f5 100644 --- a/templates/python.nix +++ b/templates/python.nix @@ -17,8 +17,5 @@ pkgs.mkShell { shellHook = '' export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib" - python -m venv .venv - source .venv/bin/activate - pip list --outdated | grep -iE "^(pip|wheel)" > /dev/null && python -m pip install --upgrade pip wheel ''; } diff --git a/templates/venv.nix b/templates/venv.nix new file mode 100644 index 00000000..dfe1bb76 --- /dev/null +++ b/templates/venv.nix @@ -0,0 +1,24 @@ +{ pkgs ? import {}, python ? pkgs.python39, ... }: + +let + python-packages = ps: with ps; [ + pip + setuptools + wheel + ]; +in +pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + (python.withPackages python-packages) + git + zlib + libgccjit + ]; + + shellHook = '' + export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib" + python -m venv .venv + source .venv/bin/activate + pip list --outdated | grep -iE "^(pip|wheel)" > /dev/null && python -m pip install --upgrade pip wheel + ''; +}