8000 Add a dynamic script launcher · Issue #31 · raujonas/executor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a dynamic script launcher #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
snax44 opened this issue May 26, 2021 · 11 comments · Fixed by #32
Closed

Add a dynamic script launcher #31

snax44 opened this issue May 26, 2021 · 11 comments · Fixed by #32

Comments

@snax44
Copy link
Contributor
snax44 commented May 26, 2021

Hi,
First of all thank a lot for your work, this extension is awesome.

My goal was a little bit different, I wanted to show alternatively some infos (ip, cpu load, ram etc...)
So I use your extension to do that and keep profit of the other features.

  1. Make a scripts directory

As explain here for using custom.css, it's better to put your scripts in ~/.config/executor...
This way your custom css will NOT be overwritten by extension updates

mkdir ~/.config/executor@raujonas.github.io/scripts
  1. Put your scripts in the scripts directory (they must be executable and have a shebang)
    example:
#! /bin/bash

ping -W 1 -4 -c 1 ifconfig.me > /dev/null 2>&1

if [[ "$?" == "0" ]]; then
  WAN_IP=$(curl -s ifconfig.me)
else
  WAN_IP="Not connected"
fi

# Auto detect lan interface based on the default route.
LAN_INTERFACE=$(ip route show default | awk '/default/ {print $5}')

# IPV4 Address
LAN_IP=$(ip a show dev $LAN_INTERFACE | grep --color=none inet | grep -v inet6 | awk '{ print $2; }' )

echo  "LanIP: $LAN_IP     WanIP: $WAN_IP" | tr '\n' ' '
  1. make a main script to call scripts alternatively

~/.config/executor@raujonas.github.io/executor.sh

#!/usr/bin/env bash

WORKDIR=$(dirname $0)
INDEX_FILE="$WORKDIR/executor.index"
SCRIPTS_DIR="$WORKDIR/scripts"

for e in $(ls $SCRIPTS_DIR); do
  if [ -x "$SCRIPTS_DIR/$e" ]; then 
    SCRIPTS_LIST=("${SCRIPTS_LIST[@]}" "$e")


  fi
done


if [[ -f $INDEX_FILE ]]; then
  source $INDEX_FILE
  $SCRIPTS_DIR/${SCRIPTS_LIST[$INDEX]}
  INDEX=$(( $INDEX + 1 ))

  if [[ $INDEX = ${#SCRIPTS_LIST[@]} ]]; 
    then INDEX=0
  fi
  echo "INDEX=$INDEX" > $INDEX_FILE
else
  echo "INDEX=0" > $INDEX_FILE
fi
  1. Call ~/.config/executor@raujonas.github.io/executor.sh from executor config window.

It's maybe not the optimal or beautiful way to do that but it work's. ;-)
I just wanted to share if someone need the same feature.

Edit:

  1. Put everything in ~/.config/executor... instead of ~/.local/share/gnome-shell/extensions/executor ...
  2. ./ instead of bash to be able to execute other languages
@raujonas
Copy link
Owner

Hi @snax44. I'm happy that you enjoy the extension. Thanks very much for sharing your configuration. I will add a link to this issue in the readme if you don't mind because this is very useful!

The only thing I would like to mention is that it might be better to store all your custom scripts and your launcher somewhere else. From what I know the folder is completely removed when an extension update is performed (https://stackoverflow.com/a/65351323/9931427), so you might lose all your scripts.

This is the same issue I had with the custom css files which is why I suggested to create a new folder mkdir /home/$USER/.config/executor@raujonas.github.io for the css files. I think this would be a good place to store your scripts too, but of course you can place them wherever you want to 😊

@snax44
Copy link
Contributor Author
snax44 commented May 27, 2021

Yes you totally right.
I've changed the examples.

Feel free to do what you want with this (link to it or correct my bad english etc...)

Furthermore, do you think that I can use the custom.css with my solution ?
I tried but nothing is working. :-(

@raujonas
Copy link
Owner
raujonas commented May 27, 2021

Technically this should work fine, yes. The extensions searches for a string like this <executor.css.red> in your command output, removes it and adds the respective css class to the output label.

  1. Is your css file at this location .config/executor@raujonas.github.io/custom.css?
  2. Have you tried to use the examples in the readme file before you tried your more complex ones? You have to copy the css from the example file to your css file first.

Please try also to restart your shell or log out and in again just to be sure.

@snax44
Copy link
Contributor Author
snax44 commented May 27, 2021

My bad ...
I've not look in the file and everything was comment. 😝

Do you think that I can find a way to use multiple color in the same output ?

@raujonas
Copy link
Owner
raujonas commented May 27, 2021

I've not look in the file and everything was comment. stuck_out_tongue_closed_eyes

So is it working now as expected?

Do you think that I can find a way to use multiple color in the same output ?

If you mean to have different colors in the same command, then the answer is no, this is currently not supported.

However I played around with it now and there's a way to use markup. I introduced a new executor setting for this (<executor.markup.true>) to activate it.

I have the following command for testing: echo "<executor.markup.true> <span foreground='blue'>Blue text</span> is <i>cool</i>! <span foreground='red'>Red text</span> is cool too".

So you see this is just a single command, the output is the following:
grafik

Is this what you were looking for? If yes, I can implement this in the next release 😊

Edit: There seems to be a bug in ClutterText, this is why there's an empty space needed before the first span tag (https://gitlab.gnome.org/GNOME/mutter/-/issues/1324)

@snax44
Copy link
Contributor Author
snax44 commented May 27, 2021

Yes it work's like a charm !
And Yes that's exactly what I was looking for.

Thank you very much for your work.

@raujonas
Copy link
Owner
raujonas commented May 27, 2021

You're welcome, I'm beyond happy that some people are using the extension and have such good ideas to improve it 😉

If you want to test it, you can check out this branch: https://github.com/raujonas/executor/tree/feature/markup

I still have to adapt the readme, after that I'll make a new release.

@raujonas
Copy link
Owner

@snax44 it is now available in the store!

@snax44
Copy link
Contributor Author
snax44 commented May 28, 2021

That's perfect !
Thank you very much.

If you need some help for translation(to French) for example or anythings else, just ask.

@raujonas
Copy link
Owner

Thanks, will come back to your offer 😊

@raujonas
Copy link
Owner
raujonas commented May 29, 2021

@snax44 Finally translations are working, so if you still want to do french it would be very appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0