Twice a week I compile a shopping list, mostly for our local supermarket, but also for some smaller stores. Getting the finished list the easiest way to my phone was a thing that I wanted to automate for a long time.
The normal way to communicate between my mobile phone and the computer is via Nextcloud. I run an instance of it on a server, and use it for syncing my contacts, calendars, images and notes. I used those notes mostly for writing thoughts or remebering things that I needed later. But I never thought of "sending" notes to myself.
But I found that to be the best way to get me "information at the fingertip" right when I need them. So I decided to send me the shoppinglist right before I go shopping. A usual shopping list for 3 recipes looks like this
| Backpulver | 3 | Tl | | Basilikumblätter | 1 | Handvoll | | Basmatireis | 2 | Tassen | | Datteltomaten | 150 | g | | Eier | 2 | St | | Fenchel | 1 | Knolle | | Feta-Käse | 200 | g | | Knoblauch | 1 | Zehe | | Knoblauchzehen | 2 | Zehen | | Lauchzwiebeln | 4 | St | | Mangochutney | 3 | Tl | | Mini-Mozzarella | 125 | g | | Möhren | 8 | St | | Olivenöl | 6 | El | | Olivenöl | 2 | El | | Olivenöl | 4 | El | | Oregano | 2 | Tl | | Oregano | 1 | Prise | | Paprikapulver | 1 | Tl | | Paprikaschoten | 2 | St | | Pellkartoffeln | 450 | g | | Petersilie | etwas | Deko | | Rosmarin | 1 | Tl | | Sahnequark | 100 | g | | Zucchini | 1 | St | | Zwiebeln | 1 | St | | Zwiebeln | 2 | St |
For better readability I already did something, that I do when I'm still at home. I delete all the rows of things that I have already at home, like salt, pepper, milk, flour, etc. Whenever I run out of it I put it on that list immediatly. How I get to these list will be the scope of another article in the future.
To get my list to the phone I decided to just mark the region of the file that I want to send it to my phone and press a button that is bound to an elisp script. The script reads:
(defun shoppinglist (&optional b e) (interactive "r") (append-to-file b e "~/cloud/Notes/Shoppinglist.txt"))
- The first line defines a function named 'shoppinglist' which takes 2 parameters for beginn and end of the marked region.
- The second line is important because I want to use this function in a manual call by a hotkey. So the 'r' after interactive fills the region parameters 'b' and 'e' of the function with the respective values.
- The tird line after all appends the marked lines to the end of the Shoppinglist file.
As soon as nextcloud recognises, that a file in the 'cloud' folder has changed it synchronizes it to all devices including my mobile phone, and voila: