Skip to content

Commit

Permalink
feat: Update
Browse files Browse the repository at this point in the history
  • Loading branch information
heraldofsolace committed Oct 27, 2024
1 parent 55706fa commit 01f1985
Show file tree
Hide file tree
Showing 337 changed files with 37,425 additions and 528 deletions.
10 changes: 10 additions & 0 deletions cells/common/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,15 @@ in {
wrapNeovimUnstable
upower
gamemode
criterion
power-profiles-daemon
;

nanopb-generator-out = latest.nanopb-generator-out.overrideAttrs (oldAttrs: {
patches =
oldAttrs.patches
++ [
./_files/nanopb-generator-out.patch
];
});
}
70 changes: 70 additions & 0 deletions cells/common/packages/_aags-config/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,73 @@ export function createSurfaceFromWidget(widget: Gtk.Widget) {
widget.draw(cr);
return surface;
}

export const closeAllMenus = () => {
const menuWindows = App.windows
.filter((w) => {
if (w.name) {
return /.*menu/.test(w.name);
}

return false;
})
.map((w) => w.name);

menuWindows.forEach((w) => {
if (w) {
App.closeWindow(w);
}
});
};

export const openMenu = (clicked: any, event: Gdk.Event, window: string) => {
/*
* NOTE: We have to make some adjustments so the menu pops up relatively
* to the center of the button clicked. We don't want the menu to spawn
* offcenter dependending on which edge of the button you click on.
* -------------
* To fix this, we take the x coordinate of the click within the button's bounds.
* If you click the left edge of a 100 width button, then the x axis will be 0
* and if you click the right edge then the x axis will be 100.
* -------------
* Then we divide the width of the button by 2 to get the center of the button and then get
* the offset by subtracting the clicked x coordinate. Then we can apply that offset
* to the x coordinate of the click relative to the screen to get the center of the
* icon click.
*/

const middleOfButton = Math.floor(clicked.get_allocated_width() / 2);
const xAxisOfButtonClick = clicked.get_pointer()[0];
const middleOffset = middleOfButton - xAxisOfButtonClick;

const clickPos = event.get_root_coords();
const adjustedXCoord = clickPos[1] + middleOffset;
const coords = [adjustedXCoord, clickPos[2]];

// globalMousePos.value = coords;

closeAllMenus();
App.toggleWindow(window);
};

export const getWifiIcon = (iconName: string) => {
const deviceIconMap = [
["network-wireless-acquiring", "󰤩"],
["network-wireless-connected", "󰤨"],
["network-wireless-encrypted", "󰤪"],
["network-wireless-hotspot", "󰤨"],
["network-wireless-no-route", "󰤩"],
["network-wireless-offline", "󰤮"],
["network-wireless-signal-excellent", "󰤨"],
["network-wireless-signal-good", "󰤥"],
["network-wireless-signal-ok", "󰤢"],
["network-wireless-signal-weak", "󰤟"],
["network-wireless-signal-none", "󰤯"],
];

const foundMatch = deviceIconMap.find((icon) =>
RegExp(icon[0]).test(iconName.toLowerCase()),
);

return foundMatch ? foundMatch[1] : "󰤨";
};
2 changes: 2 additions & 0 deletions cells/common/packages/_aags-config/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Verification from "widget/powermenu/Verification";
import { forMonitors } from "lib/utils";
import { setupQuickSettings } from "widget/quicksettings/QuickSettings";
import { setupDateMenu } from "widget/datemenu/DateMenu";
import NetworkMenu from "widget/networkmenu/NetworkMenu";

App.config({
onConfigParsed: () => {
Expand All @@ -37,5 +38,6 @@ App.config({
PowerMenu(),
SettingsDialog(),
Verification(),
NetworkMenu(),
],
});
25 changes: 25 additions & 0 deletions cells/common/packages/_aags-config/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
packages = with pkgs; [
(ags.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [pkgs.libdbusmenu-gtk3];
}))
accountsservice
brightnessctl
bun
dart-sass
fd
fzf
gtk3
hyprpicker
networkmanager
pavucontrol
slurp
swww
swappy
wayshot
wf-recorder
wl-clipboard
which
];
}
2 changes: 1 addition & 1 deletion cells/common/packages/_aags-config/style/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const variables = () => [

async function resetCss() {
if (!dependencies("sass", "fd")) return;

print(dark.bg.value);
try {
const vars = `${TMP}/variables.scss`;
const scss = `${TMP}/main.scss`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import PopupWindow from "widget/PopupWindow";
// import { Ethernet } from "./ethernet";
import { Wifi } from "./wifi";

export default () => {
return PopupWindow({
name: "networkmenu",
transition: "crossfade",
child: Widget.Box({
class_name: "menu-items network",
child: Widget.Box({
vertical: true,
hexpand: true,
class_name: "menu-items-container network",
children: [
// Ethernet(),
Wifi(),
],
}),
}),
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { Network } from "types/service/network";
import { Variable } from "types/variable";
import { AccessPoint } from "lib/types/network";
const renderWapStaging = (
self: any,
network: Network,
staging: Variable<AccessPoint>,
connecting: Variable<string>,
) => {
Utils.merge([network.bind("wifi"), staging.bind("value")], () => {
if (!Object.keys(staging.value).length) {
return (self.child = Widget.Box());
}

return (self.child = Widget.Box({
class_name: "network-element-item staging",
vertical: true,
children: [
Widget.Box({
hpack: "fill",
hexpand: true,
children: [
Widget.Icon({
class_name: `network-icon wifi`,
icon: `${staging.value.iconName}`,
}),
Widget.Box({
class_name: "connection-container",
hexpand: true,
vertical: true,
children: [
Widget.Label({
class_name: "active-connection",
hpack: "start",
truncate: "end",
wrap: true,
label: staging.value.ssid,
}),
],
}),
Widget.Revealer({
hpack: "end",
reveal_child: connecting
.bind("value")
.as((c) => staging.value.bssid === c),
child: Widget.Spinner({
class_name: "spinner wap",
}),
}),
],
}),
Widget.Box({
class_name: "network-password-input-container",
hpack: "fill",
hexpand: true,
children: [
Widget.Entry({
hpack: "start",
hexpand: true,
visibility: false,
class_name: "network-password-input",
placeholder_text: "enter password",
onAccept: (selfInp) => {
connecting.value = staging.value.bssid || "";
Utils.execAsync(
`nmcli dev wifi connect ${staging.value.bssid} password ${selfInp.text}`,
)
.catch((err) => {
connecting.value = "";
console.error(
`Failed to connect to wifi: ${staging.value.ssid}... ${err}`,
);
Utils.notify({
summary: "Network",
body: err,
timeout: 5000,
});
})
.then(() => {
connecting.value = "";
staging.value = {} as AccessPoint;
});
selfInp.text = "";
},
}),
Widget.Button({
hpack: "end",
class_name: "close-network-password-input-button",
on_primary_click: () => {
connecting.value = "";
staging.value = {} as AccessPoint;
},
child: Widget.Icon({
class_name: "close-network-password-input-icon",
icon: "window-close-symbolic",
}),
}),
],
}),
],
}));
});
};

export { renderWapStaging };
Loading

0 comments on commit 01f1985

Please sign in to comment.