どのように私は最も使用されるtimedateマクロ
なぜ?
私はたくさん書いた.私の文章では、タイムスタンプ、日付、時刻、時間の範囲を使用します.
私は以下のdatetime形式を使います
bashスクリプトの例
#!/bin/sh
alias setclip='xclip -selection c'
alias getclip='xclip -selection clipboard -o'
printf $(date +"%Y-%m-%d") | setclip
最初は、私は本当に幸せでしたが、カスタムスクリプトのいくつかの時間数が増加した後.私は彼らを思い出すと苦労した.どうやって?
私はつまずいたUlauncher そして、私はこれらのtimedateスクリプトのために拡張を作成することができたことを私に下ろします.
知らない人に.Ulauncher 多くの開発者が多くの拡張子を書くアプリケーションランチャーです.
いくつかの例
マイエクステンション
Ulauncherには拡張子が必要ですmanifest.json
操作するファイル.
例manifest.json
{
"required_api_version": "^2.0.0",
"name": "Timestamp macros",
"description": "Copy to clipboard the most used timedate formats",
"developer_name": "Nurgazy Nazhimidinov",
"icon": "images/icon.png",
"options": {
"query_debounce": 0.05
},
"preferences": [
{
"id": "time_kw",
"type": "keyword",
"name": "Timemacros",
"default_value": "tm"
}
]
}
それは、あなたがキーワードTimeMedisを書くならば、拡大がLauncherの上にあると言います.
あなたがTimeMedisとクリックを書くならば
or
tmとSPACE
, then KeywordQueryEventListener(EventListener)
が呼び出される.
以下がコードです.
class DemoExtension(Extension):
def __init__(self):
super(DemoExtension, self).__init__()
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
class KeywordQueryEventListener(EventListener):
def on_event(self, event, extension):
items = []
logger.info('preferences %s' % json.dumps(extension.preferences))
logger.info(event.get_keyword()) # gives the keyword 'tm'
items.append(ExtensionResultItem(icon='images/icon.png',
name='YYYY-MM-DD',
description='{0:%Y-%m-%d}'.format(datetime.datetime.now()),
on_enter=CopyToClipboardAction('{0:%Y-%m-%d}'.format(datetime.datetime.now()))))
items.append(ExtensionResultItem(icon='images/icon.png',
name='HH:mm',
description='{0:%H:%M}'.format(datetime.datetime.now()),
on_enter=CopyToClipboardAction(
'{0:%H:%M}'.format(datetime.datetime.now()))))
items.append(ExtensionResultItem(icon='images/icon.png',
name='YYYY-MM-DD HH:mm',
description='{0:%Y-%m-%d %H:%M}'.format(datetime.datetime.now()),
on_enter=CopyToClipboardAction(
'{0:%Y-%m-%d %H:%M}'.format(datetime.datetime.now()))))
return RenderResultListAction(items)
if __name__ == '__main__':
DemoExtension().run()
ご覧の通りKeywordQueryEventListener(EventListener)
and on_event
が実行されRenderResultListAction(items)
を返します.
我々items
であろう
{
"required_api_version": "^2.0.0",
"name": "Timestamp macros",
"description": "Copy to clipboard the most used timedate formats",
"developer_name": "Nurgazy Nazhimidinov",
"icon": "images/icon.png",
"options": {
"query_debounce": 0.05
},
"preferences": [
{
"id": "time_kw",
"type": "keyword",
"name": "Timemacros",
"default_value": "tm"
}
]
}
class DemoExtension(Extension):
def __init__(self):
super(DemoExtension, self).__init__()
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
class KeywordQueryEventListener(EventListener):
def on_event(self, event, extension):
items = []
logger.info('preferences %s' % json.dumps(extension.preferences))
logger.info(event.get_keyword()) # gives the keyword 'tm'
items.append(ExtensionResultItem(icon='images/icon.png',
name='YYYY-MM-DD',
description='{0:%Y-%m-%d}'.format(datetime.datetime.now()),
on_enter=CopyToClipboardAction('{0:%Y-%m-%d}'.format(datetime.datetime.now()))))
items.append(ExtensionResultItem(icon='images/icon.png',
name='HH:mm',
description='{0:%H:%M}'.format(datetime.datetime.now()),
on_enter=CopyToClipboardAction(
'{0:%H:%M}'.format(datetime.datetime.now()))))
items.append(ExtensionResultItem(icon='images/icon.png',
name='YYYY-MM-DD HH:mm',
description='{0:%Y-%m-%d %H:%M}'.format(datetime.datetime.now()),
on_enter=CopyToClipboardAction(
'{0:%Y-%m-%d %H:%M}'.format(datetime.datetime.now()))))
return RenderResultListAction(items)
if __name__ == '__main__':
DemoExtension().run()
コード:
items.append(ExtensionResultItem(icon='images/icon.png',
name='YYYY-MM-DD',
description='{0:%Y-%m-%d}'.format(datetime.datetime.now()),
on_enter=CopyToClipboardAction('{0:%Y-%m-%d}'.format(datetime.datetime.now()))))
説明ExtensionResultItem
: name
- ユーザーに表示されるタイトルdescription
- また、上記のスクリーンショットを見てくださいon_enter
- 最も重要な部分は、ユーザーがこの項目をクリックするかどうかを言います.私の場合はCopyToClipboardAction
クリップボードにデータをコピーするアクション.概要
最後に、私は私のカスタムbashスクリプトを破棄し、それらのためのキーボードショートカットを忘れて有効になって拡張機能を開発した.
Source code on Github
スクリプトの廃止😄
From personal blog: https://www.nurgasemetey.com/2020/extension-ulauncher/
Reference
この問題について(どのように私は最も使用されるtimedateマクロ), 我々は、より多くの情報をここで見つけました
https://dev.to/nurgasemetey/how-i-wrote-ulauncher-extension-for-most-used-timedate-macros-c5i
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
From personal blog: https://www.nurgasemetey.com/2020/extension-ulauncher/
Reference
この問題について(どのように私は最も使用されるtimedateマクロ), 我々は、より多くの情報をここで見つけました https://dev.to/nurgasemetey/how-i-wrote-ulauncher-extension-for-most-used-timedate-macros-c5iテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol