版本v0.1.1 ----1、新增显示输入法状态的功能;2、新增时间同步功能;3、新增翻译功能;4、新增咖啡因功能;5、新增屏幕取色功能;6、新增菜单栏管理

This commit is contained in:
sugood
2020-10-24 23:17:20 +08:00
parent 7352b399f4
commit a75843b3a2
27 changed files with 3006 additions and 13 deletions
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/.hammerspoon.iml" filepath="$PROJECT_DIR$/.idea/.hammerspoon.iml" />
</modules>
</component>
</project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+878
View File
@@ -0,0 +1,878 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="495daa03-3ea5-4e8c-9013-c532511d508b" name="Default" comment="">
<change beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
<change beforePath="" afterPath="$PROJECT_DIR$/data/config.json" />
<change beforePath="" afterPath="$PROJECT_DIR$/data/dictHistory.json" />
<change beforePath="" afterPath="$PROJECT_DIR$/icon/caffeine-off.pdf" />
<change beforePath="" afterPath="$PROJECT_DIR$/icon/caffeine-on.pdf" />
<change beforePath="" afterPath="$PROJECT_DIR$/modules/caffeine.lua" />
<change beforePath="" afterPath="$PROJECT_DIR$/modules/commons.lua" />
<change beforePath="" afterPath="$PROJECT_DIR$/modules/jsonFormat.lua" />
<change beforePath="$PROJECT_DIR$/data/history.json" afterPath="$PROJECT_DIR$/data/history.json" />
<change beforePath="$PROJECT_DIR$/init.lua" afterPath="$PROJECT_DIR$/init.lua" />
<change beforePath="$PROJECT_DIR$/modules/hotkey.lua" afterPath="$PROJECT_DIR$/modules/hotkey.lua" />
<change beforePath="$PROJECT_DIR$/modules/snippet.lua" afterPath="$PROJECT_DIR$/modules/snippet.lua" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="inputstat.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/modules/inputstat.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="48" lean-forward="false" selection-start-line="3" selection-start-column="48" selection-end-line="3" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="init.lua" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/init.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="21" lean-forward="true" selection-start-line="10" selection-start-column="21" selection-end-line="10" selection-end-column="21" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="hotkey.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/modules/hotkey.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="8" lean-forward="false" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="8" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="dict.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/modules/dict.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="48" lean-forward="false" selection-start-line="3" selection-start-column="48" selection-end-line="3" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="commons.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/modules/commons.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1980">
<caret line="132" column="39" lean-forward="false" selection-start-line="132" selection-start-column="39" selection-end-line="132" selection-end-column="39" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="history.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/data/history.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="859">
<caret line="144" column="4" lean-forward="false" selection-start-line="144" selection-start-column="4" selection-end-line="144" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="dictHistory.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/data/dictHistory.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="1" lean-forward="true" selection-start-line="2" selection-start-column="1" selection-end-line="2" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/data/config.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="1" lean-forward="true" selection-start-line="11" selection-start-column="1" selection-end-line="11" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="caffeine.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/modules/caffeine.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="48" lean-forward="false" selection-start-line="2" selection-start-column="48" selection-end-line="2" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="reload.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/modules/reload.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="0" lean-forward="false" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="NewLua" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>SubStringGetByteCount</find>
<find>historyPath</find>
<find>translation</find>
<find>hs.json</find>
<find>setState</find>
<find>isEm</find>
<find>webview</find>
<find>console.clearConsole()</find>
<find>menubar</find>
<find>config</find>
<find>menubar.new(true)</find>
<find>searchResult</find>
<find>keywords</find>
<find>hs.hotkey.bind</find>
<find>hs.hotkey</find>
<find>displayIdle</find>
<find>syntaxHighlight</find>
<find>hs.alert.show</find>
<find>切换</find>
<find>isSyncTime</find>
<find>hs.dialog</find>
<find>else if</find>
<find>elseif</find>
<find>colorDialog</find>
<find>appid</find>
<find>mChooser</find>
<find>baiduAppSecret</find>
<find>baiduAppid</find>
<find>hs.dialog.blockAlert</find>
<find>ydAppKey</find>
</findStrings>
<replaceStrings>
<replace>self.menubar</replace>
<replace>macMenubar</replace>
</replaceStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GradleLocalSettings">
<option name="externalProjectsViewState">
<projects_view />
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/timesync/timesync.sh" />
<option value="$PROJECT_DIR$/modules/LuaJson.lua" />
<option value="$PROJECT_DIR$/modules/system.lua" />
<option value="$PROJECT_DIR$/modules/colorpicker.lua" />
<option value="$PROJECT_DIR$/modules/colorPicker.lua" />
<option value="$PROJECT_DIR$/Spoons/KSheet.spoon/init.lua" />
<option value="$PROJECT_DIR$/modules/utils.lua" />
<option value="$PROJECT_DIR$/modules/caffine.lua" />
<option value="$PROJECT_DIR$/modules/hotkey.lua" />
<option value="$PROJECT_DIR$/modules/jsonFormat.lua" />
<option value="$PROJECT_DIR$/modules/snippet.lua" />
<option value="$PROJECT_DIR$/modules/dict1.lua" />
<option value="$PROJECT_DIR$/modules/dict2.lua" />
<option value="$PROJECT_DIR$/init.lua" />
<option value="$PROJECT_DIR$/data/history.json" />
<option value="$PROJECT_DIR$/modules/caffeine.lua" />
<option value="$PROJECT_DIR$/modules/dict.lua" />
<option value="$PROJECT_DIR$/modules/inputstat.lua" />
<option value="$PROJECT_DIR$/modules/timesync.lua" />
<option value="$PROJECT_DIR$/data/config.json" />
<option value="$PROJECT_DIR$/modules/commons.lua" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1920" />
<option name="height" value="1009" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name=".hammerspoon" type="b2602c69:ProjectViewProjectNode" />
<item name=".hammerspoon" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name=".hammerspoon" type="b2602c69:ProjectViewProjectNode" />
<item name=".hammerspoon" type="462c0819:PsiDirectoryNode" />
<item name="data" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name=".hammerspoon" type="b2602c69:ProjectViewProjectNode" />
<item name=".hammerspoon" type="462c0819:PsiDirectoryNode" />
<item name="modules" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scratches" />
<pane id="AndroidView" />
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/data" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/modules" />
<recent name="$PROJECT_DIR$/icon" />
<recent name="$PROJECT_DIR$/data" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration default="true" type="Applet" factoryName="Applet">
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<module />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
</configuration>
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
<module name="" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
<option name="PROGRAM_PARAMETERS" />
<predefined_log_file id="idea.log" enabled="true" />
</configuration>
<configuration name="timesync.lua" type="lua.app" factoryName="Lua Application" temporary="true">
<option name="program" value="lua" />
<option name="file" value="$PROJECT_DIR$/modules/timesync.lua" />
<option name="workingDir" value="" />
<option name="debuggerType" value="2" />
<option name="params" value="" />
<option name="charset" value="UTF-8" />
<option name="showConsole" value="true" />
</configuration>
<recent_temporary>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Lua Application.timesync.lua" />
</list>
</recent_temporary>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="495daa03-3ea5-4e8c-9013-c532511d508b" name="Default" comment="" />
<created>1602820978741</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1602820978741</updated>
<workItem from="1602820980264" duration="616000" />
<workItem from="1602821729128" duration="86000" />
<workItem from="1602821832919" duration="32183000" />
<workItem from="1602822925699" duration="14000" />
<workItem from="1602822943319" duration="1000" />
<workItem from="1602822966566" duration="642000" />
<workItem from="1602910724222" duration="3375000" />
<workItem from="1602916148688" duration="33848000" />
<workItem from="1603074238740" duration="59948000" />
<workItem from="1603457165086" duration="40772000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="171485000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1920" height="1009" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="LuaCheck" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="4" />
</breakpoint-manager>
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/modules/windows.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
<caret line="18" column="32" lean-forward="false" selection-start-line="18" selection-start-column="32" selection-end-line="18" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/snippet.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2415">
<caret line="161" column="37" lean-forward="false" selection-start-line="161" selection-start-column="37" selection-end-line="161" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/timesync/timesync.sh">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="13" column="4" lean-forward="true" selection-start-line="13" selection-start-column="4" selection-end-line="13" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/history.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1950">
<caret line="130" column="54" lean-forward="true" selection-start-line="130" selection-start-column="54" selection-end-line="130" selection-end-column="54" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/init.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="0" lean-forward="true" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/launcher.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="465">
<caret line="31" column="39" lean-forward="false" selection-start-line="31" selection-start-column="39" selection-end-line="31" selection-end-column="39" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/reload.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="21" lean-forward="false" selection-start-line="4" selection-start-column="9" selection-end-line="4" selection-end-column="21" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/system.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/timesync/timesync.sh">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="0" lean-forward="true" selection-start-line="6" selection-start-column="0" selection-end-line="6" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/timesync.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="60" lean-forward="false" selection-start-line="5" selection-start-column="60" selection-end-line="5" selection-end-column="60" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/windows.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
<caret line="18" column="32" lean-forward="true" selection-start-line="18" selection-start-column="32" selection-end-line="18" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/snippet.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2415">
<caret line="161" column="37" lean-forward="true" selection-start-line="161" selection-start-column="37" selection-end-line="161" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/inputstat.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="0" lean-forward="true" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/init.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/dict.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/hotkey.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="29" lean-forward="false" selection-start-line="3" selection-start-column="29" selection-end-line="3" selection-end-column="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/launcher.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="420">
<caret line="28" column="19" lean-forward="false" selection-start-line="28" selection-start-column="19" selection-end-line="28" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/system.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/timesync.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="9" lean-forward="false" selection-start-line="4" selection-start-column="9" selection-end-line="4" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/snippet.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" column="9" lean-forward="false" selection-start-line="9" selection-start-column="9" selection-end-line="9" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/timesync/timesync.sh">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="14" column="4" lean-forward="true" selection-start-line="14" selection-start-column="4" selection-end-line="14" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/init.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="0" lean-forward="true" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/dict.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/hotkey.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="29" lean-forward="true" selection-start-line="3" selection-start-column="29" selection-end-line="3" selection-end-column="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/LuaJson.lua" />
<entry file="file://$PROJECT_DIR$/timesync/timesync.sh">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="0" lean-forward="false" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Spoons/ColorPicker.spoon/docs.json" />
<entry file="file://$PROJECT_DIR$/Spoons/ColorPicker.spoon/init.lua" />
<entry file="file://$PROJECT_DIR$/Spoons/SpoonInstall.spoon/init.lua" />
<entry file="file://$PROJECT_DIR$/Spoons/KSheet.spoon/init.lua" />
<entry file="file://$PROJECT_DIR$/Spoons/Caffeine.spoon/docs.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1022">
<caret line="23" column="24" lean-forward="true" selection-start-line="23" selection-start-column="24" selection-end-line="23" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Spoons/Caffeine.spoon/init.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="630">
<caret line="42" column="31" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="119" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="jar://$APPLICATION_PLUGINS_DIR$/intellij-emmylua/lib/intellij-emmylua-1.3.2.142-IDEA172.jar!/std/Lua53/debug.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1110">
<caret line="74" column="15" lean-forward="false" selection-start-line="74" selection-start-column="15" selection-end-line="74" selection-end-column="15" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/colorPicker.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1938">
<caret line="22" column="49" lean-forward="false" selection-start-line="22" selection-start-column="49" selection-end-line="22" selection-end-column="49" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/dict.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="900">
<caret line="60" column="18" lean-forward="true" selection-start-line="60" selection-start-column="18" selection-end-line="60" selection-end-column="18" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/snippet.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1230">
<caret line="82" column="37" lean-forward="true" selection-start-line="82" selection-start-column="37" selection-end-line="82" selection-end-column="37" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/system.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="25" lean-forward="true" selection-start-line="17" selection-start-column="25" selection-end-line="17" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/windows.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="18" column="32" lean-forward="false" selection-start-line="18" selection-start-column="32" selection-end-line="18" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/timesync.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="570">
<caret line="38" column="15" lean-forward="true" selection-start-line="38" selection-start-column="15" selection-end-line="38" selection-end-column="15" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/launcher.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="30" column="19" lean-forward="false" selection-start-line="30" selection-start-column="19" selection-end-line="30" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/jsonFormat.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="23" lean-forward="true" selection-start-line="2" selection-start-column="23" selection-end-line="2" selection-end-column="50" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/hotkey.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="8" lean-forward="false" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="8" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/dict.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="48" lean-forward="false" selection-start-line="3" selection-start-column="48" selection-end-line="3" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/caffeine.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="48" lean-forward="false" selection-start-line="2" selection-start-column="48" selection-end-line="2" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/reload.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="0" lean-forward="false" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/history.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="859">
<caret line="144" column="4" lean-forward="false" selection-start-line="144" selection-start-column="4" selection-end-line="144" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/dictHistory.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="1" lean-forward="true" selection-start-line="2" selection-start-column="1" selection-end-line="2" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/config.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="1" lean-forward="true" selection-start-line="11" selection-start-column="1" selection-end-line="11" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/commons.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1980">
<caret line="132" column="39" lean-forward="false" selection-start-line="132" selection-start-column="39" selection-end-line="132" selection-end-column="39" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/inputstat.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="48" lean-forward="false" selection-start-line="3" selection-start-column="48" selection-end-line="3" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/init.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="21" lean-forward="true" selection-start-line="10" selection-start-column="21" selection-end-line="10" selection-end-column="21" />
<folding />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+143
View File
@@ -0,0 +1,143 @@
[
{
"Command": [],
"Constant": [],
"Constructor": [],
"Deprecated": [],
"Field": [],
"Function": [],
"Method": [
{
"def": "Caffeine:bindHotkeys(mapping)",
"desc": "Binds hotkeys for Caffeine",
"doc": "Binds hotkeys for Caffeine\n\nParameters:\n * mapping - A table containing hotkey modifier/key details for the following items:\n * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic\n\nReturns:\n * The Caffeine object",
"name": "bindHotkeys",
"parameters": [
" * mapping - A table containing hotkey modifier/key details for the following items:",
" * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic"
],
"returns": [
" * The Caffeine object"
],
"signature": "Caffeine:bindHotkeys(mapping)",
"stripped_doc": "",
"type": "Method"
},
{
"def": "Caffeine:setState(on)",
"desc": "Sets whether or not caffeination should be enabled",
"doc": "Sets whether or not caffeination should be enabled\n\nParameters:\n * on - A boolean, true if screens should be kept awake, false to let macOS send them to sleep\n\nReturns:\n * None",
"name": "setState",
"parameters": [
" * on - A boolean, true if screens should be kept awake, false to let macOS send them to sleep"
],
"returns": [
" * None"
],
"signature": "Caffeine:setState(on)",
"stripped_doc": "",
"type": "Method"
},
{
"def": "Caffeine:start()",
"desc": "Starts Caffeine",
"doc": "Starts Caffeine\n\nParameters:\n * None\n\nReturns:\n * The Caffeine object",
"name": "start",
"parameters": [
" * None"
],
"returns": [
" * The Caffeine object"
],
"signature": "Caffeine:start()",
"stripped_doc": "",
"type": "Method"
},
{
"def": "Caffeine:stop()",
"desc": "Stops Caffeine",
"doc": "Stops Caffeine\n\nParameters:\n * None\n\nReturns:\n * The Caffeine object",
"name": "stop",
"parameters": [
" * None"
],
"returns": [
" * The Caffeine object"
],
"signature": "Caffeine:stop()",
"stripped_doc": "",
"type": "Method"
}
],
"Variable": [],
"desc": "Prevent the screen from going to sleep",
"doc": "Prevent the screen from going to sleep\nDownload: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip)",
"items": [
{
"def": "Caffeine:bindHotkeys(mapping)",
"desc": "Binds hotkeys for Caffeine",
"doc": "Binds hotkeys for Caffeine\n\nParameters:\n * mapping - A table containing hotkey modifier/key details for the following items:\n * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic\n\nReturns:\n * The Caffeine object",
"name": "bindHotkeys",
"parameters": [
" * mapping - A table containing hotkey modifier/key details for the following items:",
" * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic"
],
"returns": [
" * The Caffeine object"
],
"signature": "Caffeine:bindHotkeys(mapping)",
"stripped_doc": "",
"type": "Method"
},
{
"def": "Caffeine:setState(on)",
"desc": "Sets whether or not caffeination should be enabled",
"doc": "Sets whether or not caffeination should be enabled\n\nParameters:\n * on - A boolean, true if screens should be kept awake, false to let macOS send them to sleep\n\nReturns:\n * None",
"name": "setState",
"parameters": [
" * on - A boolean, true if screens should be kept awake, false to let macOS send them to sleep"
],
"returns": [
" * None"
],
"signature": "Caffeine:setState(on)",
"stripped_doc": "",
"type": "Method"
},
{
"def": "Caffeine:start()",
"desc": "Starts Caffeine",
"doc": "Starts Caffeine\n\nParameters:\n * None\n\nReturns:\n * The Caffeine object",
"name": "start",
"parameters": [
" * None"
],
"returns": [
" * The Caffeine object"
],
"signature": "Caffeine:start()",
"stripped_doc": "",
"type": "Method"
},
{
"def": "Caffeine:stop()",
"desc": "Stops Caffeine",
"doc": "Stops Caffeine\n\nParameters:\n * None\n\nReturns:\n * The Caffeine object",
"name": "stop",
"parameters": [
" * None"
],
"returns": [
" * The Caffeine object"
],
"signature": "Caffeine:stop()",
"stripped_doc": "",
"type": "Method"
}
],
"name": "Caffeine",
"stripped_doc": "Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip)",
"submodules": [],
"type": "Module"
}
]
+119
View File
@@ -0,0 +1,119 @@
--- === Caffeine ===
---
--- Prevent the screen from going to sleep
--- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/Caffeine.spoon.zip)
local obj = { __gc = true }
--obj.__index = obj
setmetatable(obj, obj)
obj.__gc = function(t)
t:stop()
end
-- Metadata
obj.name = "Caffeine"
obj.version = "1.0"
obj.author = "Chris Jones <cmsj@tenshu.net>"
obj.homepage = "https://github.com/Hammerspoon/Spoons"
obj.license = "MIT - https://opensource.org/licenses/MIT"
obj.menuBarItem = nil
obj.hotkeyToggle = nil
-- Internal function used to find our location, so we know where to load files from
local function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)")
end
obj.spoonPath = script_path()
function obj:init()
end
--- Caffeine:bindHotkeys(mapping)
--- Method
--- Binds hotkeys for Caffeine
---
--- Parameters:
--- * mapping - A table containing hotkey modifier/key details for the following items:
--- * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic
---
--- Returns:
--- * The Caffeine object
function obj:bindHotkeys(mapping)
if (self.hotkeyToggle) then
self.hotkeyToggle:delete()
end
local toggleMods = mapping["toggle"][1]
local toggleKey = mapping["toggle"][2]
self.hotkeyToggle = hs.hotkey.new(toggleMods, toggleKey, function() self.clicked() end)
return self
end
--- Caffeine:start()
--- Method
--- Starts Caffeine
---
--- Parameters:
--- * None
---
--- Returns:
--- * The Caffeine object
function obj:start()
if self.menuBarItem then self:stop() end
self.menuBarItem = hs.menubar.new()
self.menuBarItem:setClickCallback(self.clicked)
if (self.hotkeyToggle) then
self.hotkeyToggle:enable()
end
self.setDisplay(hs.caffeinate.get("displayIdle"))
return self
end
--- Caffeine:stop()
--- Method
--- Stops Caffeine
---
--- Parameters:
--- * None
---
--- Returns:
--- * The Caffeine object
function obj:stop()
if self.menuBarItem then self.menuBarItem:delete() end
if (self.hotkeyToggle) then
self.hotkeyToggle:disable()
end
self.menuBarItem = nil
return self
end
function obj.setDisplay(state)
local result
if state then
result = obj.menuBarItem:setIcon(obj.spoonPath.."/caffeine-on.pdf")
else
result = obj.menuBarItem:setIcon(obj.spoonPath.."/caffeine-off.pdf")
end
end
function obj.clicked()
obj.setDisplay(hs.caffeinate.toggle("displayIdle"))
end
--- Caffeine:setState(on)
--- Method
--- Sets whether or not caffeination should be enabled
---
--- Parameters:
--- * on - A boolean, true if screens should be kept awake, false to let macOS send them to sleep
---
--- Returns:
--- * None
function obj:setState(on)
hs.caffeinate.set("displayIdle", on)
obj.setDisplay(on)
end
return obj
+12
View File
@@ -0,0 +1,12 @@
[
{
"youdaoAppid" : "",
"youdaoAppSecret" : "",
"dictEngine" : "百度",
"isSyncTime" : "off",
"rootPassword" : "",
"caffeine" : "off",
"baiduAppSecret" : "eI3BLUVURG5Zzb8Tdgdm",
"baiduAppid" : "20201017000591957"
}
]
+3
View File
@@ -0,0 +1,3 @@
[
]
+12
View File
@@ -1,4 +1,12 @@
[
{
"subText" : "chrome:\/\/inspect",
"text" : "chrome:\/\/inspect"
},
{
"subText" : "chrome:\/\/version\/",
"text" : "chrome:\/\/version\/"
},
{
"subText" : "cmd|cat filename|显示或连接文件",
"text" : "cat"
@@ -127,6 +135,10 @@
"subText" : "cmd|vi ~\/.bash_profile|修改环境变量",
"text" : "vi ~\/.bash_profile"
},
{
"subText" : "cmd|which python|查看指令的路径",
"text" : "which"
},
{
"subText" : "code|java|author注释模板",
"text" : "\/** \n* @Title: ${file_name} \n* @Package ${package_name} \n* @Description: ${todo}(用一句话描述该文件做什么) \n* @author sugood\n* @date ${date} ${time} \n* @version V1.0 \n*\/"
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+9 -3
View File
@@ -1,9 +1,15 @@
hs.configdir = os.getenv('HOME') .. '/.hammerspoon'
package.path = hs.configdir .. '/?.lua;' .. hs.configdir .. '/?/init.lua;' .. hs.configdir .. '/Spoons/?.spoon/init.lua;' .. package.path
require "modules/reload"
require "modules/commons"
require "modules/hotkey"
require "modules/system"
require "modules/windows"
require "modules/launcher"
require "modules/snippet"
-- 监听~./hammerspoon/data/中的文件,如果有改变就自动更新
hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/data", hs.reload):start()
require "modules/timesync"
require "modules/inputstat"
require "modules/dict"
require "modules/jsonFormat"
require "modules/caffeine"
+16
View File
@@ -0,0 +1,16 @@
---
--- 控制空闲时是否允许屏幕睡眠
--- Created by sugood(https://github.com/sugood).
--- DateTime: 2020/10/24 14:13
---
if config ~=nil and config[1].caffeine == 'on' then
print("设置状态栏")
local menuBarItem = hs.menubar.new()
menuBarItem:setTitle("")
menuBarItem:setIcon("~/.hammerspoon/icon/caffeine-on.pdf")
hs.caffeinate.set("displayIdle", true)
else
hs.caffeinate.set("displayIdle", false)
end
+226
View File
@@ -0,0 +1,226 @@
---
--- 公共函数
--- Created by sugood(https://github.com/sugood).
--- DateTime: 2020/10/24 14:13
---
local console = require("hs.console")
version = "v0.1.1"
configPath= "~/.hammerspoon/data/config.json"
config = {}
colorDialog = hs.dialog.color
function switchDict()
if config[1].dictEngine == '百度' then
config[1].dictEngine = '有道'
else
config[1].dictEngine = '百度'
end
hs.json.write(config,configPath, true, true)
hs.reload()
end
function switchTime()
if config[1].isSyncTime == 'on' then
config[1].isSyncTime = 'off'
else
if(stringIsEmpty(config[1].rootPassword)) then
local result,subText = hs.dialog.textPrompt("输入开机密码", "时间同步操作需要开机密码", '', "确定", "取消", true)
if result == "确定" and stringIsEmpty(subText) == false then
config[1].rootPassword = subText
config[1].isSyncTime = 'on'
end
else
config[1].isSyncTime = 'on'
end
end
hs.json.write(config,configPath, true, true)
hs.reload()
end
function switchCaffeine()
if config[1].caffeine == 'on' then
config[1].caffeine = 'off'
else
config[1].caffeine = 'on'
end
hs.json.write(config,configPath, true, true)
hs.reload()
end
--设置全局菜单栏
function initMenu()
macMenubar = hs.menubar.new()
macMenubar:setTitle("")
macMenubar:setIcon()
macMenubar:setMenu( {
{ title = "Reload config", fn = function()
hs.reload()
end },
{ title = "Open console", fn = function() hs.openConsole() end },
{ title = "Relaunch", fn = function() hs.relaunch() end },
{ title = "-" },
{ title = "翻译平台:" .. config[1].dictEngine, fn = function()
if (hs.dialog.blockAlert("支持百度和有道翻译,确认切换?","有道翻译需先申请有道云API","确定","取消","informational") == "确定") then
switchDict()
end
end },
{ title = "输入appID", fn = function()
if(config[1].dictEngine == '有道') then
local result,subText = hs.dialog.textPrompt("输入appID", "请通过有道云API获取appkey", config[1].youdaoAppid, "确定", "取消", false)
if result == "确定" then
config[1].youdaoAppid = subText
hs.json.write(config,configPath, true, true)
end
elseif(config[1].dictEngine == '百度') then
local result,subText = hs.dialog.textPrompt("输入appID", "百度翻译可不修改", config[1].baiduAppid, "确定", "取消", true)
if result == "确定" then
config[1].baiduAppid = subText
hs.json.write(config,configPath, true, true)
end
end
end },
{ title = "输入appSecret", fn = function()
if(config[1].dictEngine == '有道') then
local result,subText = hs.dialog.textPrompt("输入appSecret", "请通过有道云API获取appSecret", config[1].youdaoAppSecret, "确定", "取消", false)
if result == "确定" then
config[1].youdaoAppSecret = subText
hs.json.write(config,configPath, true, true)
end
elseif(config[1].dictEngine == '百度') then
local result,subText = hs.dialog.textPrompt("输入appSecret", "百度翻译可不修改", config[1].baiduAppSecret, "确定", "取消", true)
if result == "确定" then
config[1].baiduAppSecret = subText
hs.json.write(config,configPath, true, true)
end
end
end },
{ title = "-" },
{ title = "时间同步:" .. config[1].isSyncTime, fn = function()
switchTime()
end },
{ title = "输入开机密码", fn = function()
local result,subText = hs.dialog.textPrompt("输入开机密码", "时间同步操作需要开机密码", config[1].rootPassword, "确定", "取消", true)
if result == "确定" then
config[1].rootPassword = subText
hs.json.write(config,configPath, true, true)
end
end },
{ title = "-" },
{ title = "屏幕取色", fn = function()
hs.openConsole(true)
colorDialog.show()
colorDialog.mode("RGB")
colorDialog.callback(function(a,b)
if b then
hs.closeConsole()
end
end)
hs.closeConsole()
end },
{ title = "-" },
{ title = "咖啡因:" .. config[1].caffeine, fn = function()
switchCaffeine()
end },
{ title = "-" },
{ title = "打开键盘偏好设置", fn = function() hs.osascript.applescript([[
tell application "System Preferences"
reveal anchor "InputSources" of pane "com.apple.preference.keyboard"
activate
end tell ]]
) end },
{ title = "-" },
{ title = "关于", fn = function()
if (hs.dialog.blockAlert("当前版本:"..version,"整理了一些能够提高效率的脚本,打开主页查看详细说明","确定","取消","informational") == "确定") then
hs.urlevent.openURL("https://github.com/sugood/hammerspoon")
end
end },
})
end
function initData()
if hs.json.read(configPath) ~= nil then
config = hs.json.read(configPath)
end
initMenu()
-- 修改全局alert样式
hs.alert.defaultStyle.strokeColor = {white = 1, alpha = 0}
hs.alert.defaultStyle.fillColor = {white = 0.05, alpha = 0.75}
hs.alert.defaultStyle.radius = 10
--清空打印信息
console.clearConsole()
--
colorDialog.mode("RGB")
end
initData()
-- 字符串判空
function stringIsEmpty(str)
return str == nil or str == ''
end
--生成url编码
function decodeURI(s)
s = string.gsub(s, "([^%w%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end)
return string.gsub(s, " ", "+")
end
--截取UTF8字符
function SubStringUTF8(str, startIndex, endIndex)
if startIndex < 0 then
startIndex = SubStringGetTotalIndex(str) + startIndex + 1;
end
if endIndex ~= nil and endIndex < 0 then
endIndex = SubStringGetTotalIndex(str) + endIndex + 1;
end
if endIndex == nil then
return string.sub(str, SubStringGetTrueIndex(str, startIndex));
else
return string.sub(str, SubStringGetTrueIndex(str, startIndex), SubStringGetTrueIndex(str, endIndex + 1) - 1);
end
end
--获取中英混合UTF8字符串的真实字符数量
function SubStringGetTotalIndex(str)
local curIndex = 0;
local i = 1;
local lastCount = 1;
repeat
lastCount = SubStringGetByteCount(str, i)
i = i + lastCount;
curIndex = curIndex + 1;
until(lastCount == 0);
return curIndex - 1;
end
function SubStringGetTrueIndex(str, index)
local curIndex = 0;
local i = 1;
local lastCount = 1;
repeat
lastCount = SubStringGetByteCount(str, i)
i = i + lastCount;
curIndex = curIndex + 1;
until(curIndex >= index);
return i - lastCount;
end
--返回当前字符实际占用的字符数
function SubStringGetByteCount(str, index)
local curByte = string.byte(str, index)
local byteCount = 1;
if curByte == nil then
byteCount = 0
elseif curByte > 0 and curByte <= 127 then
byteCount = 1
elseif curByte>=192 and curByte<=223 then
byteCount = 2
elseif curByte>=224 and curByte<=239 then
byteCount = 3
elseif curByte>=240 and curByte<=247 then
byteCount = 4
end
return byteCount;
end
+205
View File
@@ -0,0 +1,205 @@
---
--- 快速打开翻译,支持百度和有道翻译API
--- 有道API需要用户自行申请。
--- Created by sugood(https://github.com/sugood).
--- DateTime: 2020/10/23 11:12
---
local chooser = require("hs.chooser")
local menubar = hs.menubar.new()
local dictHistoryPath= "~/.hammerspoon/data/dictHistory.json"
local ydUrl = 'https://openapi.youdao.com/api'
local bdUrl = 'https://fanyi-api.baidu.com/api/trans/vip/translate'
local bdWeburl = 'https://fanyi.baidu.com/#'
local ydWeburl = 'http://youdao.com/w/'
local mChooser
local searchResult = {}
local isFirst = true
function truncate(q)
if q == nil or q == '' then
return ''
end
local len = SubStringGetTotalIndex(q)
if (len <= 20) then
return q
else
return SubStringUTF8(q,1,10)..len..SubStringUTF8(q,len-9)
end
end
function newWebview()
local cscreen = hs.screen.mainScreen()
local cres = cscreen:fullFrame()
sheetView = hs.webview.newBrowser({
x = cres.x+cres.w*0.15/2,
y = cres.y+cres.h*0.25/2,
w = cres.w*0.85,
h = cres.h*0.75
})
sheetView:windowTitle("CheatSheets")
sheetView:windowStyle("utility")
sheetView:titleVisibility("hidden")
sheetView:allowGestures(true)
sheetView:allowNewWindows(false)
sheetView:allowTextEntry(true)
sheetView:closeOnEscape(true)
sheetView:bringToFront(false)
sheetView:darkMode(true)
sheetView:reload(false)
sheetView:level(hs.drawing.windowLevels.mainMenu)
end
-- 右键弹出菜单
local rightClickCallbackFn = function(index)
if index and index > 0 then
local selectResult = mChooser:selectedRowContents(index)
if selectResult == nil or stringIsEmpty(selectResult.text) then
return
end
menubar = hs.menubar.new(false)
menubar:setTitle("Hidden Menu")
menubar:setMenu( {
{ title = "查看详情", fn = function()
hs.dialog.blockAlert(selectResult.text, selectResult.subText,"确定","","informational")
end },
{ title = "查看网页", fn = function()
sheetView:url(selectResult.webUrl):show()
end },
})
menubar:popupMenu(hs.mouse.getAbsolutePosition(), true)
end
end
function getBaiduApi(q)
headers = {ContentType = "application/x-www-form-urlencoded;charset=utf-8"}
salt = tostring(hs.timer.secondsSinceEpoch()*1000)
curtime = tostring(os.time())
geturl = "q="..q.."&from=auto&to=auto&appid=".. config[1].baiduAppid .."&salt="..salt.."&sign="..hs.hash.MD5(config[1].baiduAppid ..q..salt..config[1].baiduAppSecret)
--print('geturl:'..geturl)
hs.http.doAsyncRequest(bdUrl,'POST',geturl,headers,function(code, body, htable)
if code ~= 200 then
print('get weather error:'..code)
return
else
searchResult = {}
results = hs.json.decode(body)
print('results:'..hs.inspect(results))
if(results['trans_result']) then
item = {}
item.text = results['trans_result'][1].dst
item.subText = q
item.webUrl = bdWeburl..results['from'].."/"..results['to'].."/"..decodeURI(q)
table.insert(searchResult,1,item)
end
mChooser:choices(searchResult)
hs.json.write(searchResult,dictHistoryPath, true, true)
end
end)
end
function getYoudaoApi(q)
headers = {ContentType = "application/x-www-form-urlencoded;charset=utf-8"}
salt = tostring(hs.timer.secondsSinceEpoch()*1000)
curtime = tostring(os.time())
geturl = "q="..q.."&from=auto&to=auto&signType=v3&curtime="..curtime.."&appKey="..config[1].youdaoAppid..
"&salt="..salt.."&sign="..hs.hash.SHA256(config[1].youdaoAppid..truncate(q)..salt..curtime..config[1].youdaoAppSecret)
--print('geturl:'..geturl)
hs.http.doAsyncRequest(ydUrl,'POST',geturl,headers,function(code, body, htable)
if code ~= 200 then
print('get weather error:'..code)
return
else
searchResult = {}
results = hs.json.decode(body)
print('results:'..hs.inspect(results))
if(results['web']) then
--逆序插入
for i=#results['web'],1,-1 do
item = {}
item.text = table.concat(results['web'][i].value,", ")
item.subText = results['web'][i].key
item.webUrl = ydWeburl..decodeURI(item.subText)
table.insert(searchResult,1,item)
end
end
if(results['basic']) then
if (results['basic']['exam_type']) then
item = {}
item.text = table.concat(results['basic']['exam_type'],', ')
item.subText = q
item.webUrl = ydWeburl..decodeURI(item.subText)
table.insert(searchResult,1,item)
end
if (results['basic']['explains']) then
for i=#results['basic']['explains'],1,-1 do
item = {}
item.text = results['basic']['explains'][i]
item.subText = q
item.webUrl = ydWeburl..decodeURI(item.subText)
table.insert(searchResult,1,item)
end
end
end
if(results['translation']) then
item = {}
item.text = table.concat(results['translation'])
item.subText = q
item.webUrl = ydWeburl..decodeURI(item.subText)
table.insert(searchResult,1,item)
end
mChooser:choices(searchResult)
hs.json.write(searchResult,dictHistoryPath, true, true)
end
end)
end
-- 粘贴选中的片段
local completionFn = function(result)
if result then
hs.pasteboard.setContents(result.text)
--hs.eventtap.keyStroke({ "cmd" }, "V")
print("keywords:"..result.text)
end
end
-- 监听输入框
local queryChangedCallbackFn = function(result)
print("changekeywords:"..result)
if result and #result > 0 then
if config[1].dictEngine == '百度' then
getBaiduApi(result)
else
getYoudaoApi(result)
end
else
if(isFirst) then
isFirst = false
else
searchResult = {}
mChooser:choices(searchResult)
hs.json.write(searchResult,dictHistoryPath, true, true)
end
end
end
function initData()
newWebview()
-- 选取片段内容(按下快捷键时显示片段列表,点击选中的快捷键将自动粘贴)
hs.hotkey.bind(hyperCmd, "F", function ()
isFirst = true
if hs.json.read(dictHistoryPath) ~= nil then
searchResult = hs.json.read(dictHistoryPath)
end
mChooser = chooser.new(completionFn)
:choices(searchResult)
:queryChangedCallback(queryChangedCallbackFn)
:rightClickCallback(rightClickCallbackFn)
:searchSubText(true)
:show()
end)
end
initData()
+2 -1
View File
@@ -1,4 +1,5 @@
hyper = {"cmd", "ctrl", "alt"}
hyperShift = {"alt", "shift"}
hyperCtrl = {"alt", "ctrl"}
hyperAlt = {"ctrl", "alt", "shift"}
hyperAlt = {"ctrl", "alt", "shift"}
hyperCmd = {"alt", "cmd"}
+128
View File
@@ -0,0 +1,128 @@
---
--- 在状态栏中显示输入法的状态
--- 例如:大小写状态,中英文状态,目前只适配搜狗输入法
--- Created by sugood(https://github.com/sugood).
--- DateTime: 2020/10/24 11:12
---
local sougouId = 'com.sogou.inputmethod.sogou.pinyin'
local shuangpinId = 'com.apple.inputmethod.SCIM.Shuangpin'
local abcId = 'com.apple.keylayout.ABC'
local mEventtap
function isChinese()
-- 用于保存当前输入法
local currentSourceID = hs.keycodes.currentSourceID()
return (currentSourceID == sougouId or currentSourceID == shuangpinId)
end
--解决hs.eventtap.new 有时候会卡死的问题。需要每秒检查下监听状态。如果卡死了就重新启动
local listenerEvent = function()
if mEventtap:isEnabled()==false then
print("重启监听事件")
mEventtap:start()
end
end
function initData()
local reverse = true
local imgInputAbc = '~/.hammerspoon/icon/input_abc.pdf'
local imgInputEn = '~/.hammerspoon/icon/input_en.pdf'
local imgInputCn = '~/.hammerspoon/icon/input_cn.pdf'
local imgInputU = '~/.hammerspoon/icon/input_u.pdf'
--初始化默认是英文输入法
hs.keycodes.currentSourceID(abcId)
if hs.hid.capslock.get() then
macMenubar:setIcon(imgInputU)
else
if(isChinese()) then
macMenubar:setIcon(imgInputCn)
else
macMenubar:setIcon(imgInputAbc)
end
end
mEventtap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function(event)
--获取shift按键信息
if event:getKeyCode() == 56 and event:getFlags().shift then
if (isChinese()) then
hs.hid.led.set('caps',false)
hs.alert.closeSpecific(showUUID)
if reverse then
reverse = false
macMenubar:setIcon(imgInputEn)
else
reverse = true
macMenubar:setIcon(imgInputCn)
end
else
if hs.hid.capslock.get()==false then
reverse = false
macMenubar:setIcon(imgInputAbc)
end
end
return
end
--获取capslock按键信息
tab =hs.eventtap.checkKeyboardModifiers("capslock")
local isCaptLock = tab["capslock"]
if isCaptLock then
if hs.hid.capslock.get() then
hs.hid.led.set('caps',true)
else
hs.hid.led.set('caps',false)
hs.alert.closeAll(0)
hs.alert.show("键盘小写 🔤- OFF")
if(isChinese()) then
if(reverse) then
macMenubar:setIcon(imgInputCn)
else
macMenubar:setIcon(imgInputEn)
end
else
macMenubar:setIcon(imgInputAbc)
end
end
else
if hs.hid.capslock.get() then
hs.hid.led.set('caps',true)
hs.alert.closeAll(0)
hs.alert.show("键盘大写 🅰️- ON")
macMenubar:setIcon(imgInputU)
else
--print("小写2")
hs.hid.led.set('caps',false)
end
end
return false
end)
mEventtap:start()
hs.timer.doEvery(1, listenerEvent)
hs.keycodes.inputSourceChanged(function()
-- 用于保存当前输入法
local currentSourceID = hs.keycodes.currentSourceID()
-- 如果当前输入法和上一个输入法相同,则直接返回
if currentSourceID == lastSourceID then
return
end
-- 用于保存当前输入法
local currentSourceID = hs.keycodes.currentSourceID()
hs.alert.closeAll(0)
-- 判断是系统自带的 ABC还是中文输入法
if (currentSourceID == abcId) then
--hs.alert.show("ABC")
macMenubar:setIcon(imgInputAbc)
reverse = false
elseif (currentSourceID == sougouId or currentSourceID == shuangpinId) then
--hs.alert.show("中文")
reverse = true
macMenubar:setIcon(imgInputCn)
end
-- 保存最后一个输入法源名称ds
lastSourceID = currentSourceID
end)
end
-- 初始化
initData()
+208
View File
@@ -0,0 +1,208 @@
-----
----- 格式化Json
----- Created by sugood(https://github.com/sugood).
----- DateTime: 2020/10/19 10:34
-----
--
--
local function generateHtml()
local html = [[
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Json格式化高亮展示工具</title>
<style>
body { height: 100%; margin:0; font-family:"微软雅黑"; font-size:12px; }
.pdiv { height: 85%; position: absolute; }
.title { height: auto; font-size:20px; text-align:center; margin-top: 5px; margin-bottom: 20px;}
.author { height: auto; width: 100%; font-size:12px; text-align:center; margin-top: 30px; margin-bottom: 20px;}
table { height: 100%; width:100%; border-collapse:collapse; }
table .tdLeft { width:85%; text-align:left; padding-left: 10px;padding-right: 10px;}
table .tdmid { width:150px; text-align:center; margin: 0px; padding: 0px;}
table .tdRight { width:85%; padding-right: 30px;text-align:left; }
table textarea { width:100%; height:100%; font-size:14px; padding-top: 10px; padding-left: 10px; outline: none; border-radius: 15px; border: 2px solid #8AC007; }
#container { width:100%; height:100%; font-size:14px; padding-top: 10px; padding-left: 10px; border-radius: 15px; border: 2px solid #8AC007;}
pre{white-space:pre-wrap; white-space:-moz-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word; margin: 0px; padding: 5px;}
pre .string { color: green; }
pre .number { color: darkorange; }
pre .boolean { color: blue; }
pre .null { color: magenta; }
.key { color: red; }
</style>
</head>
<body>
<div class="pdiv">
<div class="title" >Json格式化高亮展示工具</div>
<table style="table-layout:fixed">
<tr>
<!-- <td class="tdLeft" nowrap>请输入要展示的Json:</td> -->
<td class="tdLeft">
<input style="width:auto; margin: 10px;" type="button" value="复制" onClick="copySource()">
<textarea name = "jsonContent" id="jsonContent" ></textarea>
</td>
<td class="tdmid"><input style="width:80%;" type="button" value="格式化JSON >>" onClick="showJson()"></td>
<td class="tdRight">
<input style="width:auto; margin: 10px;" type="button" value="复制" onClick="copyResult()">
<pre id="container"></pre>
</td>
</tr>
</table>
<div class="author">
<a href="https://github.com/sugood" target="_blank">By: github.com/sugood</a>
</div>
<div class="tips" id="tips">
</div>
</div>
</body>
<script type="text/javascript">
function copySource(){
var obj = document.getElementById('jsonContent');
//选择当前对象
obj.select();
try{
if(document.execCommand("Copy","false",null)){
alert("复制成功!");
}
}catch(err){
alert("复制错误!");
}
}
function copyResult(){
var text = document.getElementById('container').innerText;
const input = document.createElement('textarea');
input.value = text;
input.setAttribute('readonly', 'readonly');
document.body.appendChild(input);
input.select();
try{
if(document.execCommand('Copy')){
alert('复制成功');
}
}catch(err){
alert("复制错误!");
}
document.body.removeChild(input);
}
function syntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 4);
}
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
function showJson(){
var text = document.getElementById('jsonContent').value
if (text!="" && text!=null){
try {
var result = JSON.stringify(JSON.parse(text), null, 4);//将字符串转换成json对象
highLineResult = syntaxHighlight(result);
document.getElementById('container').innerHTML= highLineResult;
localStorage.setItem("jsonFormatSource",text);
localStorage.setItem("jsonFormatResult",highLineResult);
} catch(e) {
document.getElementById('container').innerText= '异常信息:'+e ;
}
}else{
document.getElementById("jsonContent").value = "请输入json文本";
document.getElementById('container').innerHTML= "显示Json格式化后的效果";
localStorage.setItem("jsonFormatSource","请输入json文本");
localStorage.setItem("jsonFormatResult","显示Json格式化后的效果");
}
  };
var jsonFormatSource = localStorage.getItem("jsonFormatSource");
if (jsonFormatSource!="" && jsonFormatSource!=null){
document.getElementById("jsonContent").value=localStorage.getItem("jsonFormatSource");
}else{
document.getElementById("jsonContent").value = "请输入json文本"
}
var jsonFormatResult = localStorage.getItem("jsonFormatResult");
if (jsonFormatResult!="" && jsonFormatResult!=null){
document.getElementById("container").innerHTML=localStorage.getItem("jsonFormatResult");
}else{
document.getElementById("jsonContent").value = "显示Json格式化后的效果"
}
</script>
</html>
]]
return html
end
--- KSheet:hide()
--- Method
--- Hide the cheatsheet view.
function hide(time)
sheetView:hide(time)
end
function init()
local cscreen = hs.screen.mainScreen()
local cres = cscreen:fullFrame()
sheetView = hs.webview.newBrowser({
x = cres.x+cres.w*0.15/2,
y = cres.y+cres.h*0.25/2,
w = cres.w*0.85,
h = cres.h*0.75
})
sheetView:windowTitle("CheatSheets")
sheetView:windowStyle("utility")
sheetView:titleVisibility("hidden")
sheetView:allowGestures(true)
sheetView:allowNewWindows(false)
sheetView:allowTextEntry(true)
sheetView:closeOnEscape(true)
sheetView:bringToFront(false)
sheetView:darkMode(true)
sheetView:reload(false)
sheetView:level(hs.drawing.windowLevels.mainMenu)
end
--- KSheet:show()
--- Method
--- Show current application's keybindings in a view.
function show(time)
local webcontent = generateHtml()
sheetView:html(webcontent, "http://localhost")
sheetView:show(time)
end
function toggle()
if sheetView and sheetView:hswindow() and sheetView:hswindow():isVisible() then
hide(2)
else
show(2)
end
end
init()
-- 添加片段(按下快捷键时做一个复制操作,并记录复制的内容到片段列表中)
hs.hotkey.bind(hyperCmd, "G", function ()
toggle()
end)
+4 -9
View File
@@ -1,7 +1,5 @@
local chooser = require("hs.chooser")
local console = require("hs.console")
console.clearConsole()
local historyPath= "~/.hammerspoon/data/history.json"
local maxLength = 1000
local history = {}
@@ -24,10 +22,7 @@ function duplicate(table,keys)
end
return false
end
-- 字符串判空
function isEmpty(str)
return str == nil or str == ''
end
-- 查询text是否存在并返回索引index
-- 等于0为没有查询到,大于0为查询到
function searchByText(table,text)
@@ -120,7 +115,7 @@ end
local rightClickCallbackFn = function(index)
if index and index > 0 then
local selectResult = mChooser:selectedRowContents(index)
if selectResult == nil or isEmpty(selectResult.text) then
if selectResult == nil or stringIsEmpty(selectResult.text) then
return
end
index = searchByText(history,selectResult.text)
@@ -160,7 +155,7 @@ local rightClickCallbackFn = function(index)
end
end
-- 选取片段内容(按下快捷键时显示片段列表,点击选中的快捷键将自动粘贴)
hs.hotkey.bind({ "ctrl", "cmd" }, "V", function ()
hs.hotkey.bind(hyperCmd, "V", function ()
mChooser = chooser.new(completionFn)
:choices(history)
:rightClickCallback(rightClickCallbackFn)
@@ -168,7 +163,7 @@ hs.hotkey.bind({ "ctrl", "cmd" }, "V", function ()
:show()
end)
-- 添加片段(按下快捷键时做一个复制操作,并记录复制的内容到片段列表中)
hs.hotkey.bind({"ctrl", "cmd"}, "A", function ()
hs.hotkey.bind(hyperCmd, "X", function ()
bindCopyKey()
if hs.dialog.blockAlert("添加片段:‘|’为分隔符,建议按如下格式","内容|keyword|示例|说明","确定","取消","informational") == "确定" then
addToHistory()
+59
View File
@@ -0,0 +1,59 @@
---
--- 时间同步,开启后在系统或屏幕唤醒后自动同步一次时间
--- Created by sugood(https://github.com/sugood).
--- DateTime: 2020/10/23 11:12
---
function execTimeSync()
local shell_command = 'expect ~/.hammerspoon/timesync/timesync.sh '.. config[1].rootPassword
result = table.pack(hs.execute(shell_command,true))
print(result[1])
end
function caffeinateCallback(eventType)
if (eventType == hs.caffeinate.watcher.screensDidSleep) then
print("screensDidSleep")
elseif (eventType == hs.caffeinate.watcher.screensDidWake) then
execTimeSync()
hs.reload()
print("screensDidWake")
elseif (eventType == hs.caffeinate.watcher.systemDidWake) then
execTimeSync()
hs.reload()
print("systemDidWake")
elseif (eventType == hs.caffeinate.watcher.screensDidLock) then
print("screensDidLock")
elseif (eventType == hs.caffeinate.watcher.screensDidUnlock) then
print("screensDidUnlock")
end
end
function initData()
if config ~=nil and config[1].isSyncTime == 'on' then
caffeinateWatcher = hs.caffeinate.watcher.new(caffeinateCallback)
caffeinateWatcher:start()
-- 添加片段(按下快捷键时做一个复制操作,并记录复制的内容到片段列表中)
hs.hotkey.bind(hyperCmd, "T", function ()
if hs.json.read(configPath) ~= nil then
config = hs.json.read(configPath)
end
if(stringIsEmpty(config[1].rootPassword)) then
local result,subText = hs.dialog.textPrompt("输入开机密码", "时间同步操作需要开机密码", '', "确定", "取消", true)
if result == "确定" then
if(stringIsEmpty(subText) == false) then
config[1].rootPassword = subText
hs.json.write(config,configPath, true, true)
execTimeSync()
hs.alert.show('同步时间')
end
end
else
execTimeSync()
hs.alert.show('同步时间')
end
end)
end
end
-- 初始化,读取本地数据
initData()
+15
View File
@@ -0,0 +1,15 @@
#timesyne.sh
#expect的安装路径
#/usr/local/bin/expect这个路径安装完expect之后 which expect可以查看
#!/usr/local/bin/expect
set timeout 10
set passwd [lindex $argv 0]
spawn sudo sntp -sS ntp.aliyun.com
#根据输出传递数据,在这里是等待密码提示显示
expect "*assword*"
send "$passwd\n"
#interact
expect eof
exit