Compare commits

...

6 Commits

3 changed files with 31 additions and 7 deletions

View File

@ -10,5 +10,8 @@
* vinyl crackle
* white noise?
* fan
* cat purr
* café
* rustling leaves
* set a window icon
* create a nice icon?

View File

@ -23,7 +23,8 @@ fn save_config(config: Config) {
let mut config_path = dirs::config_dir()
.expect("Couldn't find user config directory");
config_path.push("ruin/lull");
config_path.push("ruin");
config_path.push("lull");
if !config_path.exists() {
std::fs::create_dir_all(&config_path)
@ -46,7 +47,9 @@ fn load_config() -> Option<Config> {
let mut config_path = dirs::config_dir()
.expect("Couldn't find user config directory");
config_path.push("ruin/lull/lull.toml");
config_path.push("ruin");
config_path.push("lull");
config_path.push("lull.toml");
let file = File::open(config_path);
@ -90,10 +93,11 @@ fn error_popup(message: &str) {
popup.show_all();
}
fn get_data_dir() -> PathBuf {
fn get_sounds_dir() -> PathBuf {
let mut data_dir = dirs::data_dir().expect("Couldn't find user data directory");
data_dir.push("ruin/lull");
data_dir.push("ruin");
data_dir.push("lull");
if !data_dir.exists() {
std::fs::create_dir_all(&data_dir).expect("Couldn't create lull data directory");
@ -119,7 +123,7 @@ fn build_ui(application: &gtk::Application) {
button_manage_sounds.connect_clicked(|_| {
let mut file_manager = Command::new(file_manager());
file_manager.arg(get_data_dir());
file_manager.arg(get_sounds_dir());
file_manager.output().unwrap();
});
@ -143,7 +147,7 @@ fn build_ui(application: &gtk::Application) {
let device = rodio::default_output_device().unwrap();
let mut paths = std::fs::read_dir(get_data_dir())
let mut paths = std::fs::read_dir(get_sounds_dir())
.expect("Couldn't read lull sounds directory")
.map(|res| res.map(|e| e.path()))
.collect::<Result<Vec<_>, std::io::Error>>()
@ -152,7 +156,14 @@ fn build_ui(application: &gtk::Application) {
paths.sort();
for path in paths {
let name: &str = path.file_stem().unwrap().to_str().unwrap();
let name = path.file_stem().unwrap().to_str().unwrap();
let extension = path.extension().unwrap().to_str().unwrap();
// on Windows the data dir and config dir are the same,
// so avoid parsing the config file as an audio file
if extension == "toml" {
continue;
}
let file = File::open(&path)
.expect("Couldn't open audio file");
@ -223,6 +234,10 @@ fn build_ui(application: &gtk::Application) {
}
fn main() {
// instantiate rodio before gtk and don't do anything with it
// this is silly but it's the easiest way to prevent cpal crashing on windows
rodio::default_output_device().unwrap();
let application = gtk::Application::new(
Some("dev.tinybird.max.lull"),
Default::default()

6
windows.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
export PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig
rm -rf package
docker start lull-build-3 -ai | less