Compare commits
5 Commits
0af09fcd96
...
attempted-
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fd83be754 | |||
| 3e01249ecf | |||
| 5f42e1a03c | |||
| 06960b6f9c | |||
| 7e045c0a8d |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,3 +6,5 @@
|
||||
/sounds/*.wav
|
||||
/sounds.zip
|
||||
/lull.zip
|
||||
/dist/
|
||||
/package/
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
[package]
|
||||
name = "lull"
|
||||
description = "a looping sound player for generating atmospheric soundscapes"
|
||||
version = "1.0.1"
|
||||
version = "1.0.3"
|
||||
authors = ["Max Bradbury <max@tinybird.info>"]
|
||||
repository = "https://tinybird.dev/max/lull"
|
||||
license = "MIT"
|
||||
edition = "2018"
|
||||
crate_type = "bin"
|
||||
|
||||
[dependencies]
|
||||
dirs = "^3.0.1"
|
||||
@@ -14,3 +13,6 @@ gdk = "^0.13.2"
|
||||
gio = "^0"
|
||||
gtk = "^0"
|
||||
rodio = "^0.11.0"
|
||||
serde = "^1.0.125"
|
||||
serde_derive = "^1.0.125"
|
||||
toml = "^0.5.8"
|
||||
|
||||
@@ -19,3 +19,5 @@ you can skip/remove any unwanted sounds, and add your own.
|
||||
*rain on glass* by [Benboncan](https://freesound.org/people/Benboncan/)
|
||||
|
||||
*birdsong* by [reinsamba](https://freesound.org/people/reinsamba/)
|
||||
|
||||
*fireplace* by [aunrea](https://freesound.org/people/aunrea/)
|
||||
|
||||
19
build.sh
19
build.sh
@@ -1,15 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
mkdir dist
|
||||
|
||||
cargo build --release
|
||||
cp target/release/lull .
|
||||
strip lull
|
||||
|
||||
# zip (itch desktop)
|
||||
zip -r lull-linux.zip README.md LICENSE lull
|
||||
# tar.gz (downloadable)
|
||||
rm lull-linux.tar.gz
|
||||
tar -czvf lull-linux.tar.gz README.md LICENSE lull
|
||||
mkdir dist/linux
|
||||
|
||||
rm lull
|
||||
cp target/release/lull dist/linux
|
||||
cp README.md dist/linux
|
||||
cp LICENSE dist/linux
|
||||
strip dist/linux/lull
|
||||
|
||||
zip -r sounds.zip SOUNDS.md sounds/*.mp3
|
||||
mkdir dist/sounds
|
||||
|
||||
cp sounds/*.mp3 SOUNDS.md dist/sounds
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
butler push lull-linux.tar.gz ruin/lull:linux-download
|
||||
butler push lull-linux.zip ruin/lull:linux-itch
|
||||
butler push sounds.zip ruin/lull:sounds
|
||||
butler push dist/linux ruin/lull:linux
|
||||
butler push dist/sounds ruin/lull:sounds
|
||||
|
||||
71
src/main.rs
71
src/main.rs
@@ -4,14 +4,69 @@ use gio::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Orientation;
|
||||
use rodio::{Sink, Source};
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
use std::env::args;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::{BufReader, Write, Read};
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
const SPACING: i32 = 16;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
struct Config {
|
||||
position: (i32, i32),
|
||||
size: (i32, i32),
|
||||
}
|
||||
|
||||
fn save_config(config: Config) {
|
||||
let mut config_path = dirs::config_dir()
|
||||
.expect("Couldn't find user config directory");
|
||||
|
||||
config_path.push("ruin/lull");
|
||||
|
||||
if !config_path.exists() {
|
||||
std::fs::create_dir_all(&config_path)
|
||||
.expect("Couldn't create lull config directory");
|
||||
}
|
||||
|
||||
let toml = toml::to_string(&config)
|
||||
.expect("Couldn't convert config to toml");
|
||||
|
||||
config_path.push("lull.toml");
|
||||
|
||||
let mut config_file = File::create(config_path)
|
||||
.expect("Couldn't create config file");
|
||||
|
||||
print!("{}", toml);
|
||||
|
||||
config_file.write(&toml.into_bytes())
|
||||
.expect("Couldn't write config file");
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
let file = File::open(config_path);
|
||||
|
||||
if file.is_err() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut toml = String::new();
|
||||
|
||||
file.unwrap().read_to_string(&mut toml)
|
||||
.expect("Couldn't read config file");
|
||||
|
||||
let config = toml::from_str(&toml)
|
||||
.expect("Couldn't parse config");
|
||||
|
||||
Some(config)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn file_manager() -> &'static str {
|
||||
"explorer"
|
||||
@@ -57,6 +112,11 @@ fn build_ui(application: >k::Application) {
|
||||
window.set_position(gtk::WindowPosition::Center);
|
||||
window.set_default_size(256, 128);
|
||||
|
||||
if let Some(config) = load_config() {
|
||||
window.move_(config.position.0, config.position.1);
|
||||
window.resize(config.size.0, config.size.1);
|
||||
}
|
||||
|
||||
let button_manage_sounds = gtk::Button::with_label("manage sounds");
|
||||
|
||||
button_manage_sounds.connect_clicked(|_| {
|
||||
@@ -153,6 +213,15 @@ fn build_ui(application: >k::Application) {
|
||||
}
|
||||
|
||||
window.show_all();
|
||||
|
||||
window.connect_delete_event(|window, _event| {
|
||||
save_config(Config {
|
||||
position: window.get_position(),
|
||||
size: window.get_size()
|
||||
});
|
||||
|
||||
Inhibit(false)
|
||||
});
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
Reference in New Issue
Block a user