Posts

Showing posts with the label bash

Disable touchpad

Today's mission has been to effectively disable the touchpa on the xps so I can take a more keyboard-driven approach and type in an uninhibited manner without weird annoying shit happening all the time. Long story short, the best way of doing this is with synclient: > synclient TouchpadOff=1 to disable the touchpad and, unsurprisingly > synclient TouchpadOff=0 to enable it again. Now, I can't rely on always being able to remember that stuff in however many month's time I need it again, so I've aliased the commands "ontouchpad" and "offtouchpad" to the relevent instructions. this equates to "on" and "off" when autocomplete is used via TAB. FURTHERmore, I have set Fn+F8 to synclient TouchpadOff=1 so I can quickly deactivate the pad in the heat of the moment. I tried a couple of scripts I found online to toggle the touchpad, but they didn't work for some reasons I didn't prioritise identifying. so, FYI...

bash enquiry

Q: bash command that'll remove all empty folders in the present directory A: find . -type d -empty -delete find finds, . specifies the present folder, -type d specifies directories (to avoid deleting empty files), -empty specifies empty, -delete instructs to delete. duh.

bash enquiry

Q: bash command that'll remove all empty folders in the present directory A: find . -type d -empty -delete find finds, . specifies the present folder, -type d specifies directories (to avoid deleting empty files), -empty specifies empty, -delete instructs to delete. duh.

morse script 2

I'll copy in the actual code below later, but I can't right now because I'm using ssh to a headless machine at work. I gave up on reading the letters from a separate text file - seemed like too much overhead for what I wanted to do. Instead I've found out how to create an associative array within my bash script. This'll let me pass the user input variable as a key that will return the binary value. SO, I have the following: #!/bin/bash # declare array and assign values to each letter # make sure no spaced between array var, = and ( declare -A morseCode_arr=( [a]=01 [b]=1000 [c]=1010 [d]=100 [e]=0 [f]=0010 [g]=110 [h]=0000 [i]=00 [j]=0111 [k]=101 [l]=0100 [m]=11 [n]=10 [o]=111 [p]=0110 [q]=1101 [r]=010 [s]=000 [t]=1 [u]=001 [v]=0001 [w]=011 [x]=1001 [y]=1011 [z]=1100 ) echo 'Input string' read user_input #loop over the characters if the user input for (( s=0; s<${#user_input}; s++ )); do # retrieve the value from the array and assign to a new va...

morse script 0

I've been trying to think of good little projects or challenges to undertake, probably in bash, that'd help me develop my knowhow, so when I was in the bath reading Tales of Pirx the Pilot by Stanislaw Lem it gave me the idea of a little morse code testing script. The idea is that it beeps out letters at you and you have to enter the letter you think it is. I guess that then builds to using a file of dictionary words and then maybe sentences from your e-books or whatever, but one step at a time! I have a vague, aspirational notion that this could be worth submitting to Linux Voice, who are soliciting for writers at the moment. might be pie in the sky, but maybe worth a shot. So, what's my approach? Well, my first thought was to use bash, rather than python or antything. I'm looking for a real basic angle. Are there any built-in commands that use the system beep? It seems not in my Arch install, but I quickly find that my instinct to type "beep" is no...

quick change audio output 3

Well, I couldn't resist plugging away at this and I must say I'm pretty pleased with the results. here's the full script: #!/bin/bash status="$(cat /sys/class/drm/card0-HDMI-A-1/status)" if [ "${status}" = disconnected ] then pactl set-card-profile 0 output:analog-stereo+input:analog-stereo notify-send -i /usr/share/icons/Mint-X/status/48/notification-audio-volume-high.png "Audio Output" "Laptop Speakers" exit elif [ "${status}" = connected ] then pactl set-card-profile 0 output:hdmi-stereo+input:analog-stereo notify-send -i /usr/share/icons/Mint-X/status/48/notification-audio-volume-high.png "Audio Output" "HDMI" exit fi Which I openly admit I got from the dude on that thread, but hey! it's simple enough that I like to think I'd've got there myself without too much trouble. And I've tarted up the notify-send statements so they look professional, with a wee volume icon and a standard...

quick change audio output 2

Reasonable success. further down the thread (on February 1st, 2012, 02:00 AM) dar270785 gives a script for dynamically selecting the output, according to the same method I was working out in my previous post. (s)he doesn't use grep for this, but the principle's the same. I tried following those instructions, but although the script works when run manually, it doesn't do so automagically when the HDMI cable is plugged in. I guess that's what the whole /etc/udev/rules.d/ bit is about, but I'm not sure what's going wrong for me. I made sure the script names were right and rebooted the lappy, but no effect. So in the meantime I've settled for a script that's kept in /usr/local/bin (called audioselect.sh), and I've tied it to an F9 key shortcut. I'm a bit bothered by the fact that it doesn't actually just toggle the output. If I can't get it to autodetect the HDMI device, and have to press a button, I'd like the button to do a s...

quick change audio output

Currently when I plug the laptop into the tv via HDMI I have to manually switch the audio from analogue stereo to hdmi digital (or whatever) by right-clicking the volume applet, choosing preferences, changing to the hardware tab, scrolling up and down trying to remember which profile to use... it's a hassle. So I want to improve on that. My own efforts got nowhere so I searched and found this forum page . The script itself doesn't work for me ("Sink 9 does not exist") which I'm kind of relieved about because that might have been too easy. It's enough of a lead to show me that a small bash script should do the job though and I've already learned: * that by putting executable files in /usr/local/bin (and doing chown 755 if necessary) they can be run like any other program. * that devices have (at least hdmi has) a status file in their folder that's just a text file listing the device status. Run cat /sys/class/drm/card0-HDMI-A-1/status to see. h...

bash vi

set -o vi to set bash to vim-like controls. will need to add it to . bashrc to make it persistent. strangely difficult to locate this nugget! http://www.sluse.com/view/15121181