LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Bodhi (https://www.linuxquestions.org/questions/bodhi-92/)
-   -   How can I make a script apear as an icon in the menu or my favorites so i can run form the menu instead of the console? (https://www.linuxquestions.org/questions/bodhi-92/how-can-i-make-a-script-apear-as-an-icon-in-the-menu-or-my-favorites-so-i-can-run-form-the-menu-instead-of-the-console-4175678214/)

questionsBot 07-06-2020 04:00 AM

How can I make a script apear as an icon in the menu or my favorites so i can run form the menu instead of the console?
 
I have a script that disabled my keyboard compleatly and enables it if the script is run a second time. I needed this as my laptop folds into a tablet. When you use the laptop in this mode, it needs the entire keyboard to be disabled. In windows it automatically disables and enabled the keyboard, but I just can't get it to do that in Linux.

So I wrote a simple script that enables or disabled the keyboard for me.

Quote:

Originally Posted by sKeyboardSwap
#! /bin/bash
# sKeyboard
# http://ubuntuforums.org/showthread.php?t=2100744

DEVICE="AT Translated Set 2 keyboard"
STATUS=`xinput list-props "$DEVICE" | grep 'Device Enabled' | sed 's/.*\([0-9]\)$/\1/'`

if [ "$STATUS" = "1" ]
then
xinput set-prop "$DEVICE" 'Device Enabled' 0
#echo "KeyBoard Disabled"
# notify-send "Touch-screen" "Disabled" -i /usr/share/pixmaps/touch-screen.png
elif [ "$STATUS" = "0" ]
then
xinput set-prop "$DEVICE" 'Device Enabled' 1
#echo "KeyBoard Enabled"
# notify-send "Touch-screen" "Enabled" -i /usr/share/pixmaps/touch-screen.png
else
echo "Error : bad argument"
fi

This seems to work fine. The thing is as it disables the keyboard I can't enable in the terminal, I need to click the actual script in my fie manager and execute it.

: TL;DR :

How can I turn this script into a entry in the actual BodHi menu, with an Icon and everything. So I can simply click my desktop, go favorites and click the icon to disable, and enable the keyboard?

Thanks!

shruggy 07-06-2020 04:06 AM

Desktop Entry Specification

ondoho 07-06-2020 06:45 AM

^ yeah I thought you talked about this in your other thread? No need to start a new one afaics.

Anyhow, create a file e.g. "$HOME/.local/share/applications/keyboard.desktop" with the following content:
Code:

[Desktop Entry]
Version=1.0
Type=Application
Name=something
Exec=/path/to/script
Icon=someicon
Terminal=false
StartupNotify=false
Categories=System;

(not tested)

The next time your menu is updated, it should show up under System.

cordx 07-06-2020 09:28 PM

Quote:

Originally Posted by shruggy (Post 6142029)

thanks for sharing that resource. i had always just looked at the examples on my system. reading through the specs has been helpful and informative.

enigma9o7 07-06-2020 10:17 PM

Quote:

Originally Posted by questionsBot (Post 6142028)
I needed this as my laptop folds into a tablet. When you use the laptop in this mode, it needs the entire keyboard to be disabled. In windows it automatically disables and enabled the keyboard, but I just can't get it to do that in Linux.

I bet you can bind folding it to disable keyboard automatically... probably ACPI bindings? Or maybe key bindings. Both in settings panel under input. Then bind them to your script. See if it can "add" that action.


All times are GMT -5. The time now is 06:57 PM.