49 lines
1.3 KiB
Fish
49 lines
1.3 KiB
Fish
|
#!/usr/bin/env fish
|
||
|
import @parent
|
||
|
alias hc=herbstclient
|
||
|
|
||
|
function new_config
|
||
|
argparse -i 'n/name=' 'v/value=' 't/type=' -- $argv
|
||
|
set_default _flag_type 'string'
|
||
|
if test -z "$_flag_name"; or test -z "$_flag_value"
|
||
|
log -c 'red' "name and value must be set"
|
||
|
return 1
|
||
|
end
|
||
|
set -f cfg_name (printf 'settings.my_%s' $_flag_name)
|
||
|
|
||
|
hc get_attr settings.my_$_flag_name &> /dev/null
|
||
|
if test $status -eq 0
|
||
|
hc set_attr "settings.my_$_flag_name" \
|
||
|
$_flag_value #&> /dev/null
|
||
|
else
|
||
|
hc new_attr "$_flag_type" \
|
||
|
"$cfg_name" \
|
||
|
"$_flag_value" #&> /dev/null
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function set_config
|
||
|
argparse -i 'n/name=' 'v/value=' -- $argv
|
||
|
if test -z "$_flag_name"; or test -z "$_flag_value";
|
||
|
log -c 'red' "name and value must be set"
|
||
|
return 1
|
||
|
end
|
||
|
set -f cfg_name (printf 'settings.my_%s' $_flag_name)
|
||
|
|
||
|
hc set_attr $cfg_name $_flag_value
|
||
|
end
|
||
|
|
||
|
function get_config
|
||
|
set -f cfg_name (printf 'settings.my_%s' "$argv")
|
||
|
|
||
|
hc get_attr $cfg_name
|
||
|
end
|
||
|
|
||
|
function set_log_color
|
||
|
set -f parent (parent_script)
|
||
|
new_config \
|
||
|
-t string \
|
||
|
-n "$(printf 'Color_%s' "$parent")" \
|
||
|
-v "$argv"
|
||
|
end
|