Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature idea: scriptable output #296

Closed
jtroo opened this issue Feb 8, 2023 Discussed in #275 · 3 comments · Fixed by #304
Closed

Feature idea: scriptable output #296

jtroo opened this issue Feb 8, 2023 Discussed in #275 · 3 comments · Fixed by #304
Labels
enhancement New feature or request

Comments

@jtroo
Copy link
Owner

jtroo commented Feb 8, 2023

Discussed in #275

Originally posted by gerhard-h January 27, 2023
Here is my solution (quite cumbersome)
it starts with this in my .kbd file:

(defalias  
;; bottom 2 lines of kbd script no leading spaces 
dayiso (macro kp2 kp0 kp2 kp3 - kp0 kp1 - kp3 kp0  ) 
dayde  (macro kp3 kp0 . kp0 kp1 . kp2 kp0 kp2 kp3  )) 

@dayiso gives 2023-01-30 and @dayde gives 30.01.2023

but this is hardcoded and not the current date!
To fix this I scheduled a batch file to run each day to update the date
( runs on windows with german date format in the same folder as kanata.kbd)

@for /f "tokens=1-3 delims=. " %%a in ('date /T') do @echo %%c-%%b-%%a > todayiso.txt 
@date /T > todayde.txt
grep -E -v "^dayde |^dayiso " kanata.kbd > todayisokanata.txt
sed -r -e "s/([0-9])/kp\1 /g" -e "s/-/- /g"    -e "s/^/dayiso (macro /" -e "s/$/)/" todayiso.txt >> todayisokanata.txt
sed -r -e "s/([0-9])/kp\1 /g" -e "s/\./\. /g"  -e "s/^/dayde  (macro /" -e "s/$/))/" todayde.txt >> todayisokanata.txt
copy todayisokanata.txt kanata.kbd

Finally if you don't if the computer is not restarted I have to use live reload key lrld to tell kananta to update its config.

Is there an easier way?

@jtroo jtroo added the enhancement New feature or request label Feb 8, 2023
@jtroo
Copy link
Owner Author

jtroo commented Feb 14, 2023

Merged into v1.3.0 branch for now

@jtroo
Copy link
Owner Author

jtroo commented Feb 25, 2023

Closing as completed

@jtroo jtroo closed this as completed Feb 25, 2023
@gerhard-h
Copy link
Contributor

played around with the feature

  • powershell was very laggy before I used -NoProfile
    (cmd-output-keys powershell.exe -NoProfile -Command "echo '(' ((Get-Date -Format 'yyyy-MM-dd').toCharArray() -join ' ') ')'")

  • many windows user may have bash installed already by means of git and it works pretty well.
    (cmd-output-keys bash -c "date +'(%F)' | sed 's/./& /g'")

  • but cmd is still the speed winner :)

@SETLOCAL EnableDelayedExpansion 
@set DT=
@for /f "tokens=1-3 delims=. " %%a in ('date /T') do @set DT=%%c%%b%%a 
@echo ( %DT:~0,1% %DT:~1,1% %DT:~2,1% %DT:~3,1% - %DT:~4,1% %DT:~5,1% - %DT:~6,1% %DT:~7,1% )
  • finaly not using the new feature
    (cmd "...\AutoHotkey\AutoHotkeyU64_UIA.exe" "isodate.ahk")
    with
FormatTime, TimeString,, yyyy-MM-dd
Send, %TimeString%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants