forked from Shinonome/dots-hyprland
sidebar: ai: latex: support dark mode
This commit is contained in:
@@ -84,6 +84,6 @@ console.log('uwu');
|
|||||||
- Random instruction thing
|
- Random instruction thing
|
||||||
- To update arch lincox, run \`sudo pacman -Syu\`
|
- To update arch lincox, run \`sudo pacman -Syu\`
|
||||||
\`\`\`tex
|
\`\`\`tex
|
||||||
\\frac{d}{dx} \\left( \\frac{x-438}{x^2+23x-7} \\right) = \\frac{-x^2 + 869}{(x^2+23x-7)^2} hmmmmmm \\frac{d}{dx} \\left( \\frac{x-438}{x^2+23x-7} \\right) = \\frac{-x^2 + 869}{(x^2+23x-7)^2}
|
\\frac{d}{dx} \\left( \\frac{x-438}{x^2+23x-7} \\right) = \\frac{-x^2 + 869}{(x^2+23x-7)^2} \\\\ \\frac{d}{dx} \\left( \\frac{x-438}{x^2+23x-7} \\right) = \\frac{-x^2 + 869}{(x^2+23x-7)^2}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`;
|
`;
|
||||||
@@ -9,7 +9,7 @@ export const hasFlatpak = !!exec(`bash -c 'command -v flatpak'`);
|
|||||||
|
|
||||||
const LIGHTDARK_FILE_LOCATION = `${GLib.get_user_cache_dir()}/ags/user/colormode.txt`;
|
const LIGHTDARK_FILE_LOCATION = `${GLib.get_user_cache_dir()}/ags/user/colormode.txt`;
|
||||||
const colorMode = Utils.exec('bash -c "sed -n \'1p\' $HOME/.cache/ags/user/colormode.txt"');
|
const colorMode = Utils.exec('bash -c "sed -n \'1p\' $HOME/.cache/ags/user/colormode.txt"');
|
||||||
export let darkMode = !(Utils.readFile(LIGHTDARK_FILE_LOCATION).trim() == 'light');
|
export let darkMode = !(Utils.readFile(LIGHTDARK_FILE_LOCATION).split('\n')[0].trim() == 'light');
|
||||||
export const hasPlasmaIntegration = !!Utils.exec('bash -c "command -v plasma-browser-integration-host"');
|
export const hasPlasmaIntegration = !!Utils.exec('bash -c "command -v plasma-browser-integration-host"');
|
||||||
|
|
||||||
export const getDistroIcon = () => {
|
export const getDistroIcon = () => {
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ const { Box, Button, Label, Icon, Scrollable } = Widget;
|
|||||||
const { execAsync, exec } = Utils;
|
const { execAsync, exec } = Utils;
|
||||||
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||||
import md2pango from '../../.miscutils/md2pango.js';
|
import md2pango from '../../.miscutils/md2pango.js';
|
||||||
|
import { darkMode } from "../../.miscutils/system.js";
|
||||||
|
|
||||||
const LATEX_DIR = `${GLib.get_user_cache_dir()}/ags/media/latex`;
|
const LATEX_DIR = `${GLib.get_user_cache_dir()}/ags/media/latex`;
|
||||||
const CUSTOM_SOURCEVIEW_SCHEME_PATH = `${App.configDir}/assets/themes/sourceviewtheme.xml`;
|
const CUSTOM_SOURCEVIEW_SCHEME_PATH = `${App.configDir}/assets/themes/sourceviewtheme.xml`;
|
||||||
const CUSTOM_SCHEME_ID = 'custom';
|
const CUSTOM_SCHEME_ID = 'custom';
|
||||||
const USERNAME = GLib.get_user_name();
|
const USERNAME = GLib.get_user_name();
|
||||||
Gtk.IconTheme.get_default().append_search_path(LATEX_DIR);
|
|
||||||
|
|
||||||
/////////////////////// Custom source view colorscheme /////////////////////////
|
/////////////////////// Custom source view colorscheme /////////////////////////
|
||||||
|
|
||||||
@@ -77,11 +77,12 @@ const TextBlock = (content = '') => Label({
|
|||||||
|
|
||||||
Utils.execAsync(['bash', '-c', `rm ${LATEX_DIR}/*`])
|
Utils.execAsync(['bash', '-c', `rm ${LATEX_DIR}/*`])
|
||||||
.then(() => Utils.execAsync(['bash', '-c', `mkdir -p ${LATEX_DIR}`]))
|
.then(() => Utils.execAsync(['bash', '-c', `mkdir -p ${LATEX_DIR}`]))
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
const Latex = (content = '') => {
|
const Latex = (content = '') => {
|
||||||
const latexViewArea = Box({
|
const latexViewArea = Box({
|
||||||
// vscroll: 'never',
|
// vscroll: 'never',
|
||||||
// hscroll: 'automatic',
|
// hscroll: 'automatic',
|
||||||
|
homogeneous: true,
|
||||||
attribute: {
|
attribute: {
|
||||||
render: async (self, text) => {
|
render: async (self, text) => {
|
||||||
if (text.length == 0) return;
|
if (text.length == 0) return;
|
||||||
@@ -91,6 +92,7 @@ const Latex = (content = '') => {
|
|||||||
const timeSinceEpoch = Date.now();
|
const timeSinceEpoch = Date.now();
|
||||||
const fileName = `${timeSinceEpoch}.tex`;
|
const fileName = `${timeSinceEpoch}.tex`;
|
||||||
const outFileName = `${timeSinceEpoch}-symbolic.svg`;
|
const outFileName = `${timeSinceEpoch}-symbolic.svg`;
|
||||||
|
const outIconName = `${timeSinceEpoch}-symbolic`;
|
||||||
const scriptFileName = `${timeSinceEpoch}-render.sh`;
|
const scriptFileName = `${timeSinceEpoch}-render.sh`;
|
||||||
const filePath = `${LATEX_DIR}/${fileName}`;
|
const filePath = `${LATEX_DIR}/${fileName}`;
|
||||||
const outFilePath = `${LATEX_DIR}/${outFileName}`;
|
const outFilePath = `${LATEX_DIR}/${outFileName}`;
|
||||||
@@ -104,13 +106,17 @@ const Latex = (content = '') => {
|
|||||||
const renderScript = `#!/usr/bin/env bash
|
const renderScript = `#!/usr/bin/env bash
|
||||||
text=$(cat ${filePath} | sed 's/$/ \\\\\\\\/g' | sed 's/&=/=/g')
|
text=$(cat ${filePath} | sed 's/$/ \\\\\\\\/g' | sed 's/&=/=/g')
|
||||||
LaTeX -headless -input="$text" -output=${outFilePath} -textsize=${fontSize * 1.1} -padding=0 -maxwidth=${latexViewArea.get_allocated_width() * 0.85}
|
LaTeX -headless -input="$text" -output=${outFilePath} -textsize=${fontSize * 1.1} -padding=0 -maxwidth=${latexViewArea.get_allocated_width() * 0.85}
|
||||||
|
sed -i 's/fill="rgb(0%, 0%, 0%)"/style="fill:#000000"/g' ${outFilePath}
|
||||||
|
sed -i 's/stroke="rgb(0%, 0%, 0%)"/stroke="${darkMode ? '#ffffff' : '#000000'}"/g' ${outFilePath}
|
||||||
`;
|
`;
|
||||||
Utils.writeFile(renderScript, scriptFilePath).catch(print);
|
Utils.writeFile(renderScript, scriptFilePath).catch(print);
|
||||||
Utils.exec(`chmod a+x ${scriptFilePath}`)
|
Utils.exec(`chmod a+x ${scriptFilePath}`)
|
||||||
Utils.timeout(100, () => {
|
Utils.timeout(100, () => {
|
||||||
Utils.exec(`bash ${scriptFilePath}`);
|
Utils.exec(`bash ${scriptFilePath}`);
|
||||||
|
Gtk.IconTheme.get_default().append_search_path(LATEX_DIR);
|
||||||
|
|
||||||
self.child?.destroy();
|
self.child?.destroy();
|
||||||
self.child = Gtk.Image.new_from_file(outFilePath);
|
self.child = Gtk.Image.new_from_icon_name(outIconName, 0);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -251,7 +251,6 @@ const WaifuImage = (taglist) => {
|
|||||||
else Utils.execAsync(['bash', '-c', `wget -O '${thisBlock.attribute.imagePath}' '${url}'`])
|
else Utils.execAsync(['bash', '-c', `wget -O '${thisBlock.attribute.imagePath}' '${url}'`])
|
||||||
.then(showImage)
|
.then(showImage)
|
||||||
.catch(print);
|
.catch(print);
|
||||||
console.log(`background-color: mix(${darkMode ? 'black' : 'white'}, ${dominant_color}, 0.97);`);
|
|
||||||
thisBlock.css = `background-color: mix(${darkMode ? 'black' : 'white'}, ${dominant_color}, 0.97);`;
|
thisBlock.css = `background-color: mix(${darkMode ? 'black' : 'white'}, ${dominant_color}, 0.97);`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -641,9 +641,6 @@ $colorpicker_rounding: 0.341rem;
|
|||||||
margin: 0rem 0.682rem;
|
margin: 0rem 0.682rem;
|
||||||
padding: 0.682rem;
|
padding: 0.682rem;
|
||||||
|
|
||||||
@if $darkmode == True {
|
|
||||||
background-color: #e6e6e6;
|
|
||||||
}
|
|
||||||
color: $onBackground;
|
color: $onBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user