Compare commits

...

2 commits

Author SHA1 Message Date
80a7334f59
Improve asciinema session recording 2023-12-12 18:55:53 +01:00
8d6ab690c4
Improve some scripts 2023-12-12 18:55:32 +01:00
5 changed files with 37 additions and 7 deletions

View file

@ -30,7 +30,7 @@ pass_path=$project_dir/$(echo "$pass_content" | grep "path:" | cut -d' ' -f2-)
case "$1" in case "$1" in
edit) edit)
pass edit "ansible/$project" ansible-vault edit "$pass_path"
exit 0 exit 0
;; ;;
deploy) deploy)
@ -41,6 +41,10 @@ case "$1" in
pass insert -m "ansible/$project.file" < "$pass_path" pass insert -m "ansible/$project.file" < "$pass_path"
exit 0 exit 0
;; ;;
pass-edit)
pass edit "ansible/$project"
exit 0
;;
esac esac
echo "$pass_content" | head -n 1 echo "$pass_content" | head -n 1

View file

@ -4,15 +4,29 @@ set -e
if [ -x "$(command -v asciinema)" ] \ if [ -x "$(command -v asciinema)" ] \
&& [ -z "$ASCIINEMA_REC" ] \ && [ -z "$ASCIINEMA_REC" ] \
&& [ "$ASCIINEMA_LOG" -gt 0 ] && [ -n "$ASCIINEMA_LOG" ]
then then
ASCIINEMA_LOG_DIR="$HOME/.cache/logs" ASCIINEMA_LOG_DIR="$HOME/.cache/logs"
mkdir -p "$ASCIINEMA_LOG_DIR" mkdir -p "$ASCIINEMA_LOG_DIR"
_file_name_date=$(date +%Y-%m-%d_%H%M%S) _file_name_date=$(date +%Y-%m-%d_%H%M%S)
if [ "$ASCIINEMA_LOG" = "raw" ]
then
export ASCIINEMA_LOG_FILE="$ASCIINEMA_LOG_DIR/asciinema-$_file_name_date.txt" export ASCIINEMA_LOG_FILE="$ASCIINEMA_LOG_DIR/asciinema-$_file_name_date.txt"
asciinema rec --quiet --raw "$ASCIINEMA_LOG_FILE" asciinema rec --quiet --raw "$ASCIINEMA_LOG_FILE"
exit 0 # Parent script should exit exit 0 # Parent script should exit
fi
if [ "$ASCIINEMA_LOG" = "video" ]
then
export ASCIINEMA_LOG_FILE="$ASCIINEMA_LOG_DIR/asciinema-$_file_name_date.cast"
asciinema rec --quiet --idle-time-limit=3 "$ASCIINEMA_LOG_FILE"
exit 0 # Parent script should exit
fi
echo "Invalid value for ASCIINEMA_LOG: $ASCIINEMA_LOG"
echo "Valid values are: raw, video"
echo "Your session will not be recorded"
exit 1 # Parent script should not exit
fi fi
exit 1 # Parent script should not exit exit 1 # Parent script should not exit

6
.bin/user-cleaner Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
# clean old logs
log_dir="$HOME/.cache/logs"
[ -d "$log_dir" ] \
&& find "$log_dir" -type f -mtime +7 -delete

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
export AUTOSTART_DISPLAY="Hyprland" export AUTOSTART_DISPLAY="Hyprland"
export ASCIINEMA_LOG="1" export ASCIINEMA_LOG="video"
export MONITOR_PRIMARY="DisplayPort-0" export MONITOR_PRIMARY="DisplayPort-0"
export MONITOR_SECONDARY="HDMI-A-0" export MONITOR_SECONDARY="HDMI-A-0"

View file

@ -15,7 +15,7 @@ $cmd_duration\
[](bg:red fg:yellow)\ [](bg:red fg:yellow)\
$status\ $status\
[](bg:white fg:red)\ [](bg:white fg:red)\
$shell\ ${custom.asciinema_log}$shell\
[](bg:cyan fg:white)\ [](bg:cyan fg:white)\
$jobs\ $jobs\
[](cyan) [](cyan)
@ -36,6 +36,12 @@ show_milliseconds = true
style = "bg:yellow fg:black" style = "bg:yellow fg:black"
format = "[$duration]($style)" format = "[$duration]($style)"
[custom.asciinema_log]
command = 'case $ASCIINEMA_LOG in "raw") printf "" ;; "video") printf "" ;; esac'
when = ''' test -n "$ASCIINEMA_LOG" && test -n "$ASCIINEMA_REC" '''
style = "bg:white fg:black"
format = '[$output ]($style)'
[directory] [directory]
read_only = "" read_only = ""
truncation_length = 8 truncation_length = 8