Add swayimg

This commit is contained in:
Nathan McCarty 2022-09-18 20:25:20 -04:00
parent bf56969ab6
commit 25a654cec4
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
4 changed files with 108 additions and 3 deletions

View File

@ -35,8 +35,6 @@ with lib;
}) })
(mkIf config.nathan.programs.util.productivity { (mkIf config.nathan.programs.util.productivity {
home.packages = with pkgs; [ home.packages = with pkgs; [
# Feh image viewer
feh
tokei tokei
# Spell check # Spell check
hunspell hunspell

View File

@ -73,5 +73,12 @@ with lib; with nLib; {
package = pkgs.firefox-beta-bin; package = pkgs.firefox-beta-bin;
}; };
nathan.programs.emacs.package = lib.mkDefault inputs.emacs.packages."${pkgs.system}".emacsPgtkNativeComp; nathan.programs.emacs.package = lib.mkDefault inputs.emacs.packages."${pkgs.system}".emacsPgtkNativeComp;
# We should be managing xdg stuff
xdg = {
enable = true;
# Manage mime associations
mime.enable = true;
mimeApps.enable = true;
};
}; };
} }

View File

@ -7,6 +7,7 @@ with lib;
config = mkIf nathan.programs.swaywm.enable ( config = mkIf nathan.programs.swaywm.enable (
let let
swaylock-command = "${pkgs.swaylock-effects}/bin/swaylock --screenshots --grace 30 --indicator --clock --timestr \"%-I:%M:%S %p\" --datestr \"%A %Y-%M-%d\" --effect-blur 20x3"; swaylock-command = "${pkgs.swaylock-effects}/bin/swaylock --screenshots --grace 30 --indicator --clock --timestr \"%-I:%M:%S %p\" --datestr \"%A %Y-%M-%d\" --effect-blur 20x3";
swayimg = pkgs.callPackage ../../../packages/swayimg/default.nix { };
in in
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
@ -36,6 +37,8 @@ with lib;
sway-contrib.grimshot sway-contrib.grimshot
# fuzzel for launcher # fuzzel for launcher
fuzzel fuzzel
# for image viewing
swayimg
]; ];
######################### #########################
## Sway ## Sway
@ -63,17 +66,25 @@ with lib;
border = 2; border = 2;
# Application specific configuration # Application specific configuration
commands = [ commands = [
# Make pinentry float
{ {
command = "floating enable"; command = "floating enable";
criteria = { criteria = {
app_id = "pinentry-qt"; app_id = "pinentry-qt";
}; };
} }
# Make swayimg float, this is required to make it work
{
command = "floating enable";
criteria = {
app_id = "^swayimg.*";
};
}
# Work around for chrome ui bug # Work around for chrome ui bug
{ {
command = "shortcuts_inhibitor disable"; command = "shortcuts_inhibitor disable";
criteria = { criteria = {
app_id = "^chrome-.*__-.*$"; app_id = "^chrome-.*_-.*$";
}; };
} }
]; ];
@ -595,6 +606,20 @@ with lib;
After = [ "waybar.service" ]; After = [ "waybar.service" ];
}; };
}; };
#########################
## Default applications
#########################
xdg.mimeApps.defaultApplications = {
# Make all supported images open in swayimg
"image/jpeg" = [ "swayimg.desktop" ];
"image/png" = [ "swayimg.desktop" ];
"image/gif" = [ "swayimg.desktop" ];
"image/svg+xml" = [ "swayimg.desktop" ];
"image/webp" = [ "swayimg.desktop" ];
"image/avif" = [ "swayimg.desktop" ];
"image/tiff" = [ "swayimg.desktop" ];
"image/bmp" = [ "swayimg.desktop" ];
};
} }
); );
} }

View File

@ -0,0 +1,75 @@
{ config
, lib
, pkgs
, stdenv
, fetchurl
, meson
, ninja
, pkg-config
, git
, cmake
, makeDesktopItem
, wayland
, wayland-protocols
, json_c
, libxkbcommon
, fontconfig
, giflib
, libjpeg
, libjxl
, libpng
, librsvg
, libwebp
, libheif
, libtiff
, libexif
, bash-completion
, ...
}:
stdenv.mkDerivation rec {
pname = "swayimg";
version = "1.9";
src = fetchurl {
url = "https://github.com/artemsen/swayimg/archive/refs/tags/v${version}.tar.gz";
sha256 = "sha256-aTojp3VevtsUQnGytnSYChxRogNtq8/5aXw+PGJY8Qg=";
name = "${pname}-${version}.tar.gz";
};
nativeBuildInputs = [ meson ninja pkg-config git cmake ];
buildInputs = [
wayland
wayland-protocols
json_c
libxkbcommon
fontconfig
giflib
libjpeg
libjxl
libpng
librsvg
libwebp
libheif
libtiff
libexif
bash-completion
];
desktopItem = makeDesktopItem {
name = "swayimg-open";
desktopName = "swayimg";
exec = "swayimg %u";
terminal = false;
mimeTypes = [
"image/jpeg"
"image/png"
"image/gif"
"image/svg+xml"
"image/webp"
"image/avif"
"image/tiff"
"image/bmp"
];
};
}