forked from Shinonome/dots-hyprland
add ask gemini button in search
This commit is contained in:
@@ -5,6 +5,7 @@ import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
|||||||
const { execAsync, exec } = Utils;
|
const { execAsync, exec } = Utils;
|
||||||
import { searchItem } from './searchitem.js';
|
import { searchItem } from './searchitem.js';
|
||||||
import { execAndClose, couldBeMath, launchCustomCommand } from './miscfunctions.js';
|
import { execAndClose, couldBeMath, launchCustomCommand } from './miscfunctions.js';
|
||||||
|
import GeminiService from '../../services/gemini.js';
|
||||||
|
|
||||||
export const DirectoryButton = ({ parentPath, name, type, icon }) => {
|
export const DirectoryButton = ({ parentPath, name, type, icon }) => {
|
||||||
const actionText = Widget.Revealer({
|
const actionText = Widget.Revealer({
|
||||||
@@ -160,4 +161,16 @@ export const SearchButton = ({ text = '' }) => searchItem({
|
|||||||
App.closeWindow('overview');
|
App.closeWindow('overview');
|
||||||
execAsync(['bash', '-c', `xdg-open '${userOptions.search.engineBaseUrl}${text} ${['', ...userOptions.search.excludedSites].join(' -site:')}' &`]).catch(print);
|
execAsync(['bash', '-c', `xdg-open '${userOptions.search.engineBaseUrl}${text} ${['', ...userOptions.search.excludedSites].join(' -site:')}' &`]).catch(print);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const AiButton = ({ text }) => searchItem({
|
||||||
|
materialIconName: 'chat_paste_go',
|
||||||
|
name: 'Ask Gemini',
|
||||||
|
actionName: 'Ask',
|
||||||
|
content: `${text}`,
|
||||||
|
onActivate: () => {
|
||||||
|
GeminiService.send(text);
|
||||||
|
App.closeWindow('overview');
|
||||||
|
App.openWindow('sideleft');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ const { execAsync, exec } = Utils;
|
|||||||
import { execAndClose, expandTilde, hasUnterminatedBackslash, couldBeMath, launchCustomCommand, ls } from './miscfunctions.js';
|
import { execAndClose, expandTilde, hasUnterminatedBackslash, couldBeMath, launchCustomCommand, ls } from './miscfunctions.js';
|
||||||
import {
|
import {
|
||||||
CalculationResultButton, CustomCommandButton, DirectoryButton,
|
CalculationResultButton, CustomCommandButton, DirectoryButton,
|
||||||
DesktopEntryButton, ExecuteCommandButton, SearchButton
|
DesktopEntryButton, ExecuteCommandButton, SearchButton, AiButton
|
||||||
} from './searchbuttons.js';
|
} from './searchbuttons.js';
|
||||||
import { checkKeybind } from '../.widgetutils/keybind.js';
|
import { checkKeybind } from '../.widgetutils/keybind.js';
|
||||||
|
import GeminiService from '../../services/gemini.js';
|
||||||
|
|
||||||
// Add math funcs
|
// Add math funcs
|
||||||
const { abs, sin, cos, tan, cot, asin, acos, atan, acot } = Math;
|
const { abs, sin, cos, tan, cot, asin, acos, atan, acot } = Math;
|
||||||
@@ -140,8 +141,9 @@ export const SearchAndWindows = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
GeminiService.send(text);
|
||||||
App.closeWindow('overview');
|
App.closeWindow('overview');
|
||||||
execAsync(['bash', '-c', `xdg-open '${userOptions.search.engineBaseUrl}${text} ${['', ...userOptions.search.excludedSites].join(' -site:')}' &`]).catch(print);
|
App.openWindow('sideleft');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onChange: (entry) => { // this is when you type
|
onChange: (entry) => { // this is when you type
|
||||||
@@ -200,6 +202,7 @@ export const SearchAndWindows = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add fallback: search
|
// Add fallback: search
|
||||||
|
resultsBox.add(AiButton({ text: entry.text }));
|
||||||
resultsBox.add(SearchButton({ text: entry.text }));
|
resultsBox.add(SearchButton({ text: entry.text }));
|
||||||
resultsBox.show_all();
|
resultsBox.show_all();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user