This commit is contained in:
sankalp committed 2024-06-29 23:54:25 +05:45
1 parent 8fd6dc4221
commit 3e0f2abb9a
12 files changed
+179 -57

No files matched your search

+1 -1
View File
@@ -33,7 +33,7 @@ const BluetoothToggle = () => Widget.EventBox({
}),
Widget.Switch({
vexpand: false,
valign: Gtk.Align.CENTER,
hpack: "center",
hpack: "end",
on_activate: self => {
if (self.state != bluetooth.enabled)
+68
View File
@@ -0,0 +1,68 @@
import { Binding } from "types/service"
const GLib = imports.gi.GLib;
import { cpu_cores, cpu_name, kernel_name, amount_of_ram, gpu_name, hostname } from "variables";
type StringOrBinding = string | Binding<any, any, string> | null;
const empty_func = () => { };
const Row = (
title: StringOrBinding, description: StringOrBinding,
on_primary_click: any = empty_func, on_secondary_click: any = empty_func
) => Widget.EventBox({
class_name: "row",
on_primary_click: on_primary_click,
on_secondary_click: on_secondary_click,
child: Widget.Box({
class_name: "row",
vpack: "start",
children: [
Widget.Box({
vertical: true,
hexpand: true,
vpack: "center",
hpack: "start",
children: [
Widget.Label({
hpack: "start",
class_name: "title",
label: title
}),
Widget.Label({
hpack: "start",
class_name: "description",
label: description
})
]
}),
]
})
})
const repo_link = "https://github.com/S4NKALP/hyprland"
const current_de = GLib.getenv("DESKTOP_SESSION");
export function Info() {
const box = Widget.Box({
vertical: true,
children: [
Row("Dotfiles", "hyprland"),
Row("Author", "S4NKALP (Discord)"),
Row("Repo", repo_link, () => {
Utils.execAsync(`xdg-open "${repo_link}"`).catch(print)
}),
Widget.Separator(),
Row("DE", current_de!),
Row("Kernel", kernel_name),
Row("CPU", `${cpu_name} (${cpu_cores} Cores)`),
Row("GPU", `${gpu_name}`),
Row("Ram", amount_of_ram),
Row("Hostname", hostname)
],
})
return Widget.Scrollable({
hscroll: "never",
child: box,
vexpand: true
})
}
+4 -1
View File
@@ -2,6 +2,7 @@ import { RegularWindow } from "apps/window";
import { Network } from "./network";
import { Bluetooth } from "./bluetooth";
import { Wallpapers } from "./wallpapers";
import { Info } from "./info";
import { Widget as WidgetType } from "types/widgets/widget";
const hyprland = await Service.import("hyprland")
import Gtk from "gi://Gtk?version=3.0"
@@ -40,7 +41,8 @@ function Settings(cur_tab: string) {
children: {
"network": Page(Network(), "Network"),
"bluetooth": Page(Bluetooth(), "Bluetooth"),
"wallpaper": Page(Wallpapers(), "Wallpapers")
"wallpaper": Page(Wallpapers(), "Wallpapers"),
"info": Page(Info(), "Info")
}
})
const Row = (name: string, label: string, icon: string = "image-missing") => Widget.Button({
@@ -64,6 +66,7 @@ function Settings(cur_tab: string) {
Widget.Separator(),
Row("wallpaper", "Wallpapers", "folder-pictures-symbolic"),
Widget.Separator(),
Row("info", "Info", "dialog-information-symbolic"),
]
})
return Widget.Box({
+1 -1
View File
@@ -132,7 +132,7 @@ const WifiToggle = () => Widget.EventBox({
}),
Widget.Switch({
vexpand: false,
valign: Gtk.Align.CENTER,
vpack: "center",
hpack: "end",
on_activate(self) {
timeout(5, () => {
+30 -24
View File
@@ -1,15 +1,16 @@
const { GLib } = imports.gi;
const WINDOW_NAME = "cliphist"
import popupwindow from './misc/popupwindow.ts';
import Box from 'types/widgets/box.js';
const { Gtk } = imports.gi;
type EntryObject = {
id: string;
content: string;
entry: string;
};
function ClipHistItem(entry: string) {
let [id, ...content] = entry.split('\t');
let clickCount = 0;
@@ -22,13 +23,13 @@ function ClipHistItem(entry: string) {
vpack: "center",
truncate: "end",
})
});
})
button.connect('clicked', () => {
clickCount++;
if (clickCount === 1) {
if (clickCount === 2) {
App.closeWindow(WINDOW_NAME);
Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`);
Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`)
clickCount = 0;
}
});
@@ -44,12 +45,13 @@ function ClipHistItem(entry: string) {
button,
Widget.Separator({
class_name: "entry_divider",
orientation: Gtk.Orientation.HORIZONTAL,
}),
],
});
orientation: Gtk.Orientation.HORIZONTAL
})
]
})
}
function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
let output: string;
let entries: string[];
@@ -65,8 +67,8 @@ function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
output = await Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --get`)
.then(str => str)
.catch(err => {
print(err);
return "";
print(err)
return ""
});
entries = output.split('\n').filter(line => line.trim() !== '');
clipHistItems = entries.map(entry => {
@@ -82,13 +84,11 @@ function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
hexpand: true,
class_name: "cliphistory_entry",
placeholder_text: "Search",
on_change: ({ text }) => {
const lowerCaseText = (text ?? "").toLowerCase();
widgets.forEach(item => {
item.visible = item.attribute.content.toLowerCase().includes(lowerCaseText);
});
},
});
on_change: ({ text }) => widgets.forEach(item => {
item.visible = item.attribute.content.match(text ?? "")
}),
})
return Widget.Box({
vertical: true,
@@ -99,22 +99,27 @@ function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
entry,
Widget.Scrollable({
hscroll: "never",
css: `min-width: ${width}px; min-height: ${height}px;`,
css: `min-width: ${width}px;`
+ `min-height: ${height}px;`,
child: list,
}),
],
setup: self => self.hook(App, (_, windowName, visible) => {
if (windowName !== WINDOW_NAME) return;
if (windowName !== WINDOW_NAME)
return
if (visible) {
repopulate();
entry.text = "";
repopulate()
entry.text = ""
}
}),
});
})
}
export const cliphist = popupwindow({
name: WINDOW_NAME,
class_name: "cliphistory",
visible: false,
keymode: "exclusive",
@@ -123,5 +128,6 @@ export const cliphist = popupwindow({
height: 500,
spacing: 0,
}),
anchor: ["bottom", "right"],
});
//anchor: ["top", "right"]
anchor: ["bottom", "right"]
})
+3 -2
View File
@@ -73,7 +73,7 @@ export const Notification = (notification: NotificationType, dismiss = true) =>
}),
Widget.Label({
class_name: "notification-time",
label: GLib.DateTime.new_from_unix_local(notification.time).format("%H:%M"),
label: GLib.DateTime.new_from_unix_local(notification.time).format("%I:%M %p"),
}),
Widget.Button({
class_name: "standard_icon_button",
@@ -112,7 +112,7 @@ export const Notification = (notification: NotificationType, dismiss = true) =>
})
}),
Widget.Box({
halign: Gtk.Align.END,
hpack: "end",
class_name: "notification-actions",
children: notification.actions.map(action => Widget.Button({
child: Widget.Label(action.label),
@@ -245,6 +245,7 @@ export function Notifications(monitor = 0) {
monitor,
name: `notifications${monitor}`,
class_name: "notification-popups",
//anchor: ["top", "right"],
anchor: ["bottom", "right"],
type: Gtk.WindowType.POPUP,
child: Widget.Box({
+47 -10
View File
@@ -5,7 +5,7 @@ const network = await Service.import('network')
const powerProfiles = await Service.import('powerprofiles')
import { OpenSettings } from "apps/settings/main.ts";
import { WINDOW_NAME } from "./main.ts"
import { bluetooth_enabled, idle_inhibitor, night_light, screen_recorder, icons } from "variables.ts";
import { bluetooth_enabled, idle_inhibitor, night_light, screen_recorder } from "variables.ts";
const currentPage = Variable(0);
@@ -44,7 +44,7 @@ function WifiIndicator() {
label: "Internet",
}),
Widget.Box({
halign: Gtk.Align.END,
hpack: "end",
hexpand: true,
child: Widget.Label({
label: "",
@@ -95,7 +95,7 @@ function IconAndName({ label, icon, padding = "0.3em", arrow = false }) {
})
if (arrow) {
const arrow = Widget.Box({
halign: Gtk.Align.END,
hpack: "end",
hexpand: true,
child: Widget.Label({
label: "",
@@ -184,7 +184,7 @@ function Page1() {
.then(out => { bluetooth_enabled.setValue(out) })
},
on_secondary_click: () => {
Utils.execAsync("blueman-manager")
OpenSettings("bluetooth")
App.closeWindow(WINDOW_NAME)
}
})
@@ -333,8 +333,17 @@ function Page2() {
class_name: "management_button",
child: Widget.Box({
children: [
Widget.Label({
label: powerProfiles.bind('active_profile').as(x => icons[x])
IconAndName({
icon: powerProfiles.bind('active_profile').as(profile => {
switch (profile) {
case 'balanced':
return '';
case 'performance':
return '';
default:
return '';
}
})
}),
Widget.Label({
label: powerProfiles.bind('active_profile').as(x => x.toUpperCase())
@@ -352,11 +361,39 @@ function Page2() {
default:
powerProfiles.active_profile = 'power-saver';
break;
};
},
}
}
}),
]
})
}),
Widget.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 2.5,
hexpand: true,
children: [
Widget.Button({
hexpand: true,
class_name: "management_button",
child: IconAndName({
label: "Settings",
icon: "",
arrow: true,
}),
on_primary_click: () => {
OpenSettings()
App.CloseWindow(WINDOW_NAME);
}
}),
Widget.Box({
hexpand: true,
class_name: "management_button",
child: IconAndName({
label: "soon",
icon: "",
})
})
]
}),
]
})
}
@@ -401,7 +438,7 @@ export function Management() {
Widget.Box({
children: dotButtons,
class_name: "dotbuttons_box",
halign: Gtk.Align.CENTER,
hpack: "center",
})
]
})
+1 -1
View File
@@ -21,7 +21,7 @@ function Button({ page, label, icon }: ButtonType) {
children: [
Widget.Box({
orientation: Gtk.Orientation.VERTICAL,
halign: Gtk.Align.CENTER,
hpack: "end",
class_name: "container",
child: Widget.Label({
hpack: "center",
@@ -52,7 +52,7 @@ function Notification(n: NotificationType) {
})
const actions = Widget.Box({
halign: Gtk.Align.END,
hpack: "end",
class_name: "notification_sidebar_actions",
children: n.actions.map(({ id, label }) => Widget.Button({
class_name: "notification_sidebar_button",
+5 -10
View File
@@ -1,11 +1,5 @@
import { Variable as VariableType } from "types/variable";
const { Gtk } = imports.gi;
const cpu_name = await Utils.execAsync(`${App.configDir}/scripts/system.sh --cpu-name`);
const cpu_cores = await Utils.execAsync(`${App.configDir}/scripts/system.sh --cpu-cores`);
const amount_of_ram = await Utils.execAsync(`${App.configDir}/scripts/system.sh --ram`);
const kernel_name = await Utils.execAsync(`${App.configDir}/scripts/system.sh --kernel`);
import { cpu_cores, cpu_name, kernel_name, amount_of_ram, gpu_name } from "variables";
type InfoType = {
cpu: string,
@@ -93,8 +87,8 @@ const Usage = (
const usage_overlay = Widget.Overlay({
child: usage_progress_bar,
overlay: Widget.Box({
halign: Gtk.Align.END,
valign: Gtk.Align.CENTER,
hpack: "end",
vpack: "center",
class_name: "usage_bar_point"
})
})
@@ -190,7 +184,8 @@ export function SystemBox() {
InfoLabelString("CPU name", cpu_name, ""),
InfoLabelString("CPU cores", cpu_cores, ""),
InfoLabelString("RAM amount", amount_of_ram, ""),
InfoLabelString("Kernel", kernel_name, "")
InfoLabelString("Kernel", kernel_name, ""),
InfoLabelString("GPU", gpu_name, ""),
],
vexpand: true
})
+12
View File
@@ -29,6 +29,14 @@ get_kernel() {
uname -r
}
get_gpu() {
lshw -C display | grep "product" | awk -F ': ' '{print $2}'
}
get_hostname() {
cat /etc/hostname
}
if [[ "$1" == "--cpu-usage" ]]; then
get_cpu_usage
elif [[ "$1" == "--ram-usage" ]]; then
@@ -45,4 +53,8 @@ if [[ "$1" == "--cpu-usage" ]]; then
get_ram
elif [[ "$1" == "--kernel" ]]; then
get_kernel
elif [[ "$1" == "--gpu-name" ]]; then
get_gpu
elif [[ "$1" == "--hostname" ]]; then
get_hostname
fi
+6 -6
View File
@@ -10,12 +10,12 @@ export const bluetooth_enabled = Variable('off', {
})
export const icons = {
'performance': ' ',
'balanced': ' ',
'power-saver': '󰡵 '
};
export const cpu_name = await Utils.execAsync(`${App.configDir}/scripts/system.sh --cpu-name`);
export const gpu_name = await Utils.execAsync(`${App.configDir}/scripts/system.sh --gpu-name`);
export const cpu_cores = await Utils.execAsync(`${App.configDir}/scripts/system.sh --cpu-cores`);
export const amount_of_ram = await Utils.execAsync(`${App.configDir}/scripts/system.sh --ram`);
export const kernel_name = await Utils.execAsync(`${App.configDir}/scripts/system.sh --kernel`);
export const hostname = await Utils.execAsync(`${App.configDir}/scripts/system.sh --hostname`);
export const wallpaper_cache_file = `${GLib.get_home_dir()}/.cache/current_wallpaper`