Skip to content

Commit

Permalink
Use a more sensible default library path
Browse files Browse the repository at this point in the history
When the device has an external SD card, it makes more sense for the
user to store its book there and only use the internal SD card for the
installed applications.
  • Loading branch information
baskerville committed Aug 15, 2019
1 parent 062380e commit f8f9f2b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ unzip plato-launcher-fmon-VERSION.zip -d SD_ROOT

## Configure

The default library path is `/mnt/onboard`. If your library lives somewhere else, you'll need to create a file named `Settings.toml` in the same directory as the program's binary with the following content:
The default library path is `/mnt/onboard` on devices without an external SD card, and `/mnt/sd` otherwise. If your library lives somewhere else, you'll need to create a file named `Settings.toml` in the same directory as the program's binary with the following content:
```toml
library-path = "LIBRARY_PATH"
```
Expand Down
13 changes: 13 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::env;
use std::fmt;
use std::path::PathBuf;
use std::collections::HashMap;
use lazy_static::lazy_static;
use crate::unit::scale_by_dpi;
Expand Down Expand Up @@ -69,6 +70,18 @@ pub enum FrontlightKind {
}

impl Device {
pub fn library_path(&self) -> PathBuf {
match self.model {
Model::AuraH2O |
Model::Aura |
Model::AuraHD |
Model::Mini |
Model::Glo |
Model::Touch => PathBuf::from("/mnt/sd"),
_ => PathBuf::from("/mnt/onboard"),
}
}

pub fn frontlight_kind(&self) -> FrontlightKind {
match self.model {
Model::AuraONE |
Expand Down
2 changes: 1 addition & 1 deletion src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl Default for BatterySettings {
impl Default for Settings {
fn default() -> Self {
Settings {
library_path: PathBuf::from("/mnt/onboard"),
library_path: CURRENT_DEVICE.library_path(),
frontlight: true,
wifi: false,
rotation_lock: None,
Expand Down

0 comments on commit f8f9f2b

Please sign in to comment.