forked from Shinonome/dots-hyprland
refractor: clamp, distro; add distro icon next to uptime
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
|
||||
export function clamp(x, min, max) {
|
||||
return Math.min(Math.max(x, min), max);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
const { execAsync, exec } = Utils;
|
||||
|
||||
export const distroID = exec(`bash -c 'cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2'`).trim();
|
||||
export const isDebianDistro = (distroID == 'linuxmint' || distroID == 'ubuntu' || distroID == 'debian' || distroID == 'zorin' || distroID == 'popos' || distroID == 'raspbian' || distroID == 'kali' || distroID == 'elementary');
|
||||
export const isArchDistro = (distroID == 'arch' || distroID == 'endeavouros' || distroID == 'cachyos');
|
||||
export const hasFlatpak = !!exec(`bash -c 'command -v flatpak'`);
|
||||
|
||||
export const getDistroIcon = () => {
|
||||
if(distroID == 'linuxmint') return 'ubuntu-symbolic';
|
||||
if(distroID == 'ubuntu') return 'ubuntu-symbolic';
|
||||
if(distroID == 'debian') return 'debian-symbolic';
|
||||
if(distroID == 'zorin') return 'ubuntu-symbolic';
|
||||
if(distroID == 'popos') return 'ubuntu-symbolic';
|
||||
if(distroID == 'raspbian') return 'debian-symbolic';
|
||||
if(distroID == 'kali') return 'debian-symbolic';
|
||||
if(distroID == 'elementary') return 'debian-symbolic';
|
||||
if(distroID == 'arch') return 'arch-symbolic';
|
||||
if(distroID == 'endeavouros') return 'endeavouros-symbolic';
|
||||
if(distroID == 'cachyos') return 'cachyos-symbolic';
|
||||
return 'linux-symbolic';
|
||||
}
|
||||
|
||||
export const getDistroName = () => {
|
||||
if(distroID == 'linuxmint') return 'Linux Mint';
|
||||
if(distroID == 'ubuntu') return 'Ubuntu';
|
||||
if(distroID == 'debian') return 'Debian';
|
||||
if(distroID == 'zorin') return 'Zorin';
|
||||
if(distroID == 'pop') return 'Pop!_OS';
|
||||
if(distroID == 'raspbian') return 'Raspbian';
|
||||
if(distroID == 'kali') return 'Kali Linux';
|
||||
if(distroID == 'elementary') return 'elementary OS';
|
||||
if(distroID == 'arch') return 'Arch Linux';
|
||||
if(distroID == 'endeavouros') return 'EndeavourOS';
|
||||
if(distroID == 'cachyos') return 'CachyOS';
|
||||
return 'Linux';
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
|
||||
import Wallpaper from '../../services/wallpaper.js';
|
||||
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||
import { clamp } from '../.miscutils/mathfuncs.js';
|
||||
|
||||
const DISABLE_AGS_WALLPAPER = true;
|
||||
|
||||
@@ -18,10 +19,6 @@ const MAX_WORKSPACES = 10;
|
||||
const WALLPAPER_OFFSCREEN_X = (WALLPAPER_ZOOM_SCALE - 1) * SCREEN_WIDTH;
|
||||
const WALLPAPER_OFFSCREEN_Y = (WALLPAPER_ZOOM_SCALE - 1) * SCREEN_HEIGHT;
|
||||
|
||||
function clamp(x, min, max) {
|
||||
return Math.min(Math.max(x, min), max);
|
||||
}
|
||||
|
||||
|
||||
export default (monitor = 0) => {
|
||||
const wallpaperImage = Widget.DrawingArea({
|
||||
|
||||
@@ -3,8 +3,7 @@ const { Gio, GLib } = imports.gi;
|
||||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
const { exec, execAsync } = Utils;
|
||||
|
||||
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||
import { clamp } from '../../.miscutils/mathfuncs.js';
|
||||
|
||||
export class ColorPickerSelection extends Service {
|
||||
static {
|
||||
|
||||
@@ -11,8 +11,7 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
|
||||
import { ColorPickerSelection, hslToHex, hslToRgbValues, hexToHSL } from './color.js';
|
||||
|
||||
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||
import { clamp } from '../../.miscutils/mathfuncs.js';
|
||||
|
||||
export default () => {
|
||||
const selectedColor = new ColorPickerSelection();
|
||||
|
||||
@@ -9,10 +9,8 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
|
||||
Gtk.IconTheme.get_default().append_search_path(`${App.configDir}/assets/icons`);
|
||||
const distroID = exec(`bash -c 'cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2'`).trim();
|
||||
const isDebianDistro = (distroID == 'linuxmint' || distroID == 'ubuntu' || distroID == 'debian' || distroID == 'zorin' || distroID == 'pop' || distroID == 'raspbian' || distroID == 'kali' || distroID == 'elementary');
|
||||
const isArchDistro = (distroID == 'arch' || distroID == 'endeavouros' || distroID == 'cachyos');
|
||||
const hasFlatpak = !!exec(`bash -c 'command -v flatpak'`);
|
||||
import { distroID, isArchDistro, isDebianDistro, hasFlatpak } from '../../.miscutils/system.js';
|
||||
|
||||
|
||||
const scripts = [
|
||||
{
|
||||
|
||||
@@ -16,10 +16,15 @@ import {
|
||||
} from "./quicktoggles.js";
|
||||
import ModuleNotificationList from "./notificationlist.js";
|
||||
import { ModuleCalendar } from "./calendar.js";
|
||||
import { getDistroIcon } from '../.miscutils/system.js';
|
||||
|
||||
const timeRow = Box({
|
||||
className: 'spacing-h-5 sidebar-group-invisible-morehorizpad',
|
||||
className: 'spacing-h-10 sidebar-group-invisible-morehorizpad',
|
||||
children: [
|
||||
Widget.Icon({
|
||||
icon: getDistroIcon(),
|
||||
className: 'txt txt-larger',
|
||||
}),
|
||||
Widget.Label({
|
||||
hpack: 'center',
|
||||
className: 'txt-small txt',
|
||||
|
||||
Reference in New Issue
Block a user