Skip to content

Commit

Permalink
Merge branch 'main' into update_flake_lock_action
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman authored Mar 15, 2024
2 parents 9fbb152 + 4ac3578 commit 8360e92
Show file tree
Hide file tree
Showing 25 changed files with 592 additions and 1,271 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deadnix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ jobs:
with:
name: deadnix
- uses: astro/deadnix-action@main
with:
commit_message: 'chore: remove dead code'
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions modules/darwin/desktop/addons/jankyborders/bordersrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

options=(
style=round
width=6.0
hidpi=off
active_color=0xff7793d1
inactive_color=0xff5e6798
background_color=0x302c2e34
blur_radius=25
)

borders "${options[@]}"
23 changes: 23 additions & 0 deletions modules/darwin/desktop/addons/jankyborders/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ config
, lib
, options
, ...
}:
let
inherit (lib) mkIf;
inherit (lib.internal) mkBoolOpt;

cfg = config.khanelinix.desktop.addons.jankyborders;
in
{
options.khanelinix.desktop.addons.jankyborders = {
enable =
mkBoolOpt false "Whether to enable jankyborders in the desktop environment.";
};

config = mkIf cfg.enable {
khanelinix.home.configFile = {
"borders/bordersrc".source = ./bordersrc;
};
};
}
6 changes: 4 additions & 2 deletions modules/darwin/desktop/addons/yabai/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}:
let
inherit (lib) mkIf getExe;
inherit (lib.internal) mkBoolOpt;
inherit (lib.internal) mkBoolOpt enabled;

cfg = config.khanelinix.desktop.addons.yabai;
in
Expand All @@ -17,6 +17,8 @@ in
};

config = mkIf cfg.enable {
khanelinix.desktop.addons.jankyborders = enabled;

services.yabai = {
enable = true;
# package = pkgs.yabai;
Expand Down Expand Up @@ -80,7 +82,7 @@ in
# ${getExe config.services.yabai.package} -m signal --add event=window_title_changed app="Firefox" title="- noVNC$" action="${getExe config.services.yabai.package} -m window $WINDOW_ID --toggle native-fullscreen"
# jankyborders
borders active_color=0xff7793d1 inactive_color=0xff5e6798 width=3.0 2>/dev/null 1>&2 &
borders 2>/dev/null 1>&2 &
echo "yabai configuration loaded.."
'';
Expand Down
1 change: 1 addition & 0 deletions modules/darwin/suites/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ in
skhd = enabled;
yabai = enabled;
sketchybar = enabled;
jankyborders = enabled;
};

homebrew = {
Expand Down
1 change: 0 additions & 1 deletion modules/home/desktop/addons/hypridle/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
, inputs
, lib
, options
, pkgs
, system
, ...
}:
Expand Down
1 change: 0 additions & 1 deletion modules/home/desktop/addons/hyprlock/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ config
, inputs
, lib
, pkgs
, options
, system
, ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

local icons = require("icons")
local settings = require("settings")
local colors = require("colors")

local popup_width = 250

local wifi = sbar.add("item", "wifi", {
position = "right",
Expand All @@ -20,59 +23,104 @@ local wifi = sbar.add("item", "wifi", {
},
label = { drawing = false },
update_freq = 60,
popup = {
align = "right",
},
})

wifi.details = sbar.add("item", "wifi.details", {
local ssid = sbar.add("item", {
position = "popup." .. wifi.name,
click_script = "sketchybar --set $NAME popup.drawing=off",
background = {
corner_radius = 12,
padding_left = 5,
padding_right = 10
icon = {
font = {
style = "Bold"
},
string = icons.wifi.router,
},
width = popup_width,
align = "center",
label = {
font = {
size = 15,
style = "Bold"
},
max_chars = 18,
string = "????????????",
},
background = {
height = 2,
color = colors.grey,
y_offset = -15
}
})

local hostname = sbar.add("item", {
position = "popup." .. wifi.name,
icon = {
background = {
height = 2,
y_offset = 12,
}
align = "left",
string = "Hostname:",
width = popup_width / 2,
},
label = {
align = "center",
max_chars = 20,
string = "????????????",
width = popup_width / 2,
align = "right",
}
})

local ip = sbar.add("item", {
position = "popup." .. wifi.name,
icon = {
align = "left",
string = "IP:",
width = popup_width / 2,
},
label = {
string = "???.???.???.???",
width = popup_width / 2,
align = "right",
}
})

wifi:subscribe({
"routine",
"power_source_change",
"system_woke"
local mask = sbar.add("item", {
position = "popup." .. wifi.name,
icon = {
align = "left",
string = "Subnet mask:",
width = popup_width / 2,
},
function()
-- Get current WiFi info
sbar.exec(
"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I",
function(currentWifi)
-- Extract SSID
local ssid = string.match(currentWifi, "SSID: (.-)\n")
label = {
string = "???.???.???.???",
width = popup_width / 2,
align = "right",
}
})

-- Extract current transmission rate
local currTx = string.match(currentWifi, "lastTxRate: (.-)\n")
local router = sbar.add("item", {
position = "popup." .. wifi.name,
icon = {
align = "left",
string = "Router:",
width = popup_width / 2,
},
label = {
string = "???.???.???.???",
width = popup_width / 2,
align = "right",
},
})

if IS_EMPTY(ssid) then
wifi:set({ icon = { string = icons.wifi_off } })
wifi.details:set({ label = "No WiFi" })
return
end

wifi:set({
icon = {
string = icons.wifi,
},
})
wifi.details:set({
label = ssid .. " (" .. currTx .. "Mbps)"
})
end)
wifi:subscribe({ "wifi_change", "system_woke" }, function(env)
sbar.exec("ipconfig getifaddr en0", function(ip)
local connected = not (ip == "")
wifi:set({
icon = {
string = connected and icons.wifi or icons.wifi_off,
},
})
end)
end)

wifi:subscribe({
"mouse.exited",
Expand All @@ -87,6 +135,36 @@ wifi:subscribe({
},
function(_)
wifi:set({ popup = { drawing = true } })
sbar.exec("networksetup -getcomputername", function(result)
hostname:set({ label = result })
end)
sbar.exec("ipconfig getifaddr en0", function(result)
ip:set({ label = result })
end)
sbar.exec("ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}'", function(result)
ssid:set({ label = result })
end)
sbar.exec("networksetup -getinfo Wi-Fi | awk -F 'Subnet mask: ' '/^Subnet mask: / {print $2}'", function(result)
mask:set({ label = result })
end)
sbar.exec("networksetup -getinfo Wi-Fi | awk -F 'Router: ' '/^Router: / {print $2}'", function(result)
router:set({ label = result })
end)
end)

local function copy_label_to_clipboard(env)
local label = sbar.query(env.NAME).label.value
sbar.exec("echo \"" .. label .. "\" | pbcopy")
sbar.set(env.NAME, { label = { string = icons.clipboard, align = "center" } })
sbar.delay(1, function()
sbar.set(env.NAME, { label = { string = label, align = "right" } })
end)
end

ssid:subscribe("mouse.clicked", copy_label_to_clipboard)
hostname:subscribe("mouse.clicked", copy_label_to_clipboard)
ip:subscribe("mouse.clicked", copy_label_to_clipboard)
mask:subscribe("mouse.clicked", copy_label_to_clipboard)
router:subscribe("mouse.clicked", copy_label_to_clipboard)

return wifi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ local settings = require('settings')
local colors = require('colors')
local icons = require('icons')

sbar.exec("killall sketchy_cpu_load >/dev/null; sketchy_cpu_load cpu_update 2.0")

local cpu = sbar.add("item", "cpu", {
background = {
padding_left = 0,
Expand All @@ -22,8 +24,34 @@ local cpu = sbar.add("item", "cpu", {
color = colors.blue
},
update_freq = 2,
mach_helper = "git.felix.sketchyhelper",
position = "right"
})

cpu:subscribe("cpu_update", function(env)
-- Also available: env.user_load, env.sys_load
local load = tonumber(env.total_load)

local color = colors.text
if load > 30 then
if load < 60 then
color = colors.yellow
elseif load < 80 then
color = colors.peach
else
color = colors.red
end
end

cpu:set({
label = {
string = env.total_load .. "%",
color = color
},
})
end)

cpu:subscribe("mouse.clicked", function(env)
sbar.exec("open -a 'Activity Monitor'")
end)

return cpu
Loading

0 comments on commit 8360e92

Please sign in to comment.