Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: script or macro for repetitive tasks

  1. #1
    Join Date
    May 2009
    Beans
    14

    script or macro for repetitive tasks

    I have several things I do regularly in Ubuntu for which I would like to have a single button, shortcut, or keyboard combination. I've been using Ubuntu for a year now (crossed over from Windows) and, while I'm pretty good with computers, I've never really done any programming beyond HTML (so, no real programming). But I figure there has to be easier ways to do the following:

    1) Due to repetitive stress problems, I have taught myself to use a mouse both left and right handed. My mouse on my desktop at home is set for right-handed use and it doesn't change. However, at work I use a laptop with a docking station. The mouse on the docking station is set to be left-handed, mixing up which hand I use to minimize repetitive movements. But when I undock my laptop (which is several times a day), I switch the mouse settings back to right handed as the keypad is awkward to manage left-handed. Obviously switching from right-handed to left-handed isn't that hard: System -> Preferences -> Mouse. To speed things up, I created a shortcut to the Mouse menu on my top panel. But it still requires 3 clicks to change the mouse setting from right-handed to left-handed. I'd like to make it a single-click affair - I hit a button or some keyboard combination and my mouse changes from right-handed to left-handed. Any suggestions on how to do that?

    2) I'm a college professor (obviously not in computer science). The reason I undock and redock my laptop multiple times during the day is because I am teaching classes and I use my laptop to present powerpoints and multimedia to my classes. Whenever I dock or undock, not only do I have to switch the mouse settings, but I have to change the monitor settings. Attached to my laptop dock is an external monitor, which gives me dual monitors when docked. Changing the monitor settings isn't that hard, of course (System -> Preferences -> Display), and I've even added the "displays" icon to the panel, which means it's relatively quick to change my displays. But it still requires several clicks. I click the icon in my panel, it brings up the Display Preferences window. I then have to select the external monitor, change the resolution settings (Ubuntu can only handle certain resolutions, particularly with my crappy laptop), position the external monitor correctly, then hit apply. I have to do this every time I dock, every time I am going to undock, every time I connect the external projector, and every time I am going to disconnect from the external projector. Since the projector settings and the external monitor settings are the same every time, it would be nice if I had a single button shortcut that simply changed my display preferences to whatever I have connected: (1) external monitor when docked, (2) external projector for classroom presentations, and (3) no external monitor when not docked. Any suggestions on how to make this happen?

    3) On my desktop computer at home I have dual monitors. I have set Songbird to load automatically when I start my computer, but it always starts on the left-hand monitor and I like it on the right-hand monitor, which means I have to move it every time I startup my computer (usually once a day in the morning). Is there something I can change in the launch command in System -> Preferences -> Startup Applications to make the Songbird window move to the right monitor instead of the left one?

    Thanks in advance for any suggestions.

  2. #2
    Join Date
    Jun 2008
    Location
    Ballard
    Beans
    2,409
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: script or macro for repetitive tasks

    Welcome to the forums.

    I would split your thread into three well crafted (and well titled) threads. You will be much more likely to get the kind of specific help you'll need.

    I did have a thought about your third issue. I suppose Sb is firing up on your main monitor? If you tell Sb to open on the other monitor (and perhaps it's possible) that may lead to troubles if you open Sb while not docked. Just a thought.
    "We're all in this together, kid." --H. Tuttle (a.k.a. H. Buttle)
    "Maybe it's a layer 8 problem." --thatguruguy
    A High-Tech Blech!

  3. #3
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: script or macro for repetitive tasks

    Hi, for making the mouse left or handed you can use gconftool. I don't know if its part of the default install or not, if you don't have it then install package gconf2.

    Then, this command will make mouse left-handed:
    Code:
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool true
    and this will revert it to right-handed:
    Code:
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool false
    So you could create a pair of custom launchers in your panel with these as the commands.

  4. #4
    Join Date
    Jun 2008
    Location
    Ballard
    Beans
    2,409
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: script or macro for repetitive tasks

    He could probably do a test (if true) to determine handedness. In which case he could put both of those statements (if and else) into a single script and use a launcher to run that script.
    "We're all in this together, kid." --H. Tuttle (a.k.a. H. Buttle)
    "Maybe it's a layer 8 problem." --thatguruguy
    A High-Tech Blech!

  5. #5
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: script or macro for repetitive tasks

    and for the monitor / resolution question, take a look at the xrandr utility.
    this article may help: http://solnyshok.blogspot.com/2009/1...-external.html

  6. #6
    Join Date
    Jan 2010
    Location
    65 AD
    Beans
    304
    Distro
    Ubuntu Development Release

    Re: script or macro for repetitive tasks

    like this

    switchmb=$(gconftool -g /desktop/gnome/peripherals/mouse/left_handed)
    if [ $switchmb = "false" ]; then
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool "true"
    else
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool "false"
    fi
    exit 0
    make it executable place it in /usr/bin and use gnome-keybinding-properties to tie it to a hotkey.

  7. #7
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: script or macro for repetitive tasks

    or slightly shorter:
    Code:
    current_setting=$(gconftool -g /desktop/gnome/peripherals/mouse/left_handed)
    $current_setting && new_setting=false || new_setting=true
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool $new_setting
    nice avatar pi/roman, who is that -- nero?

  8. #8
    Join Date
    May 2009
    Beans
    14

    Re: script or macro for repetitive tasks

    Quote Originally Posted by DaithiF View Post
    Hi, for making the mouse left or handed you can use gconftool. I don't know if its part of the default install or not, if you don't have it then install package gconf2.

    Then, this command will make mouse left-handed:
    Code:
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool true
    and this will revert it to right-handed:
    Code:
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool false
    So you could create a pair of custom launchers in your panel with these as the commands.


    This worked. Thank you!

    Now trying the if/then approach.

  9. #9
    Join Date
    Jan 2010
    Location
    65 AD
    Beans
    304
    Distro
    Ubuntu Development Release

    Re: script or macro for repetitive tasks

    nice avatar pi/roman, who is that -- nero?
    Yep, thanx, and thanx for teaching me some new scripting methods.

  10. #10
    Join Date
    May 2009
    Beans
    14

    Re: script or macro for repetitive tasks

    Quote Originally Posted by DaithiF View Post
    or slightly shorter:
    Code:
    current_setting=$(gconftool -g /desktop/gnome/peripherals/mouse/left_handed)
    $current_setting && new_setting=false || new_setting=true
    gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool $new_setting
    nice avatar pi/roman, who is that -- nero?

    This worked as well. I opened a text file using sudo gedit /usr/bin/mouse_switch and copied the code as is and pasted it into the text file. I then CHMOD'd mouse_switch and used keyboard bindings (CTRL+SHIFT+M) to attach it to a keyboard binding. et voila, I have a keyboard shortcut to switch my mouse configuration.

    So nice!!! Thank you!!!

    (Now I just have to figure out how it works...)
    Last edited by rcragun; September 2nd, 2010 at 03:15 PM.

Page 1 of 4 123 ... LastLast

Tags for this Thread

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
  •