From 666a0478141cc56e6249ded348404a2a7f9d7658 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Sun, 30 Mar 2025 08:00:10 +0200 Subject: [PATCH] [Launcher] fzf, cmd processing, args --- config/ags/launcher/app.ts | 9 +++++++++ config/ags/launcher/util/fzf.ts | 22 ++++++++++++++++++++++ config/ags/launcher/util/search.ts | 10 +++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/config/ags/launcher/app.ts b/config/ags/launcher/app.ts index 7e8cc7c..898ad85 100644 --- a/config/ags/launcher/app.ts +++ b/config/ags/launcher/app.ts @@ -7,4 +7,13 @@ App.start({ main() { App.get_monitors().map(Bar) }, + requestHandler(request, res) { + if ( request === 'open' ) { + res( 'ok' ); + } else if ( request === 'close' ) { + res( 'ok' ); + } else if ( request === 'toggle' ) { + res( 'ok' ); + } + } }) diff --git a/config/ags/launcher/util/fzf.ts b/config/ags/launcher/util/fzf.ts index e69de29..380daf9 100644 --- a/config/ags/launcher/util/fzf.ts +++ b/config/ags/launcher/util/fzf.ts @@ -0,0 +1,22 @@ +/* +* dotfiles - fzf.ts +* +* Created by Janis Hutz 03/30/2025, Licensed under the GPL V3 License +* https://janishutz.com, development@janishutz.com +* +* +*/ + +import AstalApps from "gi://AstalApps?version=0.1" + +// TODO: For all astal apps, read a global colours config file +const fzfApplication = ( query: string ) => { + const apps = new AstalApps.Apps() + return apps.fuzzy_query( query ); +} + +const fzfCmd = ( query: string ) => {} + +export default { + fzfApplication +} diff --git a/config/ags/launcher/util/search.ts b/config/ags/launcher/util/search.ts index 895461e..f150ab4 100644 --- a/config/ags/launcher/util/search.ts +++ b/config/ags/launcher/util/search.ts @@ -8,6 +8,7 @@ */ import subprocessRunner from "./subprocessRunner"; +import fzf from "./fzf"; const preprocess = ( input: string ) => { // Find out what kind of instruction to process @@ -19,8 +20,11 @@ const preprocess = ( input: string ) => { // Determine if entered string is calculation or not // We can easily do that by asking qalc (qalculate cli) if this is fine subprocessRunner.executeCommand( 'qalc "' + input + '"' ).then( out => { + // we get a calculation result here print( out ); + processCalculation( out ); } ).catch( err => { + processSearch( input ); print( err ); } ); } @@ -30,7 +34,7 @@ const processSearch = ( input: string ) => { } -const processCalculation = ( input: string ) => { +const processCalculation = ( output: string ) => { } @@ -41,3 +45,7 @@ const processCommand = ( cmd: string, args: string[] ) => { const processBang = ( bang: string, input: string ) => { } + +export default { + preprocess +}