Script to Toggle the “language icon” permanently on/off

Forum Forums antiX-development Development Script to Toggle the “language icon” permanently on/off

Tagged: 

  • This topic has 4 replies, 3 voices, and was last updated Oct 27-4:42 pm by PPC.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #118938
    Member
    PPC

      Most users, me included, do not need to use more than 1 keyboard layout… and most users do not want to edit config files, which is required to make sure something does not auto-start, every time the system starts…

      So I came up with a script that:
      – if the “language icon” is on the system tray, closes it and also comments it out in the startup file
      – if the “language icon” is not on the system tray, starts it and makes sure it’s entry is not commented out in the startup file.

      Not running the icon does save some MB of idle RAM…

      I think it would be a nice addition to antiX, with a localized .desktop file, to make it available from the menu, in the “antiX” category, maybe? And maybe also in the Control Centre, maybe on the “System” or “Session” tabs…

      #!/bin/bash
      #script to enable/disable antiX Linux's "system tray's keyboard language icon", also enabling/disabling it from ~/.desktop-session/startup, by making sure  it's entry is uncommentend/commented), by PPC, GPL license, 2023
      file=$HOME/.desktop-session/startup
      line_content=$(grep -Fiw fbxkb <$file)
      line_number=$(grep -Fiwn fbxkb <$file |cut -d: -f1)
      first_character_in_line=${line_content:0:1}
      if [ "$(pidof fbxkb)" ]; then
      #	echo "fbxkb is running, turning it off"
      	pkill fbxkb 
       # make sure fbxkb is commented on the startup file
      sed -i  "$line_number"' s/^/#/' "$file"
              
      else
      # echo "fbxkb is not running, starting it"
       fbxkb &
       
      #and also make sure fbxkb is not commented on  the startup file
       
      	if [ "$first_character_in_line" == "#" ]; then #line is commented out already. Uncommenting it
      		sed -i '/fbxkb/ s/^#//' $file
              fi
      	
      fi
      exit
      
      • This topic was modified 1 month, 4 weeks ago by PPC.
      • This topic was modified 1 month, 4 weeks ago by PPC.
      • This topic was modified 1 month, 4 weeks ago by PPC.
      #118975
      Member
      sybok
        Helpful
        Up
        0
        ::

        Hi, I suggest the following minor changes

        1) grep the larger string ‘fbxkb-start’ when acquiring line-number to avoid any issues with custom modifications of the ‘~/.destkop-session/startup’ script, i.e.
        grep -Fiwn -- fbxkb-start < $file|...
        Also, both ‘Fi’ seem not to be necessary.

        2) uncommenting via ‘sed’ substitution – please, also explicitly use the address with line-number.

        I am not sure if ‘fbxkb’ is newly installed by default. I believe I had to install it to some older version of antiX.

        #119041
        Member
        PPC
          Helpful
          Up
          0
          ::

          When I create scripts to automate configuration files management, it’s always a risk – they are meant to run well on the default files… I assume someone that manually edits config files does not require my scripts to do… I initially choose to use fbxkb only to make sure that the script always enables/ disables it, even if users messed with the config file and comented the original command and end up adding just fbxfb…
          On the other hand, you may be right, so I adapted the script and inserted your suggestions… Either way the script works fine with the original config file…

          #!/bin/bash
          #script to enable/disable antiX Linux's "system tray's keyboard language icon", also enabling/disabling it from ~/.desktop-session/startup, by making sure  it's entry is uncommentend/commented), by PPC, GPL license, 2023
          file=$HOME/.desktop-session/startup
          line_content=$(grep -Fiw fbxkb-start <$file)
          line_number=$(grep -Fiwn fbxkb-start <$file |cut -d: -f1)
          first_character_in_line=${line_content:0:1}
          if [ "$(pidof fbxkb)" ]; then
          #	echo "fbxkb is running, turning it off"
          	pkill fbxkb 
           # make sure fbxkb is comented on the startup file
          sed -i  "$line_number"' s/^/#/' "$file"
                  
          	else
          # echo "fbxkb is not running, starting it"
          	fbxkb &
           
          #and also make sure fbxkb is not commented on  the startup file
           
          	if [ "$first_character_in_line" == "#" ]; then #line is commented out already. Uncommententing it
          		sed -i "$line_number"' s/^#//' $file
                  fi
          	
          fi
          

          EDIT: scripts similar to this one can be used for permanently toggling Conky on/off, etc…

          #121851
          Member
          blur13
            Helpful
            Up
            0
            ::

            Instead of having a desktop file for each line in the startup file that can be commented/uncommented, why not make a sort of “control panel” with all those options in one place. The problem with having a desktop file for each individual change is that the “antiX” menu gets cluttered. I think MX has some sort of “MX tweaks” program that gathers changes of this nature in one place. Maybe put everything in “antiX tweaks”. Or in a submenu.

            #121946
            Member
            PPC
              Helpful
              Up
              0
              ::

              @blur13 – We already have our Control Centre, a “Control Panel” would just sound like a strange thing… specially because we already have also a “IceWM Control Centre”.
              The reason this script was not included in IceWM Control Centre itself was because it changes a setting that affects other Window Managers too, so, if this setting was changed from that GUI and the user switched to other Window Manager, there would be no available GUI to change the setting again…

              I kind of think of the “antiX” sub-menu, under “Applications” as the place to go to control antiX related stuff (and specially IceWM settings) – I think this script would fit right in there very well… but don’t worry, I don’t have any more suggestions related to antiX UI or GUIs I can create- for me, antiX 23 is pretty much perfect the way it is right now… Sound problems are solved (the biggest problem antiX 23 had, other than the problem installing to UEFI computers, without performing first an update, or at least installing a couple of packages)- IceWM Control Centre has pretty much all settings I wanted it to have (the ones I left out, I explain how to perform in IceWM Tips and Tricks).
              IceWM itself is very nearly perfect for my needs, and it all the GUI’s antiX includes, acts almost like a modern “dock”. I even managed to tweak a little bit app-select (it self almost a perfect tool too, specially for computers that are powerful enough to open it in a second or so).

              I could be run over a truck today, and there will be almost no idea that I wanted to implement in antiX that is not already included in antiX 23 or documented on the forum…

              There is always room for improvement – I can always try to improve the FX themes (the lighter one never seemed quite right to me), I need to add window icons on the title bar by default (I’ll have to dig around examples, to find out how to do that). The “toggle” scripts can always be improved, I can finish my script to integrate appimages, etc, tiny stuff like that… nothing major… unless something changes, that’s probably all I’ll be doing in the near term, on antiX (if I do anything more than trying to help out around the forum).

              My point – no more “tools” to pollute the antiX menu, not from me 🙂

              Edit: the idea of a dedicated GUI to access some tweaks is indeed good – maybe a new Control Centre Tab, something like “Tweaks”? It could house stuff like this proposed script, toggle conky on/off, toggle pipewire on/off (if that is not placed in the Hardware tab), manage the Personal menu, set default paper size, etc)

              P.

              • This reply was modified 1 month ago by PPC.
              • This reply was modified 1 month ago by PPC.
            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.