Skip to content

Commit 7c16446

Browse files
authored
Merge branch 'main' into u/pking/fixing_hammerspoon
2 parents 319b64e + 4f114b8 commit 7c16446

File tree

12 files changed

+116
-35
lines changed

12 files changed

+116
-35
lines changed

Darwin/defaults.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash -xe Get updates in background.
1+
#!/bin/bash -xe
2+
23
softwareupdate --download --verbose --install --all
34

45
# Ask for the administrator password upfront
@@ -130,14 +131,14 @@ defaults write com.apple.dock expose-animation-duration -float 0.1 # Speed up Mi
130131
# ========================================================================= }}}
131132
# Safari ================================================================== {{{
132133

133-
defaults write com.apple.Safari HomePage -string "about:blank" # Set Safari’s home page to `about:blank` for faster loading
134-
defaults write com.apple.Safari ShowFavoritesBar -bool false # Hide Safari’s bookmarks bar by default
135-
defaults write com.apple.Safari ShowSidebarInTopSites -bool false # Hide Safari’s sidebar in Top Sites
136-
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true # Show the full URL in the address bar
134+
# defaults write com.apple.Safari HomePage -string "about:blank" # Set Safari’s home page to `about:blank` for faster loading
135+
# defaults write com.apple.Safari ShowFavoritesBar -bool false # Hide Safari’s bookmarks bar by default
136+
# defaults write com.apple.Safari ShowSidebarInTopSites -bool false # Hide Safari’s sidebar in Top Sites
137+
# defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true # Show the full URL in the address bar
137138

138139
# Don’t send search queries to Apple
139-
defaults write com.apple.Safari UniversalSearchEnabled -bool false
140-
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
140+
# defaults write com.apple.Safari UniversalSearchEnabled -bool false
141+
# defaults write com.apple.Safari SuppressSearchSuggestions -bool true
141142

142143
# ========================================================================= }}}
143144

@@ -170,7 +171,6 @@ defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
170171
# Time Machine ============================================================ {{{
171172

172173
exclusions=("$HOME/.local"
173-
"$HOME/.Trash"
174174
"$HOME/Downloads"
175175
"$HOME/Dropbox"
176176
"$HOME/Library/Caches"

homemaker.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ accepts = [["which", "npm"]]
3939
["which", "fish"],
4040
["echo", "$SHELL", "|", "grep", "fish"],
4141
]
42-
cmds = [["chsh", "-s", "/usr/bin/fish"]]
42+
cmds = [["chsh", "-s", "/opt/homebrew/bin/fish"]]
4343

4444
[tasks.terminfo]
4545
accepts = [["which", "tic"]]
@@ -53,7 +53,8 @@ accepts = [["which", "npm"]]
5353
# ========================================================================= }}}
5454
# meta ==================================================================== {{{
5555
[tasks.default]
56-
deps = ["links", "systemconfig", "pip", "npm", "fish", "fish_completions", "terminfo"]
56+
# deps = ["links", "systemconfig", "pip", "npm", "fish", "fish_completions", "terminfo"]
57+
deps = ["links", "pip", "npm", "fish", "fish_completions", "terminfo"]
5758

5859
# ========================================================================= }}}
5960
# macOS =================================================================== {{{

tilde/.config/fish/conf.d/env.fish

+9-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,18 @@ set -gx QUBES_GPG_DOMAIN gpg
3939
set -gx HOMEBREW_PREFIX $__brew_prefix
4040
set -gx HOMEBREW_CELLAR $__brew_prefix/Cellar
4141
set -gx HOMEBREW_REPOSITORY $__brew_prefix
42+
set -gx HOMEBREW_GNUBIN $__brew_prefix/opt/coreutils/libexec/gnubin
43+
set -gx HOMEBREW_GNUMAN $__brew_prefix/opt/coreutils/libexec/gnuman
44+
4245
set -q PATH; or set PATH ''
43-
set -gx PATH $__brew_prefix/bin $__brew_prefix/sbin $PATH
46+
set -gx PATH $HOMEBREW_GNUBIN $__brew_prefix/bin $__brew_prefix/sbin $PATH
47+
4448
set -q MANPATH; or set MANPATH ''
45-
set -gx MANPATH /opt/homebrew/share/man $MANPATH
49+
set -gx MANPATH $HOMEBREW_GNUMAN /opt/homebrew/share/man $MANPATH
50+
4651
set -q INFOPATH; or set INFOPATH ''
4752
set -gx INFOPATH $__brew_prefix/share/info $INFOPATH
53+
4854
if test -e $__brew_prefix/opt/fish/share/fish/__fish_build_paths.fish
4955
source $__brew_prefix/opt/fish/share/fish/__fish_build_paths.fish
5056
end
@@ -55,6 +61,7 @@ fish_add_path --path $HOME/.yarn/bin
5561
fish_add_path --path $HOME/.config/yarn/global/node_modules/.bin
5662
fish_add_path --path $HOME/go/bin
5763
fish_add_path --path $HOME/.cargo/bin
64+
fish_add_path --path $HOME/.local/bin # pipx path
5865
fish_add_path --path $__brew_prefix/opt/homebrew/opt/coreutils/libexec/gnubin
5966
fish_add_path --path $__brew_prefix/share/google-cloud-sdk/path.fish.inc
6067

tilde/.config/nvim/lua/pking/plugin/auto-session.lua

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ return {
55
auto_session_enabled = true,
66
auto_session_create_enabled = true,
77
auto_session_use_git_branch = true,
8+
auto_session_enable_last_session = true,
9+
auto_save_enabled = true,
10+
auto_restore_enabled = true,
811
auto_session_suppress_dirs = { "~/", "~/Downloads", "~/Library", "/"},
912

1013

tilde/.config/nvim/lua/pking/plugin/lsp/lspconfig.lua

+10-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,16 @@ return {
105105

106106
require("mason-lspconfig").setup({
107107
automatic_installation = true,
108-
ensure_installed = {},
108+
-- Only LSPs are listed here, all of the other installs are in
109+
-- null-ls.lua
110+
ensure_installed = {
111+
"bashls",
112+
"eslint",
113+
"harper_ls",
114+
"lua_ls",
115+
"ruff_lsp",
116+
"taplo",
117+
},
109118
handlers = {
110119
default_setup,
111120
}

tilde/.config/nvim/lua/pking/plugin/lsp/null-ls.lua

+5-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ return {
1010
local null_ls = require("null-ls")
1111
null_ls.setup({
1212
sources = {
13+
-- Everything but LSPs are listed here. All automatic LSP
14+
-- installs can be found in lspconfig.lua under
15+
-- `ensure_installed` for the mason-lspconfig setup.
16+
1317
-- Bash
14-
null_ls.builtins.code_actions.shellcheck,
1518
null_ls.builtins.formatting.shfmt,
1619

1720
-- Docker
@@ -30,18 +33,14 @@ return {
3033
null_ls.builtins.formatting.goimports,
3134

3235
-- Lua
33-
null_ls.builtins.diagnostics.luacheck,
36+
null_ls.builtins.diagnostics.selene,
3437
null_ls.builtins.formatting.stylua,
3538

3639
-- Markdown / Text
3740
null_ls.builtins.code_actions.proselint,
38-
null_ls.builtins.diagnostics.vale,
3941
null_ls.builtins.diagnostics.write_good.with({ filetypes = { "markdown", "text" }}),
4042
null_ls.builtins.formatting.markdownlint,
4143

42-
-- Python
43-
null_ls.builtins.formatting.autopep8,
44-
4544
-- SQL
4645
null_ls.builtins.diagnostics.sqlfluff.with({
4746
extra_args = { "--dialect", "postgres" }, -- change to your dialect
@@ -50,14 +49,12 @@ return {
5049

5150
-- Terraform
5251
null_ls.builtins.diagnostics.tfsec,
53-
null_ls.builtins.formatting.terrafmt, -- Terraform formatting in markdown
5452
null_ls.builtins.formatting.terraform_fmt, -- Terraform formatting in .tf files
5553

5654
-- TOML
5755
null_ls.builtins.formatting.taplo,
5856

5957
-- Typescript
60-
null_ls.builtins.code_actions.eslint_d,
6158
null_ls.builtins.formatting.prettierd,
6259

6360
-- Vim

tilde/.config/nvim/lua/pking/plugin/lualine.lua

+19-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ return {
77
event = { 'UIEnter' },
88
dependencies = {
99
"nvim-tree/nvim-web-devicons",
10-
"WhoIsSethDaniel/lualine-lsp-progress",
10+
{
11+
"linrongbin16/lsp-progress.nvim",
12+
config = function()
13+
require ('lsp-progress').setup()
14+
15+
vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
16+
vim.api.nvim_create_autocmd("User", {
17+
group = "lualine_augroup",
18+
pattern = "LspProgressStatusUpdated",
19+
callback = require("lualine").refresh,
20+
})
21+
end,
22+
},
1123
"AndreM222/copilot-lualine",
1224
},
1325
config = function()
@@ -127,6 +139,10 @@ return {
127139

128140
end
129141

142+
local function auto_session()
143+
return "󱎤 "..require('auto-session.lib').current_session_name()
144+
end
145+
130146
require('lualine').setup {
131147
options = {
132148
icons_enabled = true,
@@ -181,9 +197,9 @@ return {
181197
newfile = '', -- Text to show for new created file before first writting
182198
}
183199
},
200+
auto_session,
184201
'location',
185-
require('auto-session.lib').current_session_name,
186-
'lsp_progress',
202+
require('lsp-progress').progress,
187203
},
188204
lualine_x = {
189205
{ searchCount },

tilde/.gitconfig

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
name = Patrick King
66
email = patrick@patrickcking.com
77
username = mr-mustash
8-
signingkey = 0x944E36F397047609
8+
#signingkey = 0x944E36F397047609
99

1010
[gpg]
11-
program = /usr/local/MacGPG2/bin/gpg
11+
#program = /usr/local/MacGPG2/bin/gpg
1212

1313
# Non-template things
1414
[alias]
@@ -21,7 +21,7 @@
2121
sort = -committerdate
2222

2323
[commit]
24-
gpgsign = true
24+
#gpgsign = true
2525

2626
[core]
2727
editor=nvim
@@ -80,3 +80,5 @@
8080
path = ~/.gitconfig.local
8181

8282
# vim: set noexpandtab tabstop=4 nolist:
83+
[credential]
84+
helper = store

tilde/.hammerspoon/init.lua

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Dock = require("system/dock")
112112
networking = require("system/networking")
113113
-- Ping = require("system/Ping") -- needs work
114114
videoCalls = require("system/videoCalls")
115+
-- Keytrap = require("system/keytrap")
115116

116117

117118
audioControl.init()
@@ -122,6 +123,7 @@ Dock.init()
122123
networking.init()
123124
-- Ping.init() -- needs work
124125
videoCalls.init()
126+
-- Keytrap.init()
125127
-- ========================================================================= }}}
126128

127129
-- App configuration ======================================================= {{{

tilde/.hammerspoon/system/audioControl.lua

+35-7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ local function internalOrExternalMic()
5050
_log("Unable to set any mic as default")
5151
return 1
5252
end
53+
local function perDeviceWatcher(dev_uid, event_name, event_scope, event_element)
54+
local device = hs.audiodevice.findDeviceByUID(dev_uid)
55+
if device and event_name == "mute" then
56+
_log("\"" .. device:name() .. "\" mute state has changed.")
57+
audioControl.matchInputMuteToOutputMute()
58+
sleep(1)
59+
end
60+
end
61+
62+
local function startOutputWatcher()
63+
local defaultOutput = hs.audiodevice.defaultOutputDevice()
64+
65+
if defaultOutput:watcherIsRunning() then
66+
_log("Audio watcher for " .. defaultOutput:name() .. " already exists.")
67+
else
68+
_log("No audio watcher found for " .. defaultOutput:name() .. " starting one.")
69+
defaultOutput:watcherCallback(perDeviceWatcher)
70+
defaultOutput:watcherStart()
71+
end
72+
end
5373

5474
local function audioDeviceChanged(arg)
5575
local outputRetval = 1
@@ -66,6 +86,7 @@ local function audioDeviceChanged(arg)
6686
sleep(5)
6787

6888
_log("New audio device detected. Current values: Speaker: " .. hs.audiodevice.defaultOutputDevice():name() .. " Mic: " .. hs.audiodevice.defaultInputDevice():name())
89+
startOutputWatcher()
6990

7091
outputRetval = internalOrExternalSpeaker()
7192
micRetval = internalOrExternalMic()
@@ -89,14 +110,12 @@ local function trapVolumeControls()
89110

90111
-- Send mute to external monitor if connected and it's the default audio output
91112
if event["key"] == "MUTE" then
92-
if isMuted == false then
93-
isMuted = true
94-
run.cmd(string.format("%s/bin/m1ddc", Homedir), { "set", "mute", "on" })
95-
_log("Muted external monitor.")
96-
else
97-
isMuted = false
98-
run.cmd(string.format("%s/bin/m1ddc", Homedir), { "set", "mute", "off" })
113+
if hs.audiodevice.defaultOutputDevice():outputMuted() then
114+
run.cmd("/Users/patrickking/bin/m1ddc", { "set", "mute", "off" })
99115
_log("Unmuted external monitor.")
116+
else
117+
run.cmd("/Users/patrickking/bin/m1ddc", { "set", "mute", "on" })
118+
_log("Muted external monitor.")
100119
end
101120
return true
102121
end
@@ -128,6 +147,7 @@ function audioControl.init()
128147
local initStart = os.clock()
129148
hs.audiodevice.watcher.setCallback(audioDeviceChanged)
130149
hs.audiodevice.watcher.start()
150+
startOutputWatcher()
131151

132152
trapVolumeControls()
133153
hs.hotkey.bind({'cmd', 'shift'}, "k", function() audioControl.mediaControls("PLAY") end)
@@ -137,6 +157,14 @@ function audioControl.init()
137157
_log(debug.getinfo(1, "S").short_src:gsub(".*/", "") .. " loaded in " .. (os.clock() - initStart) .. " seconds.")
138158
end
139159

160+
function audioControl.matchInputMuteToOutputMute()
161+
if hs.audiodevice.defaultOutputDevice():muted() then
162+
audioControl.muteInputs()
163+
else
164+
audioControl.unmuteInputs()
165+
end
166+
end
167+
140168
function audioControl.muteInputs()
141169
for _, device in pairs(hs.audiodevice.allInputDevices()) do
142170
device:setInputMuted(true)

tilde/.hammerspoon/system/keytrap.lua

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
local keytrap = {}
2+
3+
local function keytrap_router()
4+
systemeventtap = hs.eventtap.new({ hs.eventtap.event.types.systemDefined }, function(mainEvent)
5+
local event = mainEvent:systemKey()
6+
local flags = hs.eventtap.checkKeyboardModifiers()
7+
8+
end)
9+
systemeventtap:start()
10+
end
11+
12+
function keytrap.init()
13+
keytrap_router()
14+
end
15+
16+
return keytrap

0 commit comments

Comments
 (0)