Simple ~/.icewm startup example with programs and wifi

Forum Forums General Tips and Tricks Simple ~/.icewm startup example with programs and wifi

  • This topic has 5 replies, 2 voices, and was last updated Oct 28-4:00 am by BobC.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #43850
    Moderator
    BobC

    To edit your IceWM startup file, from the main menu got to Control Centre, Desktop, IceWM Settings, startup tab and by default it just has the first line, but I will start a Mahjongg game, start Firefox, and lastly, make sure WiFi is running, and if not, bring up the Connection Manager so you can turn it on and/or connect to it. Note & after the command to run the program allows it to run that program, then without stopping, continue running this script. The sleep command intentionally delays x seconds. Any programmers better than I are welcome to suggest better code 🙂

    So for a real beginner to Linux I should mention that if you already have code in your startup, you should investigate it, and at least back it up by saving it with a different name so it isn’t lost. Then I would select and copy the code in the box below, and paste it into the Geany startup tab, then click File Save or Save As to save as startup. It will take effect the next time you log out and log back in to IceWM. This was tested with antiX full x64. The only problem I had was that I found the touchpad didn’t want to work as I got low on battery, and so I commented out the synclient command.

    #!/bin/bash
    
    # disable touchpad tapping for button1 so I don't click by mistake when my hand moves.  lines beginning with # are treated as comments
    ###synclient tapbutton1=-1 &
    
    # Start Mahjongg
    gnome-mahjongg &
    
    # Start Firefox
    desktop-defaults-run -b &
    
    # test internet connection and bring up connman if not connected
    # Give it a few more seconds to connect, then test for connection
    sleep 3
    connected_addr=$(ip addr | grep "inet " | sed '/ scope host /d')
    if [ -z "$connected_addr" ]; then
       cmst -d &
    fi
    
    • This topic was modified 1 year, 1 month ago by BobC. Reason: show commented out line
    • This topic was modified 1 year, 1 month ago by BobC.
    #43866
    Member
    Robin
    Helpful
    Up
    0
    ::

    Hello BobC
    You’ve given some great hints for real beginners. Thank you very much!
    Some weeks ago I solved a similar problem with the touchpad making my cursor jump around wildly and accidentally while typing at the keyboard, so I decided to create a script, which toggles the touchpad on and off, and I bound this script to one of the (until now) unused multimedia-buttons the notebook provides. I’ll also share my results with the community.
    Here is the code. Save it as root in a new file named touchpad-toggle.sh in the folder /usr/local/bin and set user rights to -rwxr-xr-x. (how to do this, see posting below)

    
    #!/bin/bash
    
    if synclient -l |grep Touch | grep [1] > /dev/null
     then
      synclient TouchpadOff=0
     else
      synclient TouchpadOff=1
    fi
    
    

    Calling the script from the commandline will toogle the touchpad on and off already. Now the button assignment:

    Add a line in the file ~/.icewm/keys

    
    key "Ctrl+Alt+XF86Mail" touchpad-toggle.sh
    

    Instead of XF86Mail you can use every unassigned button or combination you like.
    Check buttons with sudo xev -event keyboard in a terminal-window.
    the output will give you the code of the button in question.
    Example output of xev, here for the mail-button of my notebook:

    
    KeyPress event, serial 28, synthetic NO, window 0x6200001,
        root 0x243, subw 0x0, time 226203003, (-462,26), root:(548,49),
        state 0x8, keycode 163 (keysym 0x1008ff19, XF86Mail), same_screen YES,
        XLookupString gives 0 bytes: 
        XmbLookupString gives 0 bytes: 
        XFilterEvent returns: False
    
    KeyRelease event, serial 28, synthetic NO, window 0x6200001,
        root 0x243, subw 0x0, time 226203186, (-462,26), root:(548,49),
        state 0x8, keycode 163 (keysym 0x1008ff19, XF86Mail), same_screen YES,
        XLookupString gives 0 bytes: 
        XFilterEvent returns: False
    

    You can see the string XF86Mail, which is the Keycode you’ll need.
    Key-combinations are explained in the file ~/.icewm/keys, itself you are just editing.
    They might be
    Ctrl+XF86Mail
    Alt+XF86Mail
    Ctrl+Alt+XF86Mail
    Super+XF86Mail

    When about to edit this file you can add some other useful keys to be at hand when needed:

    
    [...]
    key "XF86PowerOff" desktop-session-exit -S #suspend to ram
    key "Ctrl+XF86PowerOff" desktop-session-exit -s #shutdown
    key "Alt+XF86PowerOff" desktop-session-exit -r #reboot
    key "XF86Mail" thunderbird #Email
    key "Ctrl+XF86Mail" efax -s #Fax
    key "XF86HomePage" xdg-open about:blank #internetbrowser
    key "Ctrl+Alt+XF86Mail" touchpad-toggle.sh #touchpad on/off
    

    which means in detail:
    a single push on the Off-button sends the notebook to suspend-mode,
    the combination Ctrl + Off-button powers system actually down,
    the combination Alt + Off-button will reboot the machine,
    the button Mail starts thunderbird,
    the combination Ctrl + Mail-button starts the fax-program
    the button Internet starts the browser
    and the combination Ctrl+Alt+Email toggles the touchpad on and off.

    This is an example only, you’ll have to adapt it to your needs. If your Keyboard/Notebook doesn’t have multimedia buttons you can use every ‘normal’ key in combination with ‘Ctrl’, ‘Alt’, ‘Super’… as well, which is not used otherwise already.
    Save the file and after next login to icewm desktop the keys work the way you have set them up. Save your files elsewhere, since they might get overwritten by a system-update. In this case you’ll have to copy them back from your saved copy.

    • This reply was modified 1 year, 1 month ago by Robin. Reason: typo
    • This reply was modified 1 year, 1 month ago by Robin. Reason: some typos
    • This reply was modified 1 year, 1 month ago by Robin. Reason: better wording
    #43913
    Member
    Robin
    Helpful
    Up
    0
    ::

    Hint for advanced users: set file permissions to 755 and ignore this digression about linux file permissions written for the real newbie.

    This setting of permissions could be done by typing in your terminal-window the following command:
    sudo chmod u=rwx,g=rx,o=rx /usr/local/bin/touchpad-toggle.sh
    I use here the lengthy diction of this command instead of the shorter octal numbers to make it more descriptive for real linux newbies. As mentioned above you could type chmod 755 /usr/local/bin/touchpad-toggle.sh as well, it denotes exactly the same thing.
    u stands for the user, who owns the file, g gives permission to the group of users to which the file belongs, and o represents all the others, who may try to access the file.
    rwx means somebody has the right to (r)ead, (w)rite and e(xecute), respectively rx means he may read and execute only: neither group nor others may not write any changes to the file, only the user who owns it can do this, which includes also the deletion of the file as well as the modifying of its permissions. This is the reason for that we have to use sudo in this case, since our file belongs to the user root and the group root. You could modify the permissions for any file in your system this way, combining these letters as you need them. But be warned: changing the permission of systemically relevant files without exactly knowing what you are doing and why may result in a broken installation of antiX and data loss, moreover this will constitute a real danger for the security of your system. So better don’t mess things up.

    Subsequently entering the command
    sudo ls -l /usr/local/bin/touchpad-toggle.sh
    you should read the output
    -rwxr-xr-x 1 root root 474 Okt 25 11:52 /usr/local/bin/touchpad-toggle.sh
    in your terminal-window.

    Within the output of this command the current settings of the three entities (user, group and owner, in this order) are to be read in the following way:
    Ignore the first dash, and think the rest of the line seperated in tripels: rwx, r-x, r-x. Note that the location where the w would have its place in the second and third triple is substituted by a dash rather than omitted, as the command chmod expects it. Now you can be sure you have got the permissions the way you wanted them.

    • This reply was modified 1 year, 1 month ago by Robin. Reason: typo
    #43915
    Moderator
    BobC
    Helpful
    Up
    0
    ::

    Robin,

    Yes, I control lots of things with key assignments too. Most I remember, some I don’t. I got to where I created a keyboard layout list of what key does what to pop up when I don’t remember.

    I would just suggest people check the ~/.icewm/keys and ~/.icewm/preferences files to make sure a key isn’t already used for something before deciding to use it for something and then finding out it was already in use. It is tricky to allocate a key to something without knowing how many people are using the existing key assignment, or how often they are using it.

    And then I remembered that you are using antiX 17. In antiX 19, additional key assignments were made which included the multimedia keys (that’s why the volume and mute keys work in 19 for example), but if someone isn’t using the email key to send emails, and has a touchy trackpad, it doesn’t matter, as nothing else in the system depends on that key assignment. I would think that if they come out with antiX 17.5 it will include the newer IceWM and corresponding setups.

    I’ll have to try your trackpad toggle to see if it helps my laptop. Thanks 🙂

    PS: Here are the IceWM Multimedia keys setup in antiX 19

    key "Print" antixscreenshot.sh
    ###Multimedia keys
    key "XF86AudioLowerVolume"	amixer sset Master 5%-
    key "XF86AudioRaiseVolume"	amixer sset Master 5%+
    key "XF86AudioMute"		amixer sset Master toggle
    key "XF86AudioPlay"		xmms --play-pause
    key "XF86AudioStop"		xmms --stop
    key "XF86AudioPrev"		xmms --rew
    key "XF86AudioNext"		xmms --fwd
    key "XF86AudioRecord"	simplescreenrecorder 
    key "XF86HomePage"		desktop-defaults-run -b --new-window
    key "XF86Search"		desktop-defaults-run -b http://www.duckduckgo.com
    key "XF86Eject"			unplugdrive.sh
    key "XF86Calculator"	/bin/sh -c "galculator || gnome-calculator || xcalc || ( type bc >/dev/null 2>&1 && xterm -e bc -l)"
    key "XF86Mail"			desktop-defaults-run -e
    • This reply was modified 1 year, 1 month ago by BobC.
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.