LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Uncategorized Entries with no category
Old

N00b method to toggle some verbosity on command for bash scripts

Posted 03-28-2016 at 11:32 PM by the dsc (linux-related notes)
Updated 03-28-2016 at 11:34 PM by the dsc
Tags bash, newbie

Just something I came up with that is probably not how actual programmers/scripters(?) would advise, specially the parameter/flag thing which is beside the point here.

Code:
if [[ $1 == "v" ]] ; then

ver(){
echo $@
}

else

ver(){
:    # ":" is a "do nothing" command
}

fi

a=10

echo normal output

ver verbose output $a
...
Member
Posted in Uncategorized
Views 1314 Comments 0 the dsc is offline
Old

Replace trash-cli with kioclient move $@ trash:/ for cross-partition trashing

Posted 03-27-2016 at 09:17 PM by the dsc (linux-related notes)
Tags trash

However arguable, some people want to trash by moving into another partition's trash folders. The linux/unix/whatever trash specifications theoretically prohibit that, but KDE's implementation doesn't. So a linked or bind-mounted trash into a different partition will behave normally, except it will move the file across, obviously.

If you also use trash-cli, which won't work with such hacks, it can be replaced with the kioclient command, that in turn can be scripted or perhaps even...
Member
Posted in Uncategorized
Views 508 Comments 0 the dsc is offline
Old

New file name generator script/function, to avoid overwrites w/o user input

Posted 03-27-2016 at 07:11 PM by the dsc (linux-related notes)

Usage examples:

cp/mv/ln/etc file11.txt $(newname "/some/path/file11.txt")

cp/mv/ln/etc file11.txt $(newname "/some/path/whatever.txt")


If there's a file11.txt or whatever.txt already there, it will rename automatically to file11(1).txt or whatever(1).txt, and (N+1) from then on.

The whole path/name must be between quotes because of spaces and such things.

May be dangerous and somehow make you lose files...
Member
Posted in Uncategorized
Views 1130 Comments 0 the dsc is offline
Old

Apparent bug with KDE/plasma file associations

Posted 03-27-2016 at 01:22 PM by the dsc (linux-related notes)
Updated 03-29-2016 at 05:40 PM by the dsc

At least in Ubuntu wily, it doesn't seem to allow you to chose the default application to open a file type. You try to do it, but it "magically" restores the previous default association before your eyes. Even if you chanced the config file, somehow. (I'm assuming it's mimeapps.lst, but I'm not sure. It seems that it's cool nowadays to have cryptic, hidden config files, avoiding to mention them unless strictly necessary, pretending it's all magic and config files don't exist)
...
Member
Posted in Uncategorized
Views 1027 Comments 0 the dsc is offline
Old

Silly volume control scripts for openbox that probably won't work for everyone

Posted 03-20-2016 at 10:03 PM by the dsc (linux-related notes)
Updated 03-20-2016 at 10:22 PM by the dsc

Code:
#!/bin/bash

# volume changer+notifier, using notify-send, and tested only with xfce4-notifyd
# the syntax is the same of the "end" of what you'd use in plain amixer, see "$1"
# Ex.: 5%-, 5%+, 30, 60%

com=(`amixer set "Master" $1`)

vol1=${com[20]} 

# and here's why it won't work for everybody. The output of amixer includes
# things like soundcard features, which are array elements I'm just
...
Member
Posted in Uncategorized
Views 740 Comments 0 the dsc is offline

  



All times are GMT -5. The time now is 01:03 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration