add rpm generation
This commit is contained in:
parent
6be45162e3
commit
e08394d68a
|
@ -7,6 +7,17 @@ license = "GPL-3.0-or-later"
|
|||
repository = "https://github.com/AnActualEmerald/cathode"
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.generate-rpm]
|
||||
assets = [
|
||||
{source= "target/release/cathode-tube", dest= "/usr/bin/cathode", mode= "755"},
|
||||
{source="cathode-tube.desktop", dest="/usr/share/applications/cathode-tube.desktop", mode="0644"},
|
||||
{source="application-cathode.xml", dest="/usr/share/mime/packages/application-cathode.xml", mode="0644"},
|
||||
{source="icons/128x128.png", dest="/usr/share/icons/hicolor/128x128/apps/cathode-tube.png", mode="0644"},
|
||||
{source="icons/128x128@2x.png", dest="/usr/share/icons/hicolor/256x256@2/apps/cathode-tube.png", mode="0644"},
|
||||
|
||||
]
|
||||
|
||||
|
||||
[workspace]
|
||||
|
||||
[profile.release]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Type=Application
|
||||
Icon=cathode-tube
|
||||
Name=Cathode
|
||||
Exec=cathode-tube %U
|
||||
Exec=cathode %U
|
||||
Terminal=false
|
||||
Hidden=false
|
||||
Categories=Graphics; Video
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
use std::io::Cursor;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use base64_url as base64;
|
||||
use image::ImageFormat;
|
||||
|
@ -8,7 +8,8 @@ use log::{debug, trace};
|
|||
use ray_format::Ray;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::api::dialog::blocking::FileDialogBuilder;
|
||||
use tauri::api::path::home_dir;
|
||||
use tauri::api::path::{cache_dir, home_dir, picture_dir};
|
||||
use tokio::fs;
|
||||
|
||||
const OBJ_URL: &'static str = "data:image/png;base64,";
|
||||
|
||||
|
@ -22,7 +23,7 @@ pub(crate) struct WebRay {
|
|||
pub(crate) async fn open_image() -> Option<String> {
|
||||
let path = FileDialogBuilder::new()
|
||||
.add_filter("Images", &["png", "jpg"])
|
||||
.set_directory(home_dir()?)
|
||||
.set_directory(picture_dir().unwrap_or_else(|| home_dir().unwrap()))
|
||||
.set_title("Select an image")
|
||||
.pick_file()?;
|
||||
if let Ok(b) = image::open(path) {
|
||||
|
@ -48,7 +49,7 @@ pub(crate) async fn open_ray() -> Option<WebRay> {
|
|||
}
|
||||
|
||||
pub(crate) async fn load_ray(path: impl AsRef<Path>) -> Option<WebRay> {
|
||||
let ray = Ray::load(path).ok()?;
|
||||
let ray = Ray::load(path.as_ref()).ok()?;
|
||||
let mut frames = [String::new(), String::new(), String::new(), String::new()];
|
||||
let mut meta = HashMap::new();
|
||||
|
||||
|
@ -72,6 +73,17 @@ pub(crate) async fn load_ray(path: impl AsRef<Path>) -> Option<WebRay> {
|
|||
}
|
||||
}
|
||||
|
||||
fs::write(
|
||||
cache_dir().unwrap().join("last_selected"),
|
||||
path.as_ref()
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.as_bytes(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
Some(WebRay { frames, meta })
|
||||
}
|
||||
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
)]
|
||||
|
||||
use std::{
|
||||
path::Path,
|
||||
path::{Path, PathBuf},
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use audio::monitor;
|
||||
use log::{trace, warn};
|
||||
use log::{debug, trace, warn};
|
||||
use serde_json::Value;
|
||||
use tauri::{Manager, State};
|
||||
use tauri::{api::path::cache_dir, Manager, State};
|
||||
|
||||
mod audio;
|
||||
mod fs;
|
||||
|
@ -22,10 +22,22 @@ const MIC_THRESHOLD: f32 = 0.5f32;
|
|||
struct MicThreshold(Arc<Mutex<f32>>);
|
||||
struct AudioLevel(Arc<Mutex<f32>>);
|
||||
|
||||
// struct LastImage(Option<Arc<Path>>);
|
||||
// struct LastRay(Arc<Mutex<Path>>);
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
let threshold = Arc::new(Mutex::new(MIC_THRESHOLD));
|
||||
let level = Arc::new(Mutex::new(0.));
|
||||
let mut ray = None;
|
||||
|
||||
if let Some(d) = cache_dir() {
|
||||
use std::fs;
|
||||
if let Ok(s) = fs::read_to_string(d.join("last_selected")) {
|
||||
debug!("Found selected ray in cache");
|
||||
ray = Some(Path::new(&s).to_path_buf());
|
||||
}
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
.manage(MicThreshold(threshold.clone()))
|
||||
|
@ -61,6 +73,15 @@ fn main() {
|
|||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(r) = ray {
|
||||
let window = app.get_window("main").unwrap();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if let Some(ray) = fs::load_ray(r).await {
|
||||
window.emit("load-ray", ray).unwrap();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue