Results 1 to 7 of 7

Thread: Short Scripts & Folders

  1. #1
    Join Date
    Jun 2013
    Location
    Sydney
    Beans
    170
    Distro
    Lubuntu

    Short Scripts & Folders

    Lubuntu 17.10(.1) waiting for 18.04.1 LTS, a single user very plain old Dell laptop used for CAD and office work.

    I am feeling my way through script writing and just a little confused.
    What would be the best arrangement for me to organise simple scripts ?

    Two existing short scripts are on the desktop and held as Desktop Entries, each with a single line of commands, work great.

    A third is similar with multi-part commands, but it won't run, even though the commands in the terminal run fine.
    In the process of trying to run it from a folder - /home/john/scripts, and running into make exec, set background and permission learning challenges. - just seems too hard for such a simple task.

    A forth script is a longer one held in /usr/share/applications with a desktop icon link and it works fine.

    What is the best way for me (single user machine) to organise short scripts, and what folder is recommended ?
    I am up to the learning challenge, just need guidance on how to organise.

    John

  2. #2
    Join Date
    Mar 2017
    Beans
    1,018

    Re: Short Scripts & Folders

    I just place my scripts in ~/scripts.
    A couple I use all the time I copy to ~/bin so they can be run without specifying the path.
    Code:
    glen@Bionic:~$ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/glen/.local/bin:/home/glen/bin
    Often used scripts I add to a .desktop file utilising a quicklist.
    The .desktop file is placed in ~/.local/share/applications
    eg this is my ~/.local/share/applications/MyScripts.desktop file.
    Code:
    [Desktop Entry]
    Version=1.0
    Name=Scripts
    Exec=xdg-open /home/glen/scripts
    Type=Application
    Icon=/home/glen/Pictures/icons/coloured_folders/scripts-folder-flipped.png
    Comment=My personal scripts
    StartupNotify=false
    
    # This sets the content and order of the Quicklist. Must match the [Desktop Action xxxxxxx]
    Actions=Background;Buckle;network-restart;Ping;reloadPlank;Speed;swap;Test Script;RunTest;reloadtint2;Upper2lower;VivaldiCSS;VivaldiPatch;zsync;separator;edit-launcher;
    
    
    [Desktop Action term-kill]
    Name=xfce4-terminal kill   
    Exec=killall xfce4-terminal
    
    [Desktop Action Background]
    Name=Background Reset   
    Exec=/home/glen/scripts/background-reset-gradient.sh
    
    [Desktop Action Whatismyip]
    Name=Whatismyip
    Exec=/home/glen/scripts/whatismyip
    
    [Desktop Action zsync]
    Name=Zsync Daily Iso
    Exec=xfce4-terminal --tab --drop-down --title "Zsync" -e "/home/glen/scripts/zsync.sh"
    
    [Desktop Action Cursor]
    Name=Change Cursor
    Exec=xfce4-terminal --tab --drop-down -e "/home/glen/scripts/change-cursor-trusty"
    
    [Desktop Action Test Script]
    Name=Test Script Edit
    Exec=gedit /home/glen/scripts/aatest.sh
    
    [Desktop Action Screensaver]
    Name=Screensaver  OFF/ON
    Exec=/home/glen/scripts/toggle_screen_blanking.sh
    
    [Desktop Action Notes]
    Name=Notes
    Exec=gedit "/media/Data/Notes"
    
    [Desktop Action open-command]
    Name=Open command in Terminal
    Exec=/home/glen/scripts/xsel-terminal.sh
    
    [Desktop Action RunTest]
    Name=Test Script Run
    Exec=gnome-terminal -e "/home/glen/scripts/aatest.sh"
    
    [Desktop Action ClockToggle]
    Name=Clock-Toggle
    Exec=/home/glen/scripts/toggle-clock.sh
    
    
    [Desktop Action TooltipToggle]
    Name=Tooltip-Toggle
    Exec=/home/glen/scripts/tooltips-toggle-trusty.sh
    
    [Desktop Action Brightness]
    Name=Brightness
    Exec=/home/glen/scripts/brightness.py
    
    [Desktop Action Reboot]
    Name=XP Reboot
    Exec=/home/glen/scripts/Reboot_to_Windows
    
    [Desktop Action reloadtint2]
    Name=Tint2 Reload
    Exec=sh -c "killall tint2 && tint2 &"
    
    [Desktop Action reloadPlank]
    Name=Plank Reload
    Exec=sh -c "killall plank && plank &"
    
    [Desktop Action separator]
    Name=______________________________________
    Exec=
    
    [Desktop Action edit-launcher]
    Name=Edit Launcher
    Exec=gedit /home/glen/.local/share/applications/MyScripts.desktop
    
    [Desktop Action Ping]
    Name=Ping Test
    Exec=/home/glen/scripts/pingtest.sh
    
    [Desktop Action Speed]
    Name=Speed Test
    Exec=/home/glen/scripts/speedtest.sh
    
    [Desktop Action Upper2lower]
    Name=Upper to Lower
    Exec=/home/glen/scripts/upper2lower.sh
    
    [Desktop Action getip]
    Name=Get-IP Loop
    Exec=sh -c "killall get-ip-loop.sh; sleep 2 && /home/glen/scripts/get-ip-loop.sh"
    
    [Desktop Action game]
    Name=Game-Settings On/Off
    Exec=/home/glen/scripts/game-settings.sh
    
    [Desktop Action poker-fix]
    Name=Poker Fix
    Exec=xfce4-terminal --tab --drop-down -e "/home/glen/scripts/pokerth-sound-fix.sh"
    
    [Desktop Action Buckle]
    Name=Buckle On/Off
    Exec=/home/glen/scripts/buckle-toggle.sh
    
    [Desktop Action unilogout]
    Name=Universal Logout
    Exec=/home/glen/scripts/universal-logout.sh
    
    [Desktop Action gnome-shell-replace]
    Name=gnome-shell-replace   
    Exec=/home/glen/scripts/gnome-shell-replace.sh
    
    [Desktop Action network-restart]
    Name=Network-restart   
    Exec=xfce4-terminal --tab --drop-down --title "Network Restart" -e "/home/glen/scripts/network-restart.sh"
    
    [Desktop Action swap]
    Name=Swap On/Off 
    Exec=xfce4-terminal --tab --drop-down --title "Network-restart" -e "/home/glen/scripts/swap_toggle.sh"
    
    [Desktop Action VivaldiPatch]
    Name=VivaldiPatch   
    Exec=xfce4-terminal --tab --drop-down --title "VivaldiPatch" -e "sudo /home/glen/MEGAsync/configs/vivaldi/VivaldiPatch/vivaldi-patch.sh"
    
    [Desktop Action VivaldiCSS]
    Name=VivaldiCSS   
    Exec=gedit /home/glen/MEGAsync/configs/vivaldi/VivaldiPatch/custom.css
    Last edited by again?; June 20th, 2018 at 12:35 AM.

  3. #3
    Join Date
    Dec 2014
    Beans
    2,590

    Re: Short Scripts & Folders

    The '/usr/share' hierarchy of directories is meant for data, possibly data shared across applications. Not quite the right place for an executable ...

    The place for self-written (or self compiled) programs is '/usr/local/bin/'. It's even on the PATH, so you can call your scripts no matter what your current working directory is. Another option is to create a directory for this purpose in your home directory and put it on the path by putting a line like
    Code:
    PATH=$PATH:/home/myusername/myscriptdirectory
    into ~/.profile or ~.bashrc. If you call your script directory 'bin', you can save yourself that trouble, a line to put it on the path is already in .profile ...

    Holger

  4. #4
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Short Scripts & Folders

    If using Nautilus.

    Scripts here will appear in scripts menu
    ~/.local/share/nautilus/scripts/

    Or:

    Note that it is a good idea to put your scripts in one place, so you can run them without requiring a path. If you create a bin directory in your home ( mkdir ~/bin ) the next time you login, that will automatically be included in your PATH. Then you could make a panel or desktop launcher as "Application in Terminal" to run your script with a click or double click of the mouse.
    Re: Starting multiple programs at once


    1. Do you have a bin directory in your home folder? If you do, skip forward to step 2. Otherwise, do the following:

    mkdir ~/bin
    chmod 755 ~/bin
    gksudo gedit ~/.bashrc
    https://ubuntuforums.org/showthread....ghlight=pkexec
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  5. #5
    Join Date
    Jun 2013
    Location
    Sydney
    Beans
    170
    Distro
    Lubuntu

    Re: Short Scripts & Folders

    It will take me a few days to absorb all the good advice.
    Oldfred,
    My file manager is PCManFM, not Nautilus.

    I rather like the idea of a /bin folder in my home directory, but cannot generate ~/bin - permission denied.
    Checked as follows, does this show that some of my problem is incorrect permissions on my home folder ?
    I can fix, just need to know what it should be.
    Is this a case for sudo ?

    Code:
    john@bluebox:~$ mkdir ~/bin
    mkdir: cannot create directory ‘/home/john/bin’: Permission denied
    john@bluebox:~$ cd ..
    john@bluebox:/home$ ls -lt
    total 12
    dr-xr-xr-x 37 john john 12288 Jun 18 11:46 john
    john@bluebox:/home$
    John

  6. #6
    Join Date
    Dec 2014
    Beans
    2,590

    Re: Short Scripts & Folders

    Not having write permission on your home directory would explain a lot of problems. How did you manage to get anything done that way ?
    Code:
    chmod u+w /home/john
    should fix it. 'You should not need to use 'sudo' for this, since you do still own the directory.

    Holger

  7. #7
    Join Date
    Jun 2013
    Location
    Sydney
    Beans
    170
    Distro
    Lubuntu

    Re: Short Scripts & Folders

    Holger,
    Thanks for the confirmation, did as you suggested, then generated the ~/bin, no problems,

    Now to sort out my scripts.
    Plan to have my scripts in ~/bin with a link for each common (daily) one on the desktop (old XP habits die hard), and absorb/understand the arrangement used by guber2.

    John.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •