user config round 2 (#271)

This commit is contained in:
end-4
2024-03-01 23:49:18 +07:00
parent e1bb1c9790
commit b1b4fd4394
15 changed files with 71 additions and 56 deletions
+14
View File
@@ -0,0 +1,14 @@
const { Gio, GLib, Gtk } = imports.gi;
export function fileExists(filePath) {
let file = Gio.File.new_for_path(filePath);
return file.query_exists(null);
}
export function expandTilde(path) {
if (path.startsWith('~')) {
return GLib.get_home_dir() + path.slice(1);
} else {
return path;
}
}
@@ -1,16 +1,16 @@
const { Gdk, GdkPixbuf, Gio, GLib, Gtk } = imports.gi;
const { Gdk, GdkPixbuf, GLib, Gtk } = imports.gi;
import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
const { exec, execAsync } = Utils;
import Mpris from 'resource:///com/github/Aylur/ags/service/mpris.js';
const { exec, execAsync } = Utils;
const { Box, EventBox, Icon, Scrollable, Label, Button, Revealer } = Widget;
import { fileExists } from '../.miscutils/files.js';
import { AnimatedCircProg } from "../.commonwidgets/cairo_circularprogress.js";
import { showMusicControls } from '../../variables.js';
const COMPILED_STYLE_DIR = `${GLib.get_user_cache_dir()}/ags/user/generated`
const LIGHTDARK_FILE_LOCATION = `${GLib.get_user_cache_dir()}/ags/user/colormode.txt`;
const lightDark = Utils.readFile(LIGHTDARK_FILE_LOCATION).trim();
const COVER_COLORSCHEME_SUFFIX = '_colorscheme.css';
@@ -31,10 +31,6 @@ function lengthStr(length) {
const sec0 = sec < 10 ? '0' : '';
return `${min}:${sec0}${sec}`;
}
function fileExists(filePath) {
let file = Gio.File.new_for_path(filePath);
return file.query_exists(null);
}
function detectMediaSource(link) {
if (link.startsWith("file://")) {
@@ -12,7 +12,6 @@ const LATEX_DIR = `${GLib.get_user_cache_dir()}/ags/media/latex`;
const CUSTOM_SOURCEVIEW_SCHEME_PATH = `${App.configDir}/assets/themes/sourceviewtheme.xml`;
const CUSTOM_SCHEME_ID = 'custom';
const USERNAME = GLib.get_user_name();
const AI_MESSAGE_CURSOR = ' ...';
/////////////////////// Custom source view colorscheme /////////////////////////
@@ -258,7 +257,7 @@ const MessageContent = (content) => {
const lastLabel = kids[kids.length - 1];
let blockContent = lines.slice(lastProcessed, lines.length).join('\n');
if (!inCode)
lastLabel.label = `${md2pango(blockContent)}${useCursor ? AI_MESSAGE_CURSOR : ''}`;
lastLabel.label = `${md2pango(blockContent)}${useCursor ? userOptions.ai.writingCursor : ''}`;
else
lastLabel.attribute.updateText(blockContent);
}
+2 -6
View File
@@ -6,6 +6,7 @@ import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
const { Box, Button, Label, Overlay, Revealer, Scrollable, Stack } = Widget;
const { execAsync, exec } = Utils;
import { fileExists } from '../../.miscutils/files.js';
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
import { MarginRevealer } from '../../.widgethacks/advancedrevealers.js';
import { setupCursorHover, setupCursorHoverInfo } from '../../.widgetutils/cursorhover.js';
@@ -20,18 +21,13 @@ async function getImageViewerApp(preferredApp) {
}
const IMAGE_REVEAL_DELAY = 13; // Some wait for inits n other weird stuff
const IMAGE_VIEWER_APP = getImageViewerApp('loupe'); // Gnome's image viewer cuz very comfortable zooming
const IMAGE_VIEWER_APP = getImageViewerApp(userOptions.apps.imageViewer); // Gnome's image viewer cuz very comfortable zooming
const USER_CACHE_DIR = GLib.get_user_cache_dir();
// Create cache folder and clear pics from previous session
Utils.exec(`bash -c 'mkdir -p ${USER_CACHE_DIR}/ags/media/waifus'`);
Utils.exec(`bash -c 'rm ${USER_CACHE_DIR}/ags/media/waifus/*'`);
export function fileExists(filePath) {
let file = Gio.File.new_for_path(filePath);
return file.query_exists(null);
}
const CommandButton = (command) => Button({
className: 'sidebar-chat-chip sidebar-chat-chip-action txt txt-small',
onClicked: () => sendMessage(command),
@@ -14,7 +14,6 @@ import { waifuView, waifuCommands, sendMessage as waifuSendMessage, waifuTabIcon
import { enableClickthrough } from "../.widgetutils/clickthrough.js";
const TextView = Widget.subclass(Gtk.TextView, "AgsTextView");
const EXPAND_INPUT_THRESHOLD = 30;
const APIS = [
{
+1 -1
View File
@@ -9,7 +9,7 @@ import { setupCursorHover } from '../.widgetutils/cursorhover.js';
import { NavigationIndicator } from '../.commonwidgets/cairo_navigationindicator.js';
import toolBox from './toolbox.js';
import apiWidgets from './apiwidgets.js';
import apiwidgets, { chatEntry } from './apiwidgets.js';
import { chatEntry } from './apiwidgets.js';
const contents = [
{
+1 -3
View File
@@ -1,7 +1,5 @@
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
const { Box, Button, EventBox, Label, Revealer, Scrollable, Stack } = Widget;
const { execAsync, exec } = Utils;
const { Box, Scrollable } = Widget;
import QuickScripts from './tools/quickscripts.js';
import ColorPicker from './tools/colorpicker.js';
@@ -11,7 +11,6 @@ import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
Gtk.IconTheme.get_default().append_search_path(`${App.configDir}/assets/icons`);
import { distroID, isArchDistro, isDebianDistro, hasFlatpak } from '../../.miscutils/system.js';
const scripts = [
{
icon: 'nixos-symbolic',
@@ -11,11 +11,6 @@ import { getCalendarLayout } from "./calendar_layout.js";
let calendarJson = getCalendarLayout(undefined, true);
let monthshift = 0;
function fileExists(filePath) {
let file = Gio.File.new_for_path(filePath);
return file.query_exists(null);
}
function getDateInXMonthsTime(x) {
var currentDate = new Date(); // Get the current date
var targetMonth = currentDate.getMonth() + x; // Calculate the target month
@@ -10,14 +10,6 @@ import { BluetoothIndicator, NetworkIndicator } from '../.commonwidgets/statusic
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
function expandTilde(path) {
if (path.startsWith('~')) {
return GLib.get_home_dir() + path.slice(1);
} else {
return path;
}
}
export const ToggleIconWifi = (props = {}) => Widget.Button({
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Wifi | Right-click to configure',
@@ -123,7 +115,7 @@ export const ModuleInvertColors = async (props = {}) => {
button.toggleClassName('sidebar-button-active', false);
}
else {
Hyprland.messageAsync(`j/keyword decoration:screen_shader ${expandTilde('~/.config/hypr/shaders/invert.frag')}`)
Hyprland.messageAsync(`j/keyword decoration:screen_shader ${GLib.get_home_dir()}/.config/hypr/shaders/invert.frag`)
.catch(print);
button.toggleClassName('sidebar-button-active', true);
}