16 March 2018
Capture audio input + output with pulseaudio
Solution is courtesy to this youtube video and for own use I made a script out of it.
03 May 2016
Make 'Open class' dialogue of IntelliJ IDEA behave under Awesome WM
Recently it was demystified for me with the help of Jetbrains developers and support and the community. There appeared to be a long-hanging issue regarding this weird behaviour IDEA-65043. And once it gained some more attention at least exact conditions triggering the issue were discovered.
The problem was caused by sloppy focus (AKA focus-follows-mouse) which is the default in some environments among which Awesome WM is. Now it can easily be solved!
I'm using default configuration of Awesome WM 3.5.9 as a base (which can be found in /etc/xdg/awesome/rc.lua).
Somewhere in the bottom there is a snippet we're looking for
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
-- Enable sloppy focus
c:connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
This is the sloppy focus implementation. Need to introduce a flag to switch it on\off. Change it to:-- {{{ Signals
-- Signal function to execute when a new client appears.
sloppyFocus = true
client.connect_signal("manage", function (c, startup)
-- Enable sloppy focus
c:connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c)
and sloppyFocus then
client.focus = c
end
end)
Now we have a switch, and we need to turn it off while we're working with IDEA (or WebStorm, etc) and the turn back on when we're off it. Find awfule.rules section in your config (for me it's right above the sloppy focus implementation snippet) and add a new rule:
{ rule = { class = "jetbrains-%w+" },
callback = function(c)
c:connect_signal("focus", function (client)
sloppyFocus = false
end)
c:connect_signal("unfocus", function (client)
sloppyFocus = true
end)
end
},
This matches any window of virtually any Jetbrains' product and switches sloppy focus off while it's focused, then switches sloppy back on when focus leaves IDE.Thanks awesome Awesome developers for allowing patterns in rule preconditions! :-)
09 March 2015
Seesu.me, dwb & vk.com
The story
seesu.me is an awesome online media player or radio or whatever you call it. Just give it try.dwb is a minimalistic vim-imsnpired browser.
And vk.com is popular (at least in xUSSR countries) social network.
What brings them all here is that there is large music collection available on vk.com which can be very nicely listened to with seesu.me. But me problem was that vk login button wasn't working in dwb browser.
The solution
In short i needed to do the following:- open dev console (dwb is based in webkit, so there is on) to find the login button
- check if clicking on it programatically would work
- if yes, all done - i'll login to vk, login will be remembered and nothing to worry about
After that dev console popped up on :wi command, but unfortunately each time it shows up it crashes the whole browser.
I had to pick firefox to check if triggering click programmatically would do the trick and it really did. Invoking $('.sign-in-to-vk').click() in dev console was at least triggering popup blocker and then i was able to reach the popup (BTW popup blocker was veeery important here).
Back to dwb i needed a way to execute arbitrary JS on a page which was quickly and easily found in already opened man page. So on seesu page i typed :js $('.sign-in-to-vk').click() and nothing happened again. Here i remembered about popup blocker and (quickly again) found and option javascript-can-open-windows-automatically which was set to true with ss javascript-can-open-windows-automatically true
After that repeating JS snipped worked like a charm.
06 January 2013
LXDM PostLogout script to shutdown user's apps
I don't really like this, but I wanted DM to show list of users instead of simple prompt. Arch wiki suggests just to killall --user $USER which would also kill all your background processes they may be running (torrent, screen, etc).
Enough words - here goes the script:
$ cat /etc/lxdm/PostLogout
#!/bin/sh
#
# Note: this is a sample and will not be run as is.
current_windows=`xlsclients -al | grep Window | cut -d' ' -f2 | sed -e 's/:$//'`
for wid in $current_windows
do
pid=`xprop -id ${wid} _NET_WM_PID | awk -F ' = ' '{ print $2 }'`
wmname=`xprop -id ${wid} WM_CLASS | cut -d= -f2 | cut -d, -f2 | sed -e 's/[ "]//g'`
if [ "p${pid}" != "p" ]
then
echo "Killing ${wmname} (${pid})"
kill ${pid}
else
echo "No PID found for ${wmname}"
fi
done
# for some reason PID for conky cannot be determined
killall --user $USER conky
It requires xlsclients and xprop. Some apps (like conky) are special case and they don't show their PID in X11 properties of a window, so they are killed separately.
05 November 2012
Archlinux moves to systemd. My own remarks.
After some reading I rebooted, edited kernel loading line in my Grub2 with init param pointing to systemd and booted into my Arhclinux. What was noticable that I received to GUI :) Though I was aware that systemd ignores /etc/inittab (my SLiM used to start from inittab) and I wasn't that surprised. I did sudo systemctl enable slim.service (along with couple of other services which made sense for me) and rebooted again (needed not to forget to put init kernel param in place again).
Basically everything went smooth except just a few points, which weren't clear from documentation and which made me post this writing :)
Here I'm talking about pure systemd installations.
1. systemd-sysvcompat
Documentation from Archwiki states that you must not remove this package or you won't be able to boot any more. Though this package doesn't seem to contain any things I may need now (file list for systemd-sysvcompat). And it appeared to be true - if you want to remove this package you need to do the following (instructions for Grub2 loader):- edit /etc/default/grub and make sure you have init kernel param present, like this:
GRUB_CMDLINE_LINUX_DEFAULT="init=/usr/lib/systemd/systemd" - regenerate grub.cfg with sudo grub-mkconfig -o /boot/grub/grub.cfg
- now when everything went fine you could remove unnecessary things:
sudo pacman -Rcs sysvinit-tools
this should remove sysvinit-tools, initscripts, sysvinit and systemd-sysvcompat.
2. PCManFM doesn't show removable drives
While some other tools may show them. If not check documentation first. For me problem was that udisks daemon was inactive. So simple sudo systemctl enable udisks.service fixed this for me.These seem to be all the troubles with systemd for me, which I find pretty painless! :) And instead of conclusion: if you want to know what else services you could enable (or disable) use systemctl list-unit-files
Update 12.01.2015
After quite some time i concluded that having a /sbin/init makes way more sense in terms of compatibility and stability then having an init= kernel option configured in a boot loader. I just switched to UEFI and had to specify init= again. This time i just symlinked systemd to /sbin/init to end up this fight:ls -s '../lib/systemd/systemd' /usr/bin/init
28 June 2012
X11 session login with SLiM and no password
I'm not going to dig into security considerations regarding passwordless users here.
So firstly let's create a user for my mum and deprive it a password:
# useradd -m -U username
# passwd -d username
Explanation:
-m force home directory creation
-U automatically creates a group with same name as username and assigns it as primary group for new user
passwd -d removes password from given account
Now you should be able to login with new user into physical terminal session. Though this depends on PAM configuration in your distro (I'm using ArchLinux). You won't be able to su to this user or login into SLiM yet.
To allow SLiM login you with empty password you need to edit /etc/pam.d/slim:
find
auth required pam_unix.so
and change to
auth required pam_unix.so nullok
That's it. Same instructions should apply to any login manager, not only SLiM.
24 April 2012
Screensharing in Linux with GoToMeeting
These two were no the case for the event I needed to share my screen for :). Ideally I needed GoToMeeting and made it to share my screen! This instructions should work with most (if not any) of available screensharing solution for Windows.
Prerequisites:
In parenthesis I referred to software I was using.- Windows running on either virtual machine (even non-virtual would work if you have spare one) (Windows XP on VirtualBox)
- VNC server running on your Linux desktop (x11vnc)
- VNC client on your Windows PC (TightVNC)
Basic idea:
You should have guessed what I'm going to do next :) I explain if not. You share the screen of you Windows PC with screensharing tool of your choice. But what the screen will display is fullscreen VNC client connected to your Linux desktop. I suppose there might be some video issues with the way how VNC client draws the picture and the way screensharing tool captures the screen, that's why I mentioned what software I was using.Setup:
For sharing my desktop on Linux I ran x11vnc like that:$ x11vnc -display :0 -auth ~/.Xauthority -forever -nap -noxdamage
$ startx -- :1
Variations:
- On dual-screen setup you could share only one screen with
$ x11vnc -display :0 -auth ~/.Xauthority -forever -nap -noxdamage -clip 1680x1050+0+0
and thus you may try to avoid switching between different XServer by running VirtualBox instance on second screen. - Gnome users may use vino instead of x11vnc, though I haven't tried this.
08 May 2010
Using D-Bus to shutdown the machine
$ dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
If you will try to execute it, you may receive and error saying that you don't have permissions to send messages to org.freedesktop.Hal.devices.computer interface. If you did, you should open hal.conf from system config directory of D-Bus (mine is /etc/dbus-1/system.d/hal.conf) and add the following policy:
<policy group="shutdown">
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
</policy>
Now all the members of group shutdown will be able to switch off the computer by D-Bus. You just have to create the group:
# groupadd shutdownAnd add your user to this group:
# gpasswd -a user shutdownFinally you may want to create a script or desktop entry:
[Desktop Entry] Icon=system-shutdown Name=Shutdown Exec=dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown