main: message shell

This commit is contained in:
2 * r + 2 * t
2025-01-17 16:32:26 +11:00
parent 7205226e5f
commit 2185b60b58
2 changed files with 26 additions and 12 deletions
+17 -1
View File
@@ -4,15 +4,31 @@ cd (dirname (status filename)) || exit
. ./util.fish . ./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 if test "$argv[1]" = change-wallpaper
./change-wallpaper.fish $argv[2..] ./change-wallpaper.fish $argv[2..]
exit
end end
test "$argv[1]" != help && error "Unknown command: $argv[1]" test "$argv[1]" != help && error "Unknown command: $argv[1]"
echo 'Usage: caelestia COMMAND' echo 'Usage: caelestia COMMAND'
echo echo
echo 'COMMAND := help | change-wallpaper' echo 'COMMAND := help | shell | change-wallpaper'
echo echo
echo ' help: show this help message' echo ' help: show this help message'
echo ' shell: send a message to the shell'
echo ' change-wallpaper: change the wallpaper' echo ' change-wallpaper: change the wallpaper'
+9 -11
View File
@@ -1,20 +1,18 @@
function log -a text function _out -a colour -a level -a text
set_color cyan set_color $colour
# Pass arguments other than text to echo # Pass arguments other than text to echo
echo $argv[2..] -- ":: $text" echo $argv[4..] -- ":: [$level] $text"
set_color normal set_color normal
end end
function log -a text
_out cyan LOG $text $argv[2..]
end
function warn -a text function warn -a text
set_color yellow _out yellow WARN $text $argv[2..]
# Pass arguments other than text to echo
echo $argv[2..] -- ":: $text"
set_color normal
end end
function error -a text function error -a text
set_color red _out red ERROR $text $argv[2..]
# Pass arguments other than text to echo
echo $argv[2..] -- ":: $text"
set_color normal
end end