mirror of
https://github.com/caelestia-dots/cli.git
synced 2026-06-08 08:19:28 -05:00
don't cd
Changing the working directory breaks realpath for the wallpaper when you dont provide the full path
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#!/bin/fish
|
#!/bin/fish
|
||||||
|
|
||||||
cd (dirname (realpath (status filename))) || exit
|
set -l src (dirname (realpath (status filename)))
|
||||||
|
|
||||||
. ./util.fish
|
. $src/util.fish
|
||||||
|
|
||||||
if test "$argv[1]" = shell
|
if test "$argv[1]" = shell
|
||||||
# Start shell if no args
|
# Start shell if no args
|
||||||
@@ -22,12 +22,12 @@ end
|
|||||||
|
|
||||||
if test "$argv[1]" = toggle
|
if test "$argv[1]" = toggle
|
||||||
set -l valid_toggles communication music sysmon specialws
|
set -l valid_toggles communication music sysmon specialws
|
||||||
contains "$argv[2]" $valid_toggles && ./toggles/$argv[2].fish || error "Invalid toggle: $argv[2]"
|
contains "$argv[2]" $valid_toggles && $src/toggles/$argv[2].fish || error "Invalid toggle: $argv[2]"
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
if test "$argv[1]" = workspace-action
|
if test "$argv[1]" = workspace-action
|
||||||
./workspace-action.sh $argv[2..]
|
$src/workspace-action.sh $argv[2..]
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ end
|
|||||||
set valid_subcommands screenshot record clipboard clipboard-delete emoji-picker wallpaper pip
|
set valid_subcommands screenshot record clipboard clipboard-delete emoji-picker wallpaper pip
|
||||||
|
|
||||||
if contains "$argv[1]" $valid_subcommands
|
if contains "$argv[1]" $valid_subcommands
|
||||||
./$argv[1].fish $argv[2..]
|
$src/$argv[1].fish $argv[2..]
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+13
-3
@@ -7,8 +7,8 @@ set threshold 80
|
|||||||
# Max 0 non-option args | h, f and d are exclusive | F and t are also exclusive
|
# Max 0 non-option args | h, f and d are exclusive | F and t are also exclusive
|
||||||
argparse -n 'caelestia-wallpaper' -X 0 -x 'h,f,d' -x 'F,t' \
|
argparse -n 'caelestia-wallpaper' -X 0 -x 'h,f,d' -x 'F,t' \
|
||||||
'h/help' \
|
'h/help' \
|
||||||
'f/file=!test -f "$_flag_value"' \
|
'f/file=' \
|
||||||
'd/directory=!test -d "$_flag_value"' \
|
'd/directory=' \
|
||||||
'F/no-filter' \
|
'F/no-filter' \
|
||||||
't/threshold=!_validate_int --min 0' \
|
't/threshold=!_validate_int --min 0' \
|
||||||
-- $argv
|
-- $argv
|
||||||
@@ -40,6 +40,11 @@ else
|
|||||||
if set -q _flag_f
|
if set -q _flag_f
|
||||||
set chosen_wallpaper (realpath $_flag_f)
|
set chosen_wallpaper (realpath $_flag_f)
|
||||||
|
|
||||||
|
if ! test -f $chosen_wallpaper
|
||||||
|
echo "$chosen_wallpaper does not exist"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
# Set last wallpaper if not same as given
|
# Set last wallpaper if not same as given
|
||||||
if [ -f "$last_wallpaper_path" ]
|
if [ -f "$last_wallpaper_path" ]
|
||||||
set last_wallpaper (cat $last_wallpaper_path)
|
set last_wallpaper (cat $last_wallpaper_path)
|
||||||
@@ -47,7 +52,12 @@ else
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
# The path to the directory containing the selection of wallpapers
|
# The path to the directory containing the selection of wallpapers
|
||||||
set -q _flag_d && set wallpapers_dir $_flag_d
|
set -q _flag_d && set wallpapers_dir (realpath $_flag_d)
|
||||||
|
|
||||||
|
if ! test -d $wallpapers_dir
|
||||||
|
echo "$wallpapers_dir does not exist"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
# Get all files in $wallpapers_dir and exclude the last wallpaper (if it exists)
|
# Get all files in $wallpapers_dir and exclude the last wallpaper (if it exists)
|
||||||
if [ -f "$last_wallpaper_path" ]
|
if [ -f "$last_wallpaper_path" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user