feat(scripts): Walk scripts directory when loading a list of scripts
This commit is contained in:
parent
8b3b95aae8
commit
200e7ba55f
5 changed files with 23 additions and 21 deletions
4
Makefile
4
Makefile
|
|
@ -95,6 +95,6 @@ install:
|
||||||
|
|
||||||
# Scripts
|
# Scripts
|
||||||
mkdir -p $(SCRIPTS_DIR)
|
mkdir -p $(SCRIPTS_DIR)
|
||||||
for script in $(PWD)/scripts/session/*.sh scripts/system76-power/*.sh; do \
|
for script in $(PWD)/scripts/*; do \
|
||||||
install -Dm0644 $${script} $(SCRIPTS_DIR); \
|
cp -r $${script} $(SCRIPTS_DIR); \
|
||||||
done
|
done
|
||||||
|
|
|
||||||
2
debian/pop-launcher-system76-power.install
vendored
2
debian/pop-launcher-system76-power.install
vendored
|
|
@ -1 +1 @@
|
||||||
/usr/lib/pop-launcher/scripts/graphics-*
|
/usr/lib/pop-launcher/scripts/system76-power
|
||||||
5
debian/pop-launcher.install
vendored
5
debian/pop-launcher.install
vendored
|
|
@ -1,6 +1,3 @@
|
||||||
/usr/bin/
|
/usr/bin/
|
||||||
/usr/lib/pop-launcher/plugins/
|
/usr/lib/pop-launcher/plugins/
|
||||||
/usr/lib/pop-launcher/scripts/session-logout.sh
|
/usr/lib/pop-launcher/scripts/session/
|
||||||
/usr/lib/pop-launcher/scripts/session-reboot.sh
|
|
||||||
/usr/lib/pop-launcher/scripts/session-shutdown.sh
|
|
||||||
/usr/lib/pop-launcher/scripts/session-suspend.sh
|
|
||||||
2
debian/rules
vendored
2
debian/rules
vendored
|
|
@ -21,4 +21,4 @@ override_dh_auto_build:
|
||||||
override_dh_fixperms:
|
override_dh_fixperms:
|
||||||
dh_fixperms
|
dh_fixperms
|
||||||
chmod +x debian/pop-launcher/usr/lib/pop-launcher/plugins/**/*.js
|
chmod +x debian/pop-launcher/usr/lib/pop-launcher/plugins/**/*.js
|
||||||
chmod +x debian/pop-launcher/usr/lib/pop-launcher/scripts/*.sh
|
chmod +x debian/pop-launcher/usr/lib/pop-launcher/scripts/**/*.sh
|
||||||
|
|
@ -72,21 +72,21 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn reload(&mut self) {
|
async fn reload(&mut self) {
|
||||||
#[allow(deprecated)]
|
let (path_tx, path_rx) = flume::unbounded::<PathBuf>();
|
||||||
let home = std::env::home_dir()
|
|
||||||
.expect("user does not have home dir")
|
|
||||||
.join(LOCAL_PATH);
|
|
||||||
|
|
||||||
let paths = &[
|
#[allow(deprecated)]
|
||||||
&home,
|
let _ = path_tx.send(std::env::home_dir()
|
||||||
Path::new(SYSTEM_ADMIN_PATH),
|
.expect("user does not have home dir")
|
||||||
Path::new(DISTRIBUTION_PATH),
|
.join(LOCAL_PATH));
|
||||||
];
|
|
||||||
let (tx, rx) = flume::unbounded();
|
let _ = path_tx.send(Path::new(SYSTEM_ADMIN_PATH).to_owned());
|
||||||
|
let _ = path_tx.send(Path::new(DISTRIBUTION_PATH).to_owned());
|
||||||
|
|
||||||
|
let (tx, rx) = flume::unbounded::<ScriptInfo>();
|
||||||
|
|
||||||
let script_sender = async move {
|
let script_sender = async move {
|
||||||
for path in paths {
|
for path in path_rx.recv_async().await {
|
||||||
load_from(path, tx.clone()).await;
|
load_from(&path, &path_tx, tx.clone()).await;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -144,12 +144,17 @@ struct ScriptInfo {
|
||||||
description: String,
|
description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn load_from(path: &Path, tx: Sender<ScriptInfo>) {
|
async fn load_from(path: &Path, path_tx: &Sender<PathBuf>, tx: Sender<ScriptInfo>) {
|
||||||
if let Ok(directory) = path.read_dir() {
|
if let Ok(directory) = path.read_dir() {
|
||||||
for entry in directory.filter_map(Result::ok) {
|
for entry in directory.filter_map(Result::ok) {
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
|
if path.is_dir() {
|
||||||
|
path_tx.send_async(path);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
smol::spawn(async move {
|
smol::spawn(async move {
|
||||||
let mut file = match smol::fs::File::open(&path).await {
|
let mut file = match smol::fs::File::open(&path).await {
|
||||||
Ok(file) => smol::io::BufReader::new(file).lines(),
|
Ok(file) => smol::io::BufReader::new(file).lines(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue