feat: add app icon and bundle it on linux

This commit is contained in:
uku 2025-05-22 12:18:56 +02:00
parent 2f228a7e9c
commit 38a7f97cad
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
6 changed files with 59 additions and 8 deletions

View file

@ -1,8 +1,11 @@
{
lib,
craneLib,
copyDesktopItems,
ffmpeg,
imagemagick,
libadwaita,
makeDesktopItem,
mold-wrapped,
pkg-config,
wrapGAppsHook4,
@ -10,14 +13,27 @@
}:
let
cargoToml = lib.importTOML ./Cargo.toml;
resFilter = path: type: baseNameOf (dirOf path) == "res";
in
craneLib.buildPackage {
pname = cargoToml.package.name;
inherit (cargoToml.package) version;
src = craneLib.cleanCargoSource ./.;
src = lib.cleanSourceWith {
src = ./.;
name = "source";
filter =
path: type:
lib.any (f: f path type) [
resFilter
craneLib.filterCargoSources
];
};
nativeBuildInputs = [
copyDesktopItems
imagemagick
mold-wrapped
pkg-config
wrapGAppsHook4
@ -29,6 +45,27 @@ craneLib.buildPackage {
doCheck = false;
postInstall =
let
resolutions = [
"16"
"32"
"48"
"128"
"256"
];
in
map (
size:
let
dir = "$out/share/icons/hicolor/${size}x${size}/apps";
in
''
mkdir -p ${dir}
magick res/tyrolienne.png -resize ${size}x ${dir}/net.uku3lig.tyrolienne.png
''
) resolutions;
preFixup = ''
gappsWrapperArgs+=(
--prefix PATH : ${
@ -40,11 +77,23 @@ craneLib.buildPackage {
)
'';
meta = with lib; {
mainProgram = cargoToml.package.name;
desktopItems = [
(makeDesktopItem {
name = "net.uku3lig.tyrolienne";
desktopName = "Tyrolienne";
type = "Application";
comment = "Compresses and uploads videos to Zipline";
exec = "tyrolienne";
icon = "net.uku3lig.tyrolienne";
terminal = false;
})
];
meta = {
description = "simple tool to convert, upload, and embed videos to zipline";
homepage = "https://git.uku3lig.net/uku/tyrolienne";
license = licenses.mpl20;
platforms = platforms.unix;
license = lib.licenses.mpl20;
platforms = lib.platforms.linux ++ lib.platforms.darwin;
mainProgram = "tyrolienne";
};
}

BIN
res/tyrolienne.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
res/tyrolienne.xcf Normal file

Binary file not shown.

View file

@ -391,11 +391,11 @@ impl AsyncComponent for Tyrolienne {
}
}
// TODO app icon
// TODO app icon (windows)
fn main() {
match ffmpeg::check().and_then(|_| get_config()) {
Ok(config) => RelmApp::new("net.uku3lig.Tyrolienne").run_async::<Tyrolienne>(config),
Err(e) => RelmApp::new("net.uku3lig.Tyrolienne").run::<StandaloneDialog>(e.to_string()),
Ok(config) => RelmApp::new("net.uku3lig.tyrolienne").run_async::<Tyrolienne>(config),
Err(e) => RelmApp::new("net.uku3lig.tyrolienne").run::<StandaloneDialog>(e.to_string()),
}
}

View file

@ -150,6 +150,7 @@ impl SimpleComponent for Toast {
pub struct StandaloneDialog;
// TODO: don't open a window, just give a HeaderBar to the dialog
impl SimpleComponent for StandaloneDialog {
type Init = String;
type Input = ();

View file

@ -80,6 +80,7 @@ async fn wrap_file(path: &Path, sender: Sender<ProgressMessage>) -> Result<Part>
})
}
// TODO: make a ZiplineError type
pub async fn get_folders(config: &Config) -> Result<Vec<ZiplineFolder>> {
let url = format!("{}api/user/folders?noincl=true", config.fixed_url());