Skip to content

Commit

Permalink
fix vim (#63)
Browse files Browse the repository at this point in the history
* fix vim

* added changes to bg
  • Loading branch information
Mast3rwaf1z authored Feb 25, 2025
1 parent 26486e8 commit 44a35a5
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 29 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
lavalink = pkgs.callPackage ./packages/lavalink {};
p8 = pkgs.callPackage ./packages/p8 {};
systems = builtins.mapAttrs (key: value: value.config.system.build.vm) self.nixosConfigurations;
test-background = pkgs.callPackage ./systems/laptop/home/sway/background { inherit pkgs; background = ./files/wallpaper.png; };
test-background = pkgs.callPackage ./systems/laptop/home/sway/background { inherit pkgs; };
};
};
}
1 change: 1 addition & 0 deletions shared/programs/neovim/plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ in {
plugins.lsp = {
enable = true;
inlayHints = true;
autoLoad = true;
servers.pyright = autoEnable' {};
servers.nixd = autoEnable' {};
servers.hls = autoEnable' {
Expand Down
8 changes: 0 additions & 8 deletions shared/programs/vim.nix

This file was deleted.

1 change: 0 additions & 1 deletion systems/laptop/home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
packages = with pkgs; [
dconf
nixos-icons
(pkgs.writeScriptBin "vim" "nvim")
];
};

Expand Down
26 changes: 23 additions & 3 deletions systems/laptop/home/sway/background/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
{pkgs, background}: let
{pkgs}: let
env = pkgs.python312.withPackages (py: with py; [
pillow
cairosvg
]);
background = pkgs.fetchurl {
url = "https://img.goodfon.com/original/3840x2160/c/8d/anime-mech-fate.jpg";
hash = "sha256-my/d2+nKKj+XCtgS5hC2mKFb7yIvVNg9P1IelPl9lRY=";
};
images = [
"${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bootloader}/share/backgrounds/nixos/nix-wallpaper-simple-dark-gray_bootloader.png"
"${pkgs.fetchFromGitHub {
owner = "WillPower3309";
repo = "swayfx";
rev = "master";
sha256 = "sha256-+yHlfDX0fLXe5LFAwiK/Avtf0vVtqhYfjq7fWcoGIX4=";
}}/assets/swayfx_logo.svg"
"${pkgs.fetchFromGitHub {
owner = "f-klubben";
repo = "logo";
rev = "master";
sha256 = "sha256-ep6/vzk7dj5InsVmaU/x2W1Lsxd4jvvwsyJzLgQJDEE=";
}}/logo.svg"
];
in pkgs.stdenv.mkDerivation {
name = "wallpaper.png";
pname = "wallpaper.png";
src = ./.;
src = ./.;
installPhase = ''
${env.interpreter} $src/overlay.py ${background} ${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bootloader}/share/backgrounds/nixos/nix-wallpaper-simple-dark-gray_bootloader.png $out
${env.interpreter} $src/overlay.py ${background} ${builtins.concatStringsSep " " images} $out
'';
}
50 changes: 40 additions & 10 deletions systems/laptop/home/sway/background/overlay.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,59 @@
import sys
from PIL import Image, ImageOps
from cairosvg import svg2png

def convert(data, source, target):
return [target if item == source else item for item in data]


background = sys.argv[1]
os_art = sys.argv[2]
destination = sys.argv[3]
def autocrop_image(image, border = 0):
# Get the bounding box
bbox = image.getbbox()

print(os_art)
# Crop the image to the contents of the bounding box
image = image.crop(bbox)

os_art_img = Image.open(os_art)
# Determine the width and height of the cropped image
(width, height) = image.size

os_art_rgba = os_art_img.convert("RGBA")
os_art_data = os_art_rgba.getdata()
# Add border
width += border * 2
height += border * 2

# Create a new image object for the output image
cropped_image = Image.new("RGBA", (width, height), (0,0,0,0))

os_art_transparent = convert(os_art_data, (47,48,47,255), (0,0,0,0))
# Paste the cropped image onto the new image
cropped_image.paste(image, (border, border))

os_art_rgba.putdata(os_art_transparent)
# Done!
return cropped_image

def fixup_image(image:str) -> Image.Image:
if image.split(".")[-1] == "svg":
with open(image, "r") as file:
svg2png(bytestring=file.read(), write_to="out.png")
image = "out.png"
img = Image.open(image)
rgba = img.convert("RGBA")
data = rgba.getdata()
transparent = convert(data, (47,48,47,255), (0,0,0,0))
rgba.putdata(transparent)
cropped = autocrop_image(rgba)
return ImageOps.contain(cropped, (150, 150))


x, y = (1920/4.5, 1080/3.3)

_, background, *images, destination = sys.argv

fixed_images = map(fixup_image, images)

background_img = Image.open(background)
background_img_rgba = background_img.convert("RGBA")
background_img_resized = background_img_rgba.resize((1920, 1080))

background_img_resized.paste(os_art_rgba, (int(1920/4.5), int(1080/4.5)), os_art_rgba)
for i, image in enumerate(fixed_images):
background_img_resized.paste(image, (int(x + (124 * i)), int(y)), image)

background_img_resized.save(destination, "PNG")
6 changes: 1 addition & 5 deletions systems/laptop/home/sway/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{pkgs, lib, config, ...}: let
image = pkgs.fetchurl {
url = "https://img.goodfon.com/original/3840x2160/c/8d/anime-mech-fate.jpg";
hash = "sha256-my/d2+nKKj+XCtgS5hC2mKFb7yIvVNg9P1IelPl9lRY=";
};
background = import ./background { inherit pkgs; background = image; };
background = import ./background { inherit pkgs; };
in {
wayland.windowManager.sway = {
enable = true;
Expand Down
2 changes: 1 addition & 1 deletion systems/skademaskinen/modules/nextcloud.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
};
config.services.nextcloud = {
enable = true;
package = pkgs.nextcloud29;
package = pkgs.nextcloud30;
home = "${config.skademaskinen.storage}/nextcloud";
hostName = "cloud.${config.skademaskinen.domain}";
https = !(config.skademaskinen.test);
Expand Down

0 comments on commit 44a35a5

Please sign in to comment.