Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Espanso temperature C/°F conversion
- # From conversation at: https://discord.com/channels/884163483409731584/1013914627886817372/1253000300730515508
- # Usage: ::10C → 10C / 50.00°F or ::10F → 10°F / -12.22C
- - regex: ::(?P<value>\d+)(?P<unit>[C,F])
- replace: "{{output}}"
- vars:
- - name: output
- type: script
- params:
- args:
- - python
- - -c
- - |
- import sys
- sys.stdout.reconfigure(encoding='utf-8') # May be necessary if "°" doesn't render
- if "{{unit}}" == "C":
- conv_value = {{value}} * 9 / 5 + 32
- print(f"{{{value}}}C / {conv_value:.2f}°F")
- else:
- conv_value = ({{value}} - 32) * 5 / 9
- print(f"{{{value}}}°F / {conv_value:.2f}C")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement