-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: add ability to customize refformat
This feature is still in development, and is being put on the backburner for now due to limitations of Alfred 5.5's Text View. For more details, see: <https://www.alfredforum.com/topic/21708-pre-populating-a-text-views-script-input-field-with-an-initial-value/>
- Loading branch information
Showing
4 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
# coding=utf-8 | ||
|
||
import json | ||
import os | ||
import re | ||
|
||
import yvs.core as core | ||
import yvs.filter_prefs as filter_prefs | ||
|
||
|
||
def main(variables): | ||
ref = core.get_ref("111/jhn.11.35", core.get_default_user_prefs()) | ||
ref_format = json.loads(variables["value_id"]) | ||
print( | ||
json.dumps( | ||
{ | ||
"response": re.sub( | ||
r"\s*¬\s*", | ||
"\n", | ||
filter_prefs.get_ref_format_value(ref_format, ref)["name"], | ||
), | ||
"footer": " · ".join( | ||
( | ||
"Press enter to confirm {}".format(variables["pref_name"]), | ||
"⎋ Return to results", | ||
) | ||
), | ||
"behaviour": { | ||
"response": "replace", | ||
"scroll": "auto", | ||
}, | ||
} | ||
) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main( | ||
{ | ||
"pref_id": os.environ["pref_id"], | ||
"pref_name": os.environ["pref_name"], | ||
"value_id": os.environ["value_id"], | ||
"value_name": os.environ["value_name"], | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# The Alfred 5.5 Text View can only run an executable script as input; it cannot | ||
# execute arbitrary script code, which we ultimately need to do so we can run | ||
# the yvs.customize_refformat as a module; therefore, this intermediate shell | ||
# script is necessary to run yvs.customize_refformat in the proper module | ||
# context | ||
/usr/bin/python3 -m yvs.customize_refformat "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters