diff --git a/app_grid/src/main.rs b/app_grid/src/main.rs index ca74326..ef6551d 100644 --- a/app_grid/src/main.rs +++ b/app_grid/src/main.rs @@ -34,7 +34,7 @@ async fn main() -> Result<()> { .pretty() .init(); let (client, event_loop) = Client::connect_with_async_loop().await?; - client.set_base_prefixes(&[directory_relative_path!("res")]); + client.set_base_prefixes(&[directory_relative_path!("../res")]); let _root = client.wrap_root(AppGrid::new(&client))?; diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3fc6377 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712681629, + "narHash": "sha256-bMDXn4AkTXLCpoZbII6pDGoSeSe9gI87jxPsHRXgu/E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "220387ac8e99cbee0ca4c95b621c4bc782b6a235", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1712791164, + "narHash": "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1042fd8b148a9105f3c0aca3a6177fd1d9360ba5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d2629c7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + crane = { + inputs.nixpkgs.follows = "nixpkgs"; + url = "github:ipetkov/crane"; + }; + }; + + + outputs = { self, nixpkgs, crane }: + let supportedSystems = [ "aarch64-linux" "x86_64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in { + packages = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { + default = crane.lib.${system}.buildPackage { + pname = "protostar"; + version = "0.1.0"; + src = ./.; + + cargoTestCommand = "echo \"looks good to me\""; + + STARDUST_RES_PREFIXES = pkgs.stdenvNoCC.mkDerivation { + name = "resources"; + src = ./.; + + buildPhase = "cp -r $src/res $out"; + }; + + # for tests + nativeBuildInputs = with pkgs; [ + ashpd-demo + ]; + XDG_CACHE_HOME = "/tmp"; + }; + }); + }; +} diff --git a/hexagon_launcher/res/protostar/cartridge.glb b/hexagon_launcher/res/protostar/cartridge.glb deleted file mode 100644 index 507a60f..0000000 Binary files a/hexagon_launcher/res/protostar/cartridge.glb and /dev/null differ diff --git a/hexagon_launcher/res/protostar/default_icon.glb b/hexagon_launcher/res/protostar/default_icon.glb deleted file mode 100755 index 7f2b2b2..0000000 Binary files a/hexagon_launcher/res/protostar/default_icon.glb and /dev/null differ diff --git a/hexagon_launcher/res/protostar/hexagon/hex_atlas.png b/hexagon_launcher/res/protostar/hexagon/hex_atlas.png deleted file mode 100644 index 03e4f18..0000000 Binary files a/hexagon_launcher/res/protostar/hexagon/hex_atlas.png and /dev/null differ diff --git a/hexagon_launcher/res/protostar/hexagon/hexagon.bin b/hexagon_launcher/res/protostar/hexagon/hexagon.bin deleted file mode 100644 index b40c29c..0000000 Binary files a/hexagon_launcher/res/protostar/hexagon/hexagon.bin and /dev/null differ diff --git a/hexagon_launcher/res/protostar/hexagon/hexagon.gltf b/hexagon_launcher/res/protostar/hexagon/hexagon.gltf deleted file mode 100644 index 21049a7..0000000 --- a/hexagon_launcher/res/protostar/hexagon/hexagon.gltf +++ /dev/null @@ -1,286 +0,0 @@ -{ - "asset":{ - "generator":"Khronos glTF Blender I/O v3.6.6", - "version":"2.0" - }, - "extensionsUsed":[ - "KHR_materials_unlit" - ], - "scene":0, - "scenes":[ - { - "name":"Scene", - "nodes":[ - 0, - 1 - ] - } - ], - "nodes":[ - { - "mesh":0, - "name":"Icon" - }, - { - "mesh":1, - "name":"Hex" - } - ], - "materials":[ - { - "alphaCutoff":0.5, - "alphaMode":"MASK", - "extensions":{ - "KHR_materials_unlit":{} - }, - "name":"Icon", - "pbrMetallicRoughness":{ - "baseColorTexture":{ - "index":0, - "texCoord":0 - }, - "metallicFactor":0, - "roughnessFactor":0.9 - } - }, - { - "alphaMode":"BLEND", - "extensions":{ - "KHR_materials_unlit":{} - }, - "name":"Hex", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.9720873236656189, - 0.018567396327853203, - 0.017742767930030823, - 1 - ], - "baseColorTexture":{ - "index":1, - "texCoord":0 - }, - "metallicFactor":0, - "roughnessFactor":0.9 - } - } - ], - "meshes":[ - { - "name":"Circle", - "primitives":[ - { - "attributes":{ - "COLOR_0":0, - "POSITION":1, - "TEXCOORD_0":2, - "NORMAL":3 - }, - "indices":4, - "material":0 - } - ] - }, - { - "name":"Circle.001", - "primitives":[ - { - "attributes":{ - "COLOR_0":5, - "POSITION":6, - "TEXCOORD_0":7, - "NORMAL":8 - }, - "indices":9, - "material":1 - } - ] - } - ], - "textures":[ - { - "sampler":0, - "source":0 - }, - { - "sampler":1, - "source":1 - } - ], - "images":[ - { - "mimeType":"image/png", - "name":"icon_test", - "uri":"icon_test.png" - }, - { - "mimeType":"image/png", - "name":"hex_atlas", - "uri":"hex_atlas.png" - } - ], - "accessors":[ - { - "bufferView":0, - "componentType":5123, - "count":4, - "normalized":true, - "type":"VEC4" - }, - { - "bufferView":1, - "componentType":5126, - "count":4, - "max":[ - 0.5853440165519714, - 0.05000000074505806, - 0.5853440165519714 - ], - "min":[ - -0.5853440165519714, - 0.05000000074505806, - -0.5853440165519714 - ], - "type":"VEC3" - }, - { - "bufferView":2, - "componentType":5126, - "count":4, - "type":"VEC2" - }, - { - "bufferView":3, - "componentType":5126, - "count":4, - "type":"VEC3" - }, - { - "bufferView":4, - "componentType":5123, - "count":6, - "type":"SCALAR" - }, - { - "bufferView":5, - "componentType":5123, - "count":54, - "normalized":true, - "type":"VEC4" - }, - { - "bufferView":6, - "componentType":5126, - "count":54, - "max":[ - 1.0166369676589966, - 0.021040409803390503, - 0.8804334998130798 - ], - "min":[ - -1.0166369676589966, - -7.071532309055328e-06, - -0.8804334998130798 - ], - "type":"VEC3" - }, - { - "bufferView":7, - "componentType":5126, - "count":54, - "type":"VEC2" - }, - { - "bufferView":8, - "componentType":5126, - "count":54, - "type":"VEC3" - }, - { - "bufferView":9, - "componentType":5123, - "count":84, - "type":"SCALAR" - } - ], - "bufferViews":[ - { - "buffer":0, - "byteLength":32, - "byteOffset":0, - "target":34962 - }, - { - "buffer":0, - "byteLength":48, - "byteOffset":32, - "target":34962 - }, - { - "buffer":0, - "byteLength":32, - "byteOffset":80, - "target":34962 - }, - { - "buffer":0, - "byteLength":48, - "byteOffset":112, - "target":34962 - }, - { - "buffer":0, - "byteLength":12, - "byteOffset":160, - "target":34963 - }, - { - "buffer":0, - "byteLength":432, - "byteOffset":172, - "target":34962 - }, - { - "buffer":0, - "byteLength":648, - "byteOffset":604, - "target":34962 - }, - { - "buffer":0, - "byteLength":432, - "byteOffset":1252, - "target":34962 - }, - { - "buffer":0, - "byteLength":648, - "byteOffset":1684, - "target":34962 - }, - { - "buffer":0, - "byteLength":168, - "byteOffset":2332, - "target":34963 - } - ], - "samplers":[ - { - "magFilter":9729, - "minFilter":9987, - "wrapS":33071, - "wrapT":33071 - }, - { - "magFilter":9729, - "minFilter":9987 - } - ], - "buffers":[ - { - "byteLength":2500, - "uri":"hexagon.bin" - } - ] -} diff --git a/hexagon_launcher/src/main.rs b/hexagon_launcher/src/main.rs index 146d3e0..e8d9de8 100644 --- a/hexagon_launcher/src/main.rs +++ b/hexagon_launcher/src/main.rs @@ -37,7 +37,7 @@ async fn main() -> Result<()> { .pretty() .init(); let (client, event_loop) = Client::connect_with_async_loop().await?; - client.set_base_prefixes(&[directory_relative_path!("res")]); + client.set_base_prefixes(&[directory_relative_path!("../res")]); let _root = client.wrap_root(AppHexGrid::new(&client).await)?; diff --git a/protostar/src/xdg.rs b/protostar/src/xdg.rs index 6b3a66a..08f4f96 100644 --- a/protostar/src/xdg.rs +++ b/protostar/src/xdg.rs @@ -94,9 +94,10 @@ pub fn get_desktop_files() -> impl Iterator { #[test] fn test_get_desktop_files() { - let mut desktop_files = get_desktop_files(); - assert!(desktop_files.any(|file| file.ends_with("gimp.desktop"))); - dbg!(desktop_files.collect::>()); + let desktop_files = get_desktop_files().collect::>(); + assert!(desktop_files + .iter() + .any(|file| file.ends_with("com.belmoussaoui.ashpd.demo.desktop"))); } pub fn parse_desktop_file(path: PathBuf) -> Result { @@ -213,7 +214,9 @@ const ICON_SIZES: [u16; 7] = [512, 256, 128, 64, 48, 32, 24]; impl DesktopFile { pub fn get_icon(&self, preferred_px_size: u16) -> Option { // Get the name of the icon from the DesktopFile struct - let Some(icon_name) = self.icon.as_ref() else { return None }; + let Some(icon_name) = self.icon.as_ref() else { + return None; + }; let test_icon_path = self.path.join(Path::new(icon_name)); if test_icon_path.exists() { if let Some(icon) = Icon::from_path(test_icon_path, preferred_px_size) { @@ -331,23 +334,15 @@ fn test_get_icon_path() { name: None, command: None, categories: vec![], - icon: Some("krita".into()), + icon: Some("com.belmoussaoui.ashpd.demo".into()), no_display: false, }; // Call the get_icon_path() function with a size argument and store the result let icon = desktop_file.get_icon(32); - dbg!(&icon); // Assert that the get_icon_path() function returns the expected result - assert!( - icon.unwrap() - == Icon::from_path( - PathBuf::from("/usr/share/icons/hicolor/32x32/apps/krita.png"), - 32 - ) - .unwrap() - ); + assert!(icon.is_some()); } pub fn get_image_cache_dir() -> PathBuf { diff --git a/hexagon_launcher/res/protostar/button.glb b/res/protostar/button.glb similarity index 100% rename from hexagon_launcher/res/protostar/button.glb rename to res/protostar/button.glb diff --git a/app_grid/res/protostar/cartridge.glb b/res/protostar/cartridge.glb similarity index 100% rename from app_grid/res/protostar/cartridge.glb rename to res/protostar/cartridge.glb diff --git a/app_grid/res/protostar/default_icon.glb b/res/protostar/default_icon.glb similarity index 100% rename from app_grid/res/protostar/default_icon.glb rename to res/protostar/default_icon.glb diff --git a/single/res/protostar/hexagon/hex_atlas.png b/res/protostar/hexagon/hex_atlas.png similarity index 100% rename from single/res/protostar/hexagon/hex_atlas.png rename to res/protostar/hexagon/hex_atlas.png diff --git a/single/res/protostar/hexagon/hexagon.bin b/res/protostar/hexagon/hexagon.bin similarity index 100% rename from single/res/protostar/hexagon/hexagon.bin rename to res/protostar/hexagon/hexagon.bin diff --git a/single/res/protostar/hexagon/hexagon.gltf b/res/protostar/hexagon/hexagon.gltf similarity index 100% rename from single/res/protostar/hexagon/hexagon.gltf rename to res/protostar/hexagon/hexagon.gltf diff --git a/hexagon_launcher/res/protostar/hexagon/icon_test.png b/res/protostar/hexagon/icon_test.png similarity index 100% rename from hexagon_launcher/res/protostar/hexagon/icon_test.png rename to res/protostar/hexagon/icon_test.png diff --git a/single/res/protostar/default_icon.glb b/single/res/protostar/default_icon.glb deleted file mode 100755 index 7f2b2b2..0000000 Binary files a/single/res/protostar/default_icon.glb and /dev/null differ diff --git a/single/res/protostar/hexagon/icon_test.png b/single/res/protostar/hexagon/icon_test.png deleted file mode 100644 index 68f4809..0000000 Binary files a/single/res/protostar/hexagon/icon_test.png and /dev/null differ diff --git a/single/src/main.rs b/single/src/main.rs index 014afdc..3ff6755 100644 --- a/single/src/main.rs +++ b/single/src/main.rs @@ -26,7 +26,7 @@ async fn main() -> Result<()> { color_eyre::install()?; let args = Args::parse(); let (client, event_loop) = Client::connect_with_async_loop().await?; - client.set_base_prefixes(&[directory_relative_path!("res")]); + client.set_base_prefixes(&[directory_relative_path!("../res")]); let protostar = Single::create_from_desktop_file( client.get_root(), diff --git a/sirius/res/protostar/button.glb b/sirius/res/protostar/button.glb deleted file mode 100644 index ed080ba..0000000 Binary files a/sirius/res/protostar/button.glb and /dev/null differ diff --git a/sirius/res/protostar/default_icon.glb b/sirius/res/protostar/default_icon.glb deleted file mode 100755 index 7f2b2b2..0000000 Binary files a/sirius/res/protostar/default_icon.glb and /dev/null differ diff --git a/sirius/res/protostar/hexagon/hex_atlas.png b/sirius/res/protostar/hexagon/hex_atlas.png deleted file mode 100644 index 5376c46..0000000 Binary files a/sirius/res/protostar/hexagon/hex_atlas.png and /dev/null differ diff --git a/sirius/res/protostar/hexagon/hexagon.bin b/sirius/res/protostar/hexagon/hexagon.bin deleted file mode 100644 index f56fec4..0000000 Binary files a/sirius/res/protostar/hexagon/hexagon.bin and /dev/null differ diff --git a/sirius/res/protostar/hexagon/hexagon.gltf b/sirius/res/protostar/hexagon/hexagon.gltf deleted file mode 100644 index f0480e3..0000000 --- a/sirius/res/protostar/hexagon/hexagon.gltf +++ /dev/null @@ -1,286 +0,0 @@ -{ - "asset":{ - "generator":"Khronos glTF Blender I/O v3.5.30", - "version":"2.0" - }, - "extensionsUsed":[ - "KHR_materials_unlit" - ], - "scene":0, - "scenes":[ - { - "name":"Scene", - "nodes":[ - 0, - 1 - ] - } - ], - "nodes":[ - { - "mesh":0, - "name":"Icon" - }, - { - "mesh":1, - "name":"Hex" - } - ], - "materials":[ - { - "alphaCutoff":0.5, - "alphaMode":"MASK", - "extensions":{ - "KHR_materials_unlit":{} - }, - "name":"Icon", - "pbrMetallicRoughness":{ - "baseColorTexture":{ - "index":0, - "texCoord":0 - }, - "metallicFactor":0, - "roughnessFactor":0.9 - } - }, - { - "alphaMode":"BLEND", - "extensions":{ - "KHR_materials_unlit":{} - }, - "name":"Hex", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 1, - 0, - 0, - 1 - ], - "baseColorTexture":{ - "index":1, - "texCoord":0 - }, - "metallicFactor":0, - "roughnessFactor":0.9 - } - } - ], - "meshes":[ - { - "name":"Circle", - "primitives":[ - { - "attributes":{ - "COLOR_0":0, - "POSITION":1, - "TEXCOORD_0":2, - "NORMAL":3 - }, - "indices":4, - "material":0 - } - ] - }, - { - "name":"Circle.001", - "primitives":[ - { - "attributes":{ - "COLOR_0":5, - "POSITION":6, - "TEXCOORD_0":7, - "NORMAL":8 - }, - "indices":9, - "material":1 - } - ] - } - ], - "textures":[ - { - "sampler":0, - "source":0 - }, - { - "sampler":1, - "source":1 - } - ], - "images":[ - { - "mimeType":"image/png", - "name":"icon_test", - "uri":"icon_test.png" - }, - { - "mimeType":"image/png", - "name":"hex_atlas", - "uri":"hex_atlas.png" - } - ], - "accessors":[ - { - "bufferView":0, - "componentType":5123, - "count":4, - "normalized":true, - "type":"VEC4" - }, - { - "bufferView":1, - "componentType":5126, - "count":4, - "max":[ - 0.5853440165519714, - 0.05000000074505806, - 0.5853440165519714 - ], - "min":[ - -0.5853440165519714, - 0.05000000074505806, - -0.5853440165519714 - ], - "type":"VEC3" - }, - { - "bufferView":2, - "componentType":5126, - "count":4, - "type":"VEC2" - }, - { - "bufferView":3, - "componentType":5126, - "count":4, - "type":"VEC3" - }, - { - "bufferView":4, - "componentType":5123, - "count":6, - "type":"SCALAR" - }, - { - "bufferView":5, - "componentType":5123, - "count":54, - "normalized":true, - "type":"VEC4" - }, - { - "bufferView":6, - "componentType":5126, - "count":54, - "max":[ - 1.0441828966140747, - 0.05000000074505806, - 0.9042890667915344 - ], - "min":[ - -1.0441828966140747, - 0, - -0.9042890667915344 - ], - "type":"VEC3" - }, - { - "bufferView":7, - "componentType":5126, - "count":54, - "type":"VEC2" - }, - { - "bufferView":8, - "componentType":5126, - "count":54, - "type":"VEC3" - }, - { - "bufferView":9, - "componentType":5123, - "count":84, - "type":"SCALAR" - } - ], - "bufferViews":[ - { - "buffer":0, - "byteLength":32, - "byteOffset":0, - "target":34962 - }, - { - "buffer":0, - "byteLength":48, - "byteOffset":32, - "target":34962 - }, - { - "buffer":0, - "byteLength":32, - "byteOffset":80, - "target":34962 - }, - { - "buffer":0, - "byteLength":48, - "byteOffset":112, - "target":34962 - }, - { - "buffer":0, - "byteLength":12, - "byteOffset":160, - "target":34963 - }, - { - "buffer":0, - "byteLength":432, - "byteOffset":172, - "target":34962 - }, - { - "buffer":0, - "byteLength":648, - "byteOffset":604, - "target":34962 - }, - { - "buffer":0, - "byteLength":432, - "byteOffset":1252, - "target":34962 - }, - { - "buffer":0, - "byteLength":648, - "byteOffset":1684, - "target":34962 - }, - { - "buffer":0, - "byteLength":168, - "byteOffset":2332, - "target":34963 - } - ], - "samplers":[ - { - "magFilter":9729, - "minFilter":9987, - "wrapS":33071, - "wrapT":33071 - }, - { - "magFilter":9729, - "minFilter":9987 - } - ], - "buffers":[ - { - "byteLength":2500, - "uri":"hexagon.bin" - } - ] -} diff --git a/sirius/res/protostar/hexagon/icon_test.png b/sirius/res/protostar/hexagon/icon_test.png deleted file mode 100644 index 68f4809..0000000 Binary files a/sirius/res/protostar/hexagon/icon_test.png and /dev/null differ diff --git a/sirius/src/main.rs b/sirius/src/main.rs index ad1bf58..66141e5 100644 --- a/sirius/src/main.rs +++ b/sirius/src/main.rs @@ -49,7 +49,7 @@ async fn main() -> Result<()> { } let (client, event_loop) = Client::connect_with_async_loop().await?; - client.set_base_prefixes(&[directory_relative_path!("res")]); + client.set_base_prefixes(&[directory_relative_path!("../res")]); let _wrapped_root = client.wrap_root(Sirius::new(&client, args)?)?;