13 Commits
5 changed files with 60 additions and 31 deletions
+13 -12
View File
@@ -39,6 +39,7 @@ permissions:
# If there's a prerelease-style suffix to the version, then the release(s)
# will be marked as a prerelease.
on:
pull_request:
push:
tags:
- '**[0-9]+.[0-9]+.[0-9]+*'
@@ -63,9 +64,9 @@ jobs:
# we specify bash to get pipefail; it guards against the `curl` command
# failing. otherwise `sh` won't catch that `curl` returned non-0
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.32.0/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh"
- name: Cache dist
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v6
with:
name: cargo-dist-cache
path: ~/.cargo/bin/dist
@@ -81,7 +82,7 @@ jobs:
cat plan-dist-manifest.json
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: "Upload dist-manifest.json"
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v6
with:
name: artifacts-plan-dist-manifest
path: plan-dist-manifest.json
@@ -130,7 +131,7 @@ jobs:
run: ${{ matrix.install_dist.run }}
# Get the dist-manifest
- name: Fetch local artifacts
uses: actions/download-artifact@v8
uses: actions/download-artifact@v7
with:
pattern: artifacts-*
path: target/distrib/
@@ -157,7 +158,7 @@ jobs:
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: "Upload artifacts"
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v6
with:
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
path: |
@@ -179,14 +180,14 @@ jobs:
persist-credentials: false
submodules: recursive
- name: Install cached dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@v7
with:
name: cargo-dist-cache
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/dist
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
- name: Fetch local artifacts
uses: actions/download-artifact@v8
uses: actions/download-artifact@v7
with:
pattern: artifacts-*
path: target/distrib/
@@ -204,7 +205,7 @@ jobs:
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: "Upload artifacts"
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v6
with:
name: artifacts-build-global
path: |
@@ -229,14 +230,14 @@ jobs:
persist-credentials: false
submodules: recursive
- name: Install cached dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@v7
with:
name: cargo-dist-cache
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/dist
# Fetch artifacts from scratch-storage
- name: Fetch artifacts
uses: actions/download-artifact@v8
uses: actions/download-artifact@v7
with:
pattern: artifacts-*
path: target/distrib/
@@ -249,14 +250,14 @@ jobs:
cat dist-manifest.json
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: "Upload dist-manifest.json"
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v6
with:
# Overwrite the previous copy
name: artifacts-dist-manifest
path: dist-manifest.json
# Create a GitHub Release while uploading all files to it
- name: "Download GitHub Artifacts"
uses: actions/download-artifact@v8
uses: actions/download-artifact@v7
with:
pattern: artifacts-*
path: artifacts
Generated
+1 -1
View File
@@ -2120,7 +2120,7 @@ dependencies = [
[[package]]
name = "termato"
version = "0.0.0"
version = "0.1.0"
dependencies = [
"cpal",
"crossterm",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "termato"
version = "0.0.0"
version = "0.1.0"
edition = "2024"
repository = "https://github.com/StevanFreeborn/termato"
+8 -1
View File
@@ -4,10 +4,17 @@ members = ["cargo:."]
# Config for 'dist'
[dist]
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.32.0"
cargo-dist-version = "0.31.0"
# CI backends to support
ci = "github"
# The installers to generate for each app
installers = ["shell", "powershell"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# Path that installers should place binaries in
install-path = "CARGO_HOME"
# Whether to install an updater program
install-updater = true
[dist.dependencies.apt]
libasound2-dev = "*"
+37 -16
View File
@@ -161,7 +161,7 @@ impl AudioVisualizer {
let bar_data = Arc::new(Mutex::new(vec![0; num_bars]));
let bar_data_clone = Arc::clone(&bar_data);
let stop_flag = Arc::new(AtomicBool::new(false));
let stop_clone = Arc::new(AtomicBool::new(false));
let stop_clone = Arc::clone(&stop_flag);
thread::spawn(move || {
if let Err(e) = Self::run_audio_loop(bar_data_clone, num_bars, stop_clone) {
@@ -194,9 +194,11 @@ impl AudioVisualizer {
{
if let Ok(devices) = host.devices() {
for dev in devices {
if let Ok(name) = dev.name() {
// Monitor devices mirror system output under PulseAudio/PipeWire
if let Ok(desc) = dev.description() {
let name = desc.to_string();
if name.contains("monitor") {
// Monitor devices mirror system output under PulseAudio/PipeWire
if let Ok(config) = dev.default_input_config() {
return Ok((dev, config.into()));
}
@@ -317,7 +319,8 @@ impl AudioVisualizer {
// sensitivity to avoid bars becoming flattened or
// clipped
fn adjust_autosens(autosens: &mut f32, bars: &[f32]) {
let max_val = bars.iter().cloned().fold(0.0f32, f32::max);
let max_val = bars.iter().copied().fold(0.0f32, f32::max);
if max_val > 8.0 {
*autosens *= 0.98;
} else if max_val < 3.0 && *autosens < 3.0 {
@@ -430,7 +433,7 @@ impl AudioVisualizer {
impl Drop for AudioVisualizer {
fn drop(&mut self) {
self.stop_flag.store(true, Ordering::Relaxed)
self.stop_flag.store(true, Ordering::Relaxed);
}
}
@@ -446,8 +449,10 @@ impl Drop for AudioVisualizer {
fn render_visualizer(f: &mut Frame, area: Rect, bar_values: &[u64]) {
const BLOCKS: [&str; 8] = ["", "", "", "", "", "", "", ""];
let max_bars = area.width as usize;
let line: String = bar_values
.iter()
.take(max_bars)
.map(|&val| {
if val == 0 {
" "
@@ -461,7 +466,7 @@ fn render_visualizer(f: &mut Frame, area: Rect, bar_values: &[u64]) {
.collect();
let viz_paragraph = Paragraph::new(line)
.style(Style::default().fg(Color::Cyan))
.style(Style::default().fg(Color::Rgb(200, 184, 224)))
.alignment(Alignment::Center);
f.render_widget(viz_paragraph, area);
@@ -504,11 +509,18 @@ fn main() -> Result<(), io::Error> {
None
};
let positional_args: Vec<&String> = args
.iter()
.skip(1)
.filter(|arg| *arg != "-n" && *arg != "--notify" && *arg != "-z" && *arg != "--visualizer")
.collect();
let is_flag = |arg: &str| {
arg == "-n"
|| arg == "--notify"
|| arg == "-z"
|| arg == "--visualizer"
|| arg == "-h"
|| arg == "--help"
|| arg == "-v"
|| arg == "--version"
};
let positional_args: Vec<&String> = args.iter().skip(1).filter(|arg| !is_flag(arg)).collect();
let work_mins = positional_args
.first()
@@ -544,11 +556,11 @@ fn main() -> Result<(), io::Error> {
let time_str = format!("{:02}:{:02}", minutes, seconds);
let time_color = if !termato.is_running {
Color::Yellow
Color::Rgb(212, 200, 122)
} else {
match termato.mode {
TimerMode::Work => Color::Red,
TimerMode::Break => Color::Green,
TimerMode::Work => Color::Rgb(212, 115, 115),
TimerMode::Break => Color::Rgb(126, 200, 192),
}
};
@@ -633,7 +645,7 @@ fn main() -> Result<(), io::Error> {
let help_block = Block::default()
.title(" Controls ")
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::DarkGray));
.border_style(Style::default().fg(Color::Rgb(58, 62, 70)));
let help_content = Paragraph::new(
"[Space] Pause / Resume\n\
@@ -643,7 +655,7 @@ fn main() -> Result<(), io::Error> {
[Q] Quit",
)
.block(help_block)
.style(Style::default().fg(Color::DarkGray))
.style(Style::default().fg(Color::Rgb(224, 228, 232)))
.alignment(Alignment::Left);
f.render_widget(Clear, popup_area);
@@ -822,4 +834,13 @@ mod tests {
let result = result.with_notifications(true);
assert!(result.enable_notifications);
}
#[test]
fn termato_visualizer_when_called_it_should_verify_opt_in_behavior() {
let result = Termato::new(25, 5);
assert!(!result.enable_visualizer);
let result = result.with_visualizer(true);
assert!(result.enable_visualizer);
}
}