From 2185b60b5842c5f2d87d232cc3dd4546045947a6 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:32:26 +1100 Subject: main: message shell --- main.fish | 18 +++++++++++++++++- util.fish | 20 +++++++++----------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/main.fish b/main.fish index 3292e65..9381ddb 100755 --- a/main.fish +++ b/main.fish @@ -4,15 +4,31 @@ cd (dirname (status filename)) || exit . ./util.fish +if test "$argv[1]" = shell + if contains 'caelestia' (astal -l) + if test -n "$argv[2..]" + log "Sent command '$argv[2..]' to shell" + astal -i caelestia $argv[2..] + else + warn 'No args given, ignoring' + end + else + warn 'Shell unavailable' + end + exit +end + if test "$argv[1]" = change-wallpaper ./change-wallpaper.fish $argv[2..] + exit end test "$argv[1]" != help && error "Unknown command: $argv[1]" echo 'Usage: caelestia COMMAND' echo -echo 'COMMAND := help | change-wallpaper' +echo 'COMMAND := help | shell | change-wallpaper' echo echo ' help: show this help message' +echo ' shell: send a message to the shell' echo ' change-wallpaper: change the wallpaper' diff --git a/util.fish b/util.fish index 4fe4444..4b5d981 100644 --- a/util.fish +++ b/util.fish @@ -1,20 +1,18 @@ -function log -a text - set_color cyan +function _out -a colour -a level -a text + set_color $colour # Pass arguments other than text to echo - echo $argv[2..] -- ":: $text" + echo $argv[4..] -- ":: [$level] $text" set_color normal end +function log -a text + _out cyan LOG $text $argv[2..] +end + function warn -a text - set_color yellow - # Pass arguments other than text to echo - echo $argv[2..] -- ":: $text" - set_color normal + _out yellow WARN $text $argv[2..] end function error -a text - set_color red - # Pass arguments other than text to echo - echo $argv[2..] -- ":: $text" - set_color normal + _out red ERROR $text $argv[2..] end -- cgit v1.2.3-freya