Appending text to a text file

Hi. I’m a KWGT newbie and I am looking TO append text to an existing file when the widget is touched. Could a kind soul provide a sample or briefly explain what needs to be done? I have already created the file and given permissions to kwgt.

Thanks in advance.

Gary, NJ

KWGT itself cannot append text to a file. It can read files, but it has no native way to modify or append content.To achieve this, you need an external automation app like Tasker.

Thx much. That saves me a lot of debugging.

Also, different subject - I have downloaded and applied the reflecting clock widget and it works and looks great. Is it possible to change the time format from hh:mm to h:mm?

Glad I could help.

To change the format and remove the leading zero, find the time formula and use this:

For 12-hour format (e.g., 8:15): Use $df(h:mm)$

For 12-hour format with AM/PM (e.g., 8:15 AM): Use $df(h:mm a)$

Make sure your Kustom settings (or system settings) are set to 12-hour mode.

Thx, actually, I don’t see the text element, see attached.

Oh wow, it’s really nice to see people using my komponents on their screens!:+1:

This komponent is made from images, not text, so unfortunately you can’t modify it yourself.

I added the leading zero on purpose to keep the clock design proportional.

I might create a version without the leading zero when I have time.

If you’re interested, keep an eye on updates in my Telegram — the link is in my profile

You can try using something like this:

sh("echo '" + "your text here" + "' >> /sdcard/Kustom/subfolder/your-filename.txt")

Android changed how storage access works, I don’t know if this still works, but if it does you have to do it in a subfolder of the Kustom folder (the one you selected in the app). Shell also only works with ASCII characters, so emojis or funny accented letters won’t work.

1 Like

Thx thetored, I will ck it out.

G

Thx Max, and I totally get the HH:MM for balance. But, if you were to tweak it to H:MM, I’d be all in. Terrific job, btw.

Thx again.
Gary

Thanks a lot for the kind words, I really appreciate it.

About the SH method from thetored I didn’t suggest it because on Android 15 my HyperOS Kustom doesn’t even have the required file‑access permissions anymore, so it can’t reliably write anything. That’s why I mentioned Tasker instead, since it still works consistently.

But if you’re on an older Android version, you can definitely try the SH approach…

1 Like

Honestly, it’s wild what we can get Kustom to do with a little bit of shell scripting. Appending text sounds simple, but getting the formatting right in a text file can be a headache.